validate:tools: Add an option to run testforever

This commit is contained in:
Thibault Saunier 2014-01-14 18:07:46 +01:00
parent d9386f7542
commit 299a677f09
2 changed files with 26 additions and 6 deletions

View file

@ -121,6 +121,7 @@ class Test(Loggable):
val = self.get_current_value()
self.debug("Got value: %s" % val)
if val is Result.NOT_RUN:
# The get_current_value logic is not implemented... dumb timeout
if time.time() - last_change_ts > self.timeout:
@ -297,9 +298,13 @@ class TestsManager(Loggable):
for test in self.tests:
if self._is_test_wanted(test):
self.reporter.before_test(test)
test.run()
if test.run() != Result.PASSED and\
self.options.forever:
return test.result
self.reporter.after_test()
return Result.PASSED
def needs_http_server(self):
return False
@ -309,6 +314,7 @@ class _TestsLauncher(Loggable):
Loggable.__init__(self)
self.options = None
self.testers = []
self.tests = []
self.reporter = None
@ -353,6 +359,7 @@ class _TestsLauncher(Loggable):
self.reporter = reporters.XunitReporter(options)
mkdir(options.logsdir)
self.options = options
wanted_testers = None
for tester in self.testers:
if tester.name in args:
@ -373,9 +380,22 @@ class _TestsLauncher(Loggable):
tester.list_tests()
self.tests.extend(tester.tests)
def run_tests(self):
def _run_tests(self):
for tester in self.testers:
tester.run_tests()
res = tester.run_tests()
if self.options.forever and res != Result.PASSED:
return False
return True
def run_tests(self):
if self.options.forever:
while self._run_tests():
continue
return False
else:
return self._run_tests()
def final_report(self):
self.reporter.final_report()

View file

@ -36,9 +36,9 @@ def main():
#action="store_true",
#default=False,
#help="Run applications into gdb")
#parser.add_option("-f", "--forever", dest="forever",
#action="store_true", default=False,
#help="Keep running tests until one fails")
parser.add_option("-f", "--forever", dest="forever",
action="store_true", default=False,
help="Keep running tests until one fails")
#parser.add_option("-F", "--fatal-error", dest="fatal_error",
#action="store_true", default=False,
#help="Stop on first fail")