aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xtools/run_tests/jobset.py13
-rwxr-xr-xtools/run_tests/run_tests.py4
2 files changed, 9 insertions, 8 deletions
diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py
index d3a46b63e1..2ab95ef97c 100755
--- a/tools/run_tests/jobset.py
+++ b/tools/run_tests/jobset.py
@@ -8,7 +8,7 @@ import tempfile
import time
-_MAX_JOBS = 16 * multiprocessing.cpu_count()
+_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
def shuffle_iteratable(it):
@@ -81,15 +81,16 @@ class Job(object):
class Jobset(object):
"""Manages one run of jobs."""
- def __init__(self, check_cancelled):
+ def __init__(self, check_cancelled, maxjobs):
self._running = set()
self._check_cancelled = check_cancelled
self._cancelled = False
self._failures = 0
+ self._maxjobs = maxjobs
def start(self, cmdline):
"""Start a job. Return True on success, False on failure."""
- while len(self._running) >= _MAX_JOBS:
+ while len(self._running) >= self._maxjobs:
if self.cancelled(): return False
self.reap()
if self.cancelled(): return False
@@ -130,10 +131,10 @@ def _never_cancelled():
return False
-def run(cmdlines, check_cancelled=_never_cancelled):
- js = Jobset(check_cancelled)
+def run(cmdlines, check_cancelled=_never_cancelled, maxjobs=None):
+ js = Jobset(check_cancelled,
+ maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS)
for cmdline in shuffle_iteratable(cmdlines):
if not js.start(cmdline):
break
return js.finish()
-
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 9234682bea..d678721274 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -43,10 +43,10 @@ def _build_and_run(check_cancelled):
# build latest, sharing cpu between the various makes
if not jobset.run(
(['make',
- '-j', '%d' % max(multiprocessing.cpu_count() / len(configs), 1),
+ '-j', '%d' % (multiprocessing.cpu_count() + 1),
'buildtests_c',
'CONFIG=%s' % cfg]
- for cfg in configs), check_cancelled):
+ for cfg in configs), check_cancelled, maxjobs=1):
sys.exit(1)
# run all the tests