diff --git a/Tools/autotest/ArduCopter.parm b/Tools/autotest/ArduCopter.parm index 5e9a2a45be..f3a4b30ce5 100644 --- a/Tools/autotest/ArduCopter.parm +++ b/Tools/autotest/ArduCopter.parm @@ -1,4 +1,5 @@ FRAME 0 +LOG_BITMASK 4095 RC1_MAX 2000.000000 RC1_MIN 1000.000000 RC1_TRIM 1500.000000 diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 601ad3cb20..86e600e659 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -256,8 +256,7 @@ def fly_ArduCopter(): '''fly ArduCopter in SIL''' global expect_list, homeloc - util.rmfile('eeprom.bin') - sil = util.start_SIL('ArduCopter') + sil = util.start_SIL('ArduCopter', wipe=True) mavproxy = util.start_MAVProxy_SIL('ArduCopter') mavproxy.expect('Please Run Setup') diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index 1daaceddfe..721f03c3d9 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -9,8 +9,7 @@ os.putenv('TMPDIR', util.reltopdir('tmp')) def get_default_params(atype): '''get default parameters''' - util.rmfile('eeprom.bin') - sil = util.start_SIL(atype) + sil = util.start_SIL(atype, wipe=True) mavproxy = util.start_MAVProxy_SIL(atype) idx = mavproxy.expect(['Please Run Setup', 'Saved [0-9]+ parameters to (\S+)']) if idx == 0: @@ -27,6 +26,24 @@ def get_default_params(atype): sil.close() print("Saved defaults for %s to %s" % (atype, dest)) + +def dump_logs(atype): + '''dump DataFlash logs''' + print("Dumping logs for %s" % atype) + sil = util.start_SIL(atype, CLI=True) + logfile = util.reltopdir('../buildlogs/%s.flashlog' % atype) + log = open(logfile, mode='w') + mavproxy = util.start_MAVProxy_SIL(atype, setup=True, logfile=log) + mavproxy.expect(']') + mavproxy.send("logs\n") + mavproxy.expect("Log]") + mavproxy.send("dump 1\n") + mavproxy.expect("Log]") + mavproxy.close() + sil.close() + log.close() + print("Saved log for %s to %s" % (atype, logfile)) + def test_prerequesites(): '''check we have the right directories and tools to run tests''' print("Testing prerequesites") @@ -49,10 +66,12 @@ opts, args = parser.parse_args() steps = [ 'build.ArduPlane', - 'build.ArduCopter', 'defaults.ArduPlane', + 'logs.ArduPlane', + 'build.ArduCopter', 'defaults.ArduCopter', - 'fly.ArduCopter' + 'fly.ArduCopter', + 'logs.ArduCopter', ] skipsteps = opts.skip.split(',') @@ -81,6 +100,10 @@ for step in steps: get_default_params('ArduPlane') elif step == 'defaults.ArduCopter': get_default_params('ArduCopter') + elif step == 'logs.ArduPlane': + dump_logs('ArduPlane') + elif step == 'logs.ArduCopter': + dump_logs('ArduCopter') elif step == 'fly.ArduCopter': arducopter.fly_ArduCopter() else: diff --git a/Tools/autotest/util.py b/Tools/autotest/util.py index 97b7caf916..e87c2b2280 100644 --- a/Tools/autotest/util.py +++ b/Tools/autotest/util.py @@ -32,7 +32,7 @@ def run_cmd(cmd, dir=".", show=False, output=False, checkfail=True): def rmfile(path): '''remove a file if it exists''' try: - os.unlink('eeprom.bin') + os.unlink(path) except Exception: pass @@ -48,19 +48,33 @@ def build_SIL(atype): dir=reltopdir(atype), checkfail=True) -def start_SIL(atype): +def start_SIL(atype, valgrind=True, wipe=False, CLI=False): '''launch a SIL instance''' - ret = pexpect.spawn(('valgrind -q --log-file=%s-valgrind.log ' % atype) + reltopdir('tmp/%s.build/%s.elf' % (atype, atype)), - logfile=sys.stdout, timeout=5) + cmd="" + if valgrind: + cmd += 'valgrind -q --log-file=%s-valgrind.log ' % atype + cmd += reltopdir('tmp/%s.build/%s.elf' % (atype, atype)) + if wipe: + cmd += ' -w' + if CLI: + cmd += ' -s' + ret = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5) ret.expect('Waiting for connection') return ret -def start_MAVProxy_SIL(atype, options=''): +def start_MAVProxy_SIL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1:5760', + options=None, logfile=sys.stdout): '''launch mavproxy connected to a SIL instance''' MAVPROXY = reltopdir('../MAVProxy/mavproxy.py') - ret = pexpect.spawn('%s --master=tcp:127.0.0.1:5760 --aircraft=test.%s %s' % ( - MAVPROXY,atype,options), - logfile=sys.stdout, timeout=60) + cmd = MAVPROXY + ' --master=%s' % master + if setup: + cmd += ' --setup' + if aircraft is None: + aircraft = 'test.%s' % atype + cmd += ' --aircraft=%s' % aircraft + if options is not None: + cmd += ' ' + options + ret = pexpect.spawn(cmd, logfile=logfile, timeout=60) return ret