From ee04c0ef50874b961609cd6beddd39bb11230bd8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 26 Nov 2011 18:12:19 +1100 Subject: [PATCH] autotest: cope with exceptions in tests leaving child processes --- Tools/autotest/autotest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index 169a710c30..9ec59bd635 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -14,6 +14,7 @@ def get_default_params(atype): '''get default parameters''' sil = util.start_SIL(atype, wipe=True) mavproxy = util.start_MAVProxy_SIL(atype) + print("Dumping defaults") idx = mavproxy.expect(['Please Run Setup', 'Saved [0-9]+ parameters to (\S+)']) if idx == 0: # we need to restart it after eeprom erase @@ -37,11 +38,15 @@ def dump_logs(atype): logfile = util.reltopdir('../buildlogs/%s.flashlog' % atype) log = open(logfile, mode='w') mavproxy = util.start_MAVProxy_SIL(atype, setup=True, logfile=log) + print("navigating menus") mavproxy.expect(']') mavproxy.send("logs\n") mavproxy.expect("logs enabled:") - mavproxy.expect("(\d+) logs") - numlogs = int(mavproxy.match.group(1)) + i = mavproxy.expect(["No logs", "(\d+) logs"]) + if i == 0: + numlogs = 0 + else: + numlogs = int(mavproxy.match.group(1)) mavproxy.expect("Log]") for i in range(numlogs): mavproxy.send("dump %u\n" % (i+1)) @@ -243,6 +248,7 @@ def run_tests(steps): print(">>>> FAILED STEP: %s at %s (%s)" % (step, time.asctime(), msg)) traceback.print_exc(file=sys.stdout) results.add(step, 'FAILED', time.time() - t1) + util.pexpect_close_all() continue results.add(step, 'PASSED', time.time() - t1) print(">>>> PASSED STEP: %s at %s" % (step, time.asctime()))