tests: Add optional -1 argument to parallel-vm.py

This can be used to skip rerunning of failed test cases
(e.g., with "./parallel-vm.py 1 -1 <test case>").

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-17 11:25:46 +02:00
parent 242b83a380
commit 802bf82482

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# #
# Parallel VM test case executor # Parallel VM test case executor
# Copyright (c) 2014, Jouni Malinen <j@w1.fi> # Copyright (c) 2014-2015, Jouni Malinen <j@w1.fi>
# #
# This software may be distributed under the terms of the BSD license. # This software may be distributed under the terms of the BSD license.
# See README for more details. # See README for more details.
@ -24,6 +24,7 @@ def get_failed(vm):
def vm_read_stdout(vm, i): def vm_read_stdout(vm, i):
global total_started, total_passed, total_failed, total_skipped global total_started, total_passed, total_failed, total_skipped
global rerun_failures
ready = False ready = False
try: try:
@ -147,7 +148,8 @@ def show_progress(scr):
raise Exception("Unexpected test cases remaining from first round") raise Exception("Unexpected test cases remaining from first round")
completed_first_pass = True completed_first_pass = True
for name in get_failed(vm): for name in get_failed(vm):
rerun_tests.append(name) if rerun_failures:
rerun_tests.append(name)
first_run_failures.append(name) first_run_failures.append(name)
for i in range(num_servers): for i in range(num_servers):
@ -225,6 +227,8 @@ def show_progress(scr):
scr.clrtoeol() scr.clrtoeol()
if rerun_tests: if rerun_tests:
scr.addstr("(RETRY FAILED %d)" % len(rerun_tests)) scr.addstr("(RETRY FAILED %d)" % len(rerun_tests))
elif rerun_failures:
pass
elif first_run_failures: elif first_run_failures:
scr.addstr("(RETRY FAILED)") scr.addstr("(RETRY FAILED)")
@ -243,6 +247,7 @@ def main():
global tests global tests
global first_run_failures global first_run_failures
global total_started, total_passed, total_failed, total_skipped global total_started, total_passed, total_failed, total_skipped
global rerun_failures
total_started = 0 total_started = 0
total_passed = 0 total_passed = 0
@ -250,9 +255,10 @@ def main():
total_skipped = 0 total_skipped = 0
debug_level = logging.INFO debug_level = logging.INFO
rerun_failures = True
if len(sys.argv) < 2: if len(sys.argv) < 2:
sys.exit("Usage: %s <number of VMs> [--debug] [--codecov] [params..]" % sys.argv[0]) sys.exit("Usage: %s <number of VMs> [-1] [--debug] [--codecov] [params..]" % sys.argv[0])
num_servers = int(sys.argv[1]) num_servers = int(sys.argv[1])
if num_servers < 1: if num_servers < 1:
sys.exit("Too small number of VMs") sys.exit("Too small number of VMs")
@ -261,6 +267,10 @@ def main():
idx = 2 idx = 2
if len(sys.argv) > idx and sys.argv[idx] == "-1":
idx += 1
rerun_failures = False
if len(sys.argv) > idx and sys.argv[idx] == "--debug": if len(sys.argv) > idx and sys.argv[idx] == "--debug":
idx += 1 idx += 1
debug_level = logging.DEBUG debug_level = logging.DEBUG
@ -389,7 +399,9 @@ def main():
double_failed.append(name) double_failed.append(name)
for test in first_run_failures: for test in first_run_failures:
double_failed.remove(test) double_failed.remove(test)
if failed and not double_failed: if not rerun_failures:
pass
elif failed and not double_failed:
print "All failed cases passed on retry" print "All failed cases passed on retry"
logger.info("All failed cases passed on retry") logger.info("All failed cases passed on retry")
elif double_failed: elif double_failed:
@ -427,7 +439,7 @@ def main():
print "file://%s/index.html" % logdir print "file://%s/index.html" % logdir
logger.info("Code coverage report: file://%s/index.html" % logdir) logger.info("Code coverage report: file://%s/index.html" % logdir)
if double_failed: if double_failed or (failed and not rerun_failures):
logger.info("Test run complete - failures found") logger.info("Test run complete - failures found")
sys.exit(2) sys.exit(2)
if failed: if failed: