[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1142/8267] oe-build-perf-test: enable locking
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 1142/8267] oe-build-perf-test: enable locking
- Date: Sat, 16 Dec 2017 21:24:48 +0000 (UTC)
commit c3ee14ef38f73c3a782b0fc8333ce437d165e4ff
Author: Markus Lehtonen <markus lehtonen linux intel com>
Date: Thu Jun 23 18:48:11 2016 +0300
oe-build-perf-test: enable locking
Makes it possible to guard that multiple tests are not run in parallel.
(From OE-Core rev: 181e92e7a1bccf678b3eb1bf547608a142784f97)
Signed-off-by: Markus Lehtonen <markus lehtonen linux intel com>
Signed-off-by: Ross Burton <ross burton intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
scripts/oe-build-perf-test | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 9dd073c..64873c9 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -15,6 +15,8 @@
#
"""Build performance test script"""
import argparse
+import errno
+import fcntl
import logging
import os
import sys
@@ -33,6 +35,19 @@ logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
log = logging.getLogger()
+def acquire_lock(lock_f):
+ """Acquire flock on file"""
+ log.debug("Acquiring lock %s", os.path.abspath(lock_f.name))
+ try:
+ fcntl.flock(lock_f, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError as err:
+ if err.errno == errno.EAGAIN:
+ return False
+ raise
+ log.debug("Lock acquired")
+ return True
+
+
def pre_run_sanity_check():
"""Sanity check of build environment"""
build_dir = os.environ.get("BUILDDIR")
@@ -72,6 +87,9 @@ def parse_args(argv):
help='Enable debug level logging')
parser.add_argument('--globalres-file',
help="Append results to 'globalres' csv file")
+ parser.add_argument('--lock-file', default='./oe-build-perf.lock',
+ metavar='FILENAME',
+ help="Lock file to use")
return parser.parse_args(argv)
@@ -83,6 +101,11 @@ def main(argv=None):
if args.debug:
log.setLevel(logging.DEBUG)
+ lock_f = open(args.lock_file, 'w')
+ if not acquire_lock(lock_f):
+ log.error("Another instance of this script is running, exiting...")
+ return 1
+
if not pre_run_sanity_check():
return 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]