validate: launcher: Add option to run tests in parallel

Patch 4/4 to implement parallel test execution.

https://bugzilla.gnome.org/show_bug.cgi?id=743063
This commit is contained in:
Ramiro Polla 2015-01-16 21:29:55 +01:00 committed by Thibault Saunier
parent 1f981762c2
commit c0cefecd23
2 changed files with 17 additions and 1 deletions

View file

@ -197,6 +197,11 @@ class Test(Loggable):
"""
Returns True when process has finished running or has timed out.
"""
if self.process is None:
# Process has not started running yet
return False
self.process.poll()
if self.process.returncode is not None:
return True
@ -819,19 +824,26 @@ class TestsManager(Loggable):
self.total_num_tests = total_num_tests
self.starting_test_num = starting_test_num
num_jobs = min(self.options.num_jobs, len(self.tests))
tests_left = list(self.tests)
jobs_running = 0
while True:
for i in range(num_jobs):
if not self.start_new_job(tests_left):
break
jobs_running += 1
while jobs_running != 0:
test = self.tests_wait()
jobs_running -= 1
self.print_test_num(test)
res = test.test_end()
self.reporter.after_test(test)
if res != Result.PASSED and (self.options.forever or
self.options.fatal_error):
return test.result
if self.start_new_job(tests_left):
jobs_running += 1
return Result.PASSED

View file

@ -209,6 +209,7 @@ class LauncherConfig(Loggable):
self.output_dir = None
self.logsdir = None
self.redirect_logs = False
self.num_jobs = 1
self.dest = None
self._using_default_paths = False
self.paths = []
@ -421,6 +422,9 @@ Note that all testsuite should be inside python modules, so the directory should
" default is MAIN_DIR/gst-integration-testsuites")
dir_group.add_argument("-rl", "--redirect-logs", dest="redirect_logs",
help="Redirect logs to 'stdout' or 'sdterr'.")
dir_group.add_argument("-j", "--jobs", dest="num_jobs",
help="Number of tests to execute simultaneously",
type=int)
http_server_group = parser.add_argument_group(
"Handle the HTTP server to be created")