2011-10-30 23:50:34 -03:00
|
|
|
#!/usr/bin/env python
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
|
|
|
APM automatic test suite
|
|
|
|
Andrew Tridgell, October 2011
|
|
|
|
"""
|
2016-11-08 07:06:05 -04:00
|
|
|
from __future__ import print_function
|
2016-07-31 07:22:06 -03:00
|
|
|
import atexit
|
|
|
|
import fnmatch
|
|
|
|
import glob
|
|
|
|
import optparse
|
|
|
|
import os
|
2018-12-13 21:40:01 -04:00
|
|
|
import re
|
2016-07-31 07:22:06 -03:00
|
|
|
import shutil
|
|
|
|
import signal
|
2018-07-03 21:51:22 -03:00
|
|
|
import subprocess
|
2016-07-31 07:22:06 -03:00
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
import apmrover2
|
|
|
|
import arducopter
|
|
|
|
import arduplane
|
|
|
|
import ardusub
|
2019-02-20 19:07:53 -04:00
|
|
|
import antennatracker
|
2018-07-03 21:51:22 -03:00
|
|
|
import quadplane
|
2018-07-20 08:53:31 -03:00
|
|
|
import balancebot
|
2018-03-05 11:14:34 -04:00
|
|
|
|
2017-08-02 08:08:28 -03:00
|
|
|
import examples
|
2016-07-31 07:22:06 -03:00
|
|
|
from pysim import util
|
2017-08-09 10:06:50 -03:00
|
|
|
from pymavlink import mavutil
|
|
|
|
from pymavlink.generator import mavtemplate
|
2011-12-02 00:21:15 -04:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2017-08-30 03:18:32 -03:00
|
|
|
def buildlogs_dirpath():
|
|
|
|
return os.getenv("BUILDLOGS", util.reltopdir("../buildlogs"))
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2017-08-30 03:18:32 -03:00
|
|
|
def buildlogs_path(path):
|
2018-07-31 06:50:02 -03:00
|
|
|
"""return a string representing path in the buildlogs directory"""
|
2017-08-30 03:18:32 -03:00
|
|
|
bits = [buildlogs_dirpath()]
|
|
|
|
if isinstance(path, list):
|
|
|
|
bits.extend(path)
|
|
|
|
else:
|
|
|
|
bits.append(path)
|
|
|
|
return os.path.join(*bits)
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2016-05-21 12:19:50 -03:00
|
|
|
def get_default_params(atype, binary):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Get default parameters."""
|
2015-03-25 22:57:46 -03:00
|
|
|
|
|
|
|
# use rover simulator so SITL is not starved of input
|
2018-07-03 21:51:22 -03:00
|
|
|
HOME = mavutil.location(40.071374969556928,
|
|
|
|
-105.22978898137808,
|
|
|
|
1583.702759,
|
|
|
|
246)
|
2017-08-09 10:04:16 -03:00
|
|
|
if "plane" in binary or "rover" in binary:
|
2016-05-21 12:19:50 -03:00
|
|
|
frame = "rover"
|
2015-05-04 20:26:31 -03:00
|
|
|
else:
|
2016-05-21 12:19:50 -03:00
|
|
|
frame = "+"
|
2015-03-25 22:57:46 -03:00
|
|
|
|
2015-05-05 03:56:17 -03:00
|
|
|
home = "%f,%f,%u,%u" % (HOME.lat, HOME.lng, HOME.alt, HOME.heading)
|
2018-07-03 21:51:22 -03:00
|
|
|
sitl = util.start_SITL(binary,
|
|
|
|
wipe=True,
|
|
|
|
model=frame,
|
|
|
|
home=home,
|
|
|
|
speedup=10,
|
|
|
|
unhide_parameters=True)
|
2016-07-31 07:22:06 -03:00
|
|
|
mavproxy = util.start_MAVProxy_SITL(atype)
|
2011-11-26 03:12:19 -04:00
|
|
|
print("Dumping defaults")
|
2018-07-03 21:51:22 -03:00
|
|
|
idx = mavproxy.expect(['Saved [0-9]+ parameters to (\S+)'])
|
2011-10-30 23:50:34 -03:00
|
|
|
if idx == 0:
|
|
|
|
# we need to restart it after eeprom erase
|
2011-11-09 00:45:18 -04:00
|
|
|
util.pexpect_close(mavproxy)
|
2016-07-31 07:22:06 -03:00
|
|
|
util.pexpect_close(sitl)
|
|
|
|
sitl = util.start_SITL(binary, model=frame, home=home, speedup=10)
|
|
|
|
mavproxy = util.start_MAVProxy_SITL(atype)
|
2019-09-21 03:04:51 -03:00
|
|
|
mavproxy.expect('Saved [0-9]+ parameters to (\S+)')
|
2011-10-30 23:50:34 -03:00
|
|
|
parmfile = mavproxy.match.group(1)
|
2017-08-30 03:18:32 -03:00
|
|
|
dest = buildlogs_path('%s-defaults.parm' % atype)
|
2011-10-30 23:50:34 -03:00
|
|
|
shutil.copy(parmfile, dest)
|
2011-11-09 00:45:18 -04:00
|
|
|
util.pexpect_close(mavproxy)
|
2016-07-31 07:22:06 -03:00
|
|
|
util.pexpect_close(sitl)
|
2011-10-30 23:50:34 -03:00
|
|
|
print("Saved defaults for %s to %s" % (atype, dest))
|
2011-11-09 01:15:53 -04:00
|
|
|
return True
|
2011-11-07 07:55:21 -04:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
def build_all_filepath():
|
|
|
|
return util.reltopdir('Tools/scripts/build_all.sh')
|
|
|
|
|
|
|
|
|
2012-02-19 02:05:21 -04:00
|
|
|
def build_all():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Run the build_all.sh script."""
|
2012-02-19 02:05:21 -04:00
|
|
|
print("Running build_all.sh")
|
2018-07-04 20:02:02 -03:00
|
|
|
if util.run_cmd(build_all_filepath(), directory=util.reltopdir('.')) != 0:
|
2012-02-19 02:05:21 -04:00
|
|
|
print("Failed build_all.sh")
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-03-10 03:16:56 -03:00
|
|
|
def build_binaries():
|
2017-09-04 21:58:56 -03:00
|
|
|
"""Run the build_binaries.py script."""
|
|
|
|
print("Running build_binaries.py")
|
2018-07-03 21:51:22 -03:00
|
|
|
# copy the script as it changes git branch, which can change the
|
|
|
|
# script while running
|
2017-09-04 21:58:56 -03:00
|
|
|
orig = util.reltopdir('Tools/scripts/build_binaries.py')
|
|
|
|
copy = util.reltopdir('./build_binaries.py')
|
2017-08-09 10:23:54 -03:00
|
|
|
shutil.copy2(orig, copy)
|
|
|
|
|
2017-10-25 17:57:48 -03:00
|
|
|
# also copy generate_manifest library:
|
|
|
|
orig_gm = util.reltopdir('Tools/scripts/generate_manifest.py')
|
|
|
|
copy_gm = util.reltopdir('./generate_manifest.py')
|
|
|
|
shutil.copy2(orig_gm, copy_gm)
|
|
|
|
|
2019-05-03 22:20:37 -03:00
|
|
|
# and gen_stable.py
|
|
|
|
orig_gs = util.reltopdir('Tools/scripts/gen_stable.py')
|
|
|
|
copy_gs = util.reltopdir('./gen_stable.py')
|
|
|
|
shutil.copy2(orig_gs, copy_gs)
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
if util.run_cmd(copy, directory=util.reltopdir('.')) != 0:
|
2017-09-04 21:58:56 -03:00
|
|
|
print("Failed build_binaries.py")
|
2013-03-10 03:16:56 -03:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2012-11-24 06:12:05 -04:00
|
|
|
def build_examples():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Build examples."""
|
2018-11-20 06:25:55 -04:00
|
|
|
for target in 'fmuv2', 'Pixhawk1', 'navio', 'linux':
|
2016-06-01 07:17:13 -03:00
|
|
|
print("Running build.examples for %s" % target)
|
|
|
|
try:
|
|
|
|
util.build_examples(target)
|
|
|
|
except Exception as e:
|
|
|
|
print("Failed build_examples on board=%s" % target)
|
|
|
|
print(str(e))
|
|
|
|
return False
|
|
|
|
|
2012-11-24 06:12:05 -04:00
|
|
|
return True
|
|
|
|
|
2018-08-14 21:33:52 -03:00
|
|
|
def build_unit_tests():
|
|
|
|
"""Build tests."""
|
|
|
|
for target in ['linux']:
|
|
|
|
print("Running build.unit_tests for %s" % target)
|
|
|
|
try:
|
|
|
|
util.build_tests(target)
|
|
|
|
except Exception as e:
|
|
|
|
print("Failed build.unit_tests on board=%s" % target)
|
|
|
|
print(str(e))
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def run_unit_test(test):
|
|
|
|
print("Running (%s)" % test)
|
|
|
|
subprocess.check_call([test])
|
|
|
|
|
|
|
|
|
|
|
|
def run_unit_tests():
|
|
|
|
binary_dir = util.reltopdir(os.path.join('build',
|
|
|
|
'linux',
|
|
|
|
'tests',
|
|
|
|
))
|
|
|
|
tests = glob.glob("%s/*" % binary_dir)
|
|
|
|
success = True
|
|
|
|
for test in tests:
|
|
|
|
try:
|
|
|
|
run_unit_test(test)
|
|
|
|
except Exception as e:
|
|
|
|
print("Exception running (%s): %s" % (test, e.message))
|
|
|
|
success = False
|
|
|
|
return success
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
def param_parse_filepath():
|
|
|
|
return util.reltopdir('Tools/autotest/param_metadata/param_parse.py')
|
|
|
|
|
|
|
|
|
|
|
|
def all_vehicles():
|
|
|
|
return ('ArduPlane',
|
|
|
|
'ArduCopter',
|
|
|
|
'APMrover2',
|
|
|
|
'AntennaTracker',
|
|
|
|
'ArduSub')
|
|
|
|
|
|
|
|
|
2013-05-21 04:01:59 -03:00
|
|
|
def build_parameters():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Run the param_parse.py script."""
|
2013-05-21 04:01:59 -03:00
|
|
|
print("Running param_parse.py")
|
2018-07-03 21:51:22 -03:00
|
|
|
for vehicle in all_vehicles():
|
|
|
|
if util.run_cmd([param_parse_filepath(), '--vehicle', vehicle],
|
|
|
|
directory=util.reltopdir('.')) != 0:
|
2017-08-25 10:55:51 -03:00
|
|
|
print("Failed param_parse.py (%s)" % vehicle)
|
|
|
|
return False
|
2013-05-21 04:01:59 -03:00
|
|
|
return True
|
|
|
|
|
2012-02-19 02:05:21 -04:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
def mavtogpx_filepath():
|
|
|
|
return util.reltopdir("modules/mavlink/pymavlink/tools/mavtogpx.py")
|
|
|
|
|
|
|
|
|
2011-11-09 05:27:00 -04:00
|
|
|
def convert_gpx():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Convert any tlog files to GPX and KML."""
|
2017-08-30 03:18:32 -03:00
|
|
|
mavlog = glob.glob(buildlogs_path("*.tlog"))
|
2018-03-21 19:11:44 -03:00
|
|
|
passed = True
|
2011-11-09 05:27:00 -04:00
|
|
|
for m in mavlog:
|
2018-07-03 21:51:22 -03:00
|
|
|
util.run_cmd(mavtogpx_filepath() + " --nofixcheck " + m)
|
2011-11-09 05:27:00 -04:00
|
|
|
gpx = m + '.gpx'
|
|
|
|
kml = m + '.kml'
|
2018-03-21 19:11:44 -03:00
|
|
|
try:
|
2018-07-03 21:51:22 -03:00
|
|
|
util.run_cmd('gpsbabel -i gpx -f %s '
|
|
|
|
'-o kml,units=m,floating=1,extrude=1 -F %s' %
|
|
|
|
(gpx, kml))
|
|
|
|
except subprocess.CalledProcessError as e:
|
2018-03-21 19:11:44 -03:00
|
|
|
passed = False
|
|
|
|
try:
|
|
|
|
util.run_cmd('zip %s.kmz %s.kml' % (m, m))
|
2018-07-03 21:51:22 -03:00
|
|
|
except subprocess.CalledProcessError as e:
|
2018-03-21 19:11:44 -03:00
|
|
|
passed = False
|
2016-07-31 07:22:06 -03:00
|
|
|
util.run_cmd("mavflightview.py --imagefile=%s.png %s" % (m, m))
|
2018-03-21 19:11:44 -03:00
|
|
|
return passed
|
2011-11-09 05:27:00 -04:00
|
|
|
|
|
|
|
|
2014-08-04 17:28:59 -03:00
|
|
|
def test_prerequisites():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Check we have the right directories and tools to run tests."""
|
2014-08-04 17:28:59 -03:00
|
|
|
print("Testing prerequisites")
|
2017-08-30 03:18:32 -03:00
|
|
|
util.mkdir_p(buildlogs_dirpath())
|
2011-11-09 01:15:53 -04:00
|
|
|
return True
|
2011-11-12 19:11:25 -04:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2012-06-15 03:52:55 -03:00
|
|
|
def alarm_handler(signum, frame):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Handle test timeout."""
|
2012-06-15 03:52:55 -03:00
|
|
|
global results, opts
|
|
|
|
try:
|
2019-02-04 16:41:09 -04:00
|
|
|
print("Alarm handler called")
|
2018-07-03 21:51:22 -03:00
|
|
|
results.add('TIMEOUT',
|
|
|
|
'<span class="failed-text">FAILED</span>',
|
|
|
|
opts.timeout)
|
2012-06-15 17:47:55 -03:00
|
|
|
util.pexpect_close_all()
|
2012-07-09 20:13:16 -03:00
|
|
|
convert_gpx()
|
2013-07-08 19:48:17 -03:00
|
|
|
write_fullresults()
|
2012-06-15 03:52:55 -03:00
|
|
|
os.killpg(0, signal.SIGKILL)
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
sys.exit(1)
|
2011-10-30 23:50:34 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2017-08-09 05:25:04 -03:00
|
|
|
def should_run_step(step):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""See if a step should be skipped."""
|
2011-10-30 23:50:34 -03:00
|
|
|
for skip in skipsteps:
|
2012-11-29 03:09:44 -04:00
|
|
|
if fnmatch.fnmatch(step.lower(), skip.lower()):
|
2017-08-09 05:25:04 -03:00
|
|
|
return False
|
|
|
|
return True
|
2011-10-30 23:50:34 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2017-08-09 10:04:16 -03:00
|
|
|
__bin_names = {
|
2018-07-03 21:51:22 -03:00
|
|
|
"ArduCopter": "arducopter",
|
|
|
|
"ArduPlane": "arduplane",
|
|
|
|
"APMrover2": "ardurover",
|
|
|
|
"AntennaTracker": "antennatracker",
|
|
|
|
"CopterAVC": "arducopter-heli",
|
|
|
|
"QuadPlane": "arduplane",
|
2018-07-20 08:53:31 -03:00
|
|
|
"ArduSub": "ardusub",
|
2018-12-15 03:43:20 -04:00
|
|
|
"balancebot": "ardurover",
|
|
|
|
"BalanceBot": "ardurover",
|
2017-08-09 10:04:16 -03:00
|
|
|
}
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2016-05-21 12:19:50 -03:00
|
|
|
def binary_path(step, debug=False):
|
2017-10-22 02:26:24 -03:00
|
|
|
try:
|
|
|
|
vehicle = step.split(".")[1]
|
|
|
|
except Exception:
|
|
|
|
return None
|
2017-08-09 10:04:16 -03:00
|
|
|
|
|
|
|
if vehicle in __bin_names:
|
|
|
|
binary_name = __bin_names[vehicle]
|
2016-05-21 12:19:50 -03:00
|
|
|
else:
|
2016-05-27 18:29:23 -03:00
|
|
|
# cope with builds that don't have a specific binary
|
|
|
|
return None
|
2016-05-21 12:19:50 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
binary = util.reltopdir(os.path.join('build',
|
|
|
|
'sitl',
|
|
|
|
'bin',
|
|
|
|
binary_name))
|
2016-05-21 12:19:50 -03:00
|
|
|
if not os.path.exists(binary):
|
|
|
|
if os.path.exists(binary + ".exe"):
|
2016-07-31 07:22:06 -03:00
|
|
|
binary += ".exe"
|
2016-05-21 12:19:50 -03:00
|
|
|
else:
|
|
|
|
raise ValueError("Binary (%s) does not exist" % (binary,))
|
|
|
|
|
|
|
|
return binary
|
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
def split_specific_test_step(step):
|
|
|
|
print('step=%s' % str(step))
|
2019-02-20 19:07:53 -04:00
|
|
|
m = re.match("((fly|drive|dive|test)[.][^.]+)[.](.*)", step)
|
2018-12-13 21:40:01 -04:00
|
|
|
if m is None:
|
|
|
|
return None
|
|
|
|
return ( (m.group(1), m.group(3)) )
|
|
|
|
|
|
|
|
def find_specific_test_to_run(step):
|
|
|
|
t = split_specific_test_step(step)
|
|
|
|
if t is None:
|
|
|
|
return None
|
|
|
|
(testname, test) = t
|
|
|
|
return "%s.%s" % (testname, test)
|
|
|
|
|
2019-03-08 21:28:27 -04:00
|
|
|
tester_class_map = {
|
|
|
|
"fly.ArduCopter": arducopter.AutoTestCopter,
|
|
|
|
"fly.ArduPlane": arduplane.AutoTestPlane,
|
|
|
|
"fly.QuadPlane": quadplane.AutoTestQuadPlane,
|
|
|
|
"drive.APMrover2": apmrover2.AutoTestRover,
|
|
|
|
"drive.balancebot": balancebot.AutoTestBalanceBot,
|
|
|
|
"fly.CopterAVC": arducopter.AutoTestHeli,
|
|
|
|
"dive.ArduSub": ardusub.AutoTestSub,
|
|
|
|
"test.AntennaTracker": antennatracker.AutoTestTracker,
|
|
|
|
}
|
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
def run_specific_test(step, *args, **kwargs):
|
|
|
|
t = split_specific_test_step(step)
|
|
|
|
if t is None:
|
|
|
|
return []
|
|
|
|
(testname, test) = t
|
|
|
|
|
|
|
|
tester_class = tester_class_map[testname]
|
|
|
|
tester = tester_class(*args, **kwargs)
|
|
|
|
|
|
|
|
print("Got %s" % str(tester))
|
|
|
|
for a in tester.tests():
|
|
|
|
print("Got %s" % (a[0]))
|
|
|
|
if a[0] == test:
|
|
|
|
return tester.run_tests([a])
|
|
|
|
print("Failed to find test %s on %s" % (test, testname))
|
|
|
|
sys.exit(1)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2011-11-09 01:15:53 -04:00
|
|
|
def run_step(step):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Run one step."""
|
2014-11-13 01:31:26 -04:00
|
|
|
|
|
|
|
# remove old logs
|
2014-11-13 06:52:48 -04:00
|
|
|
util.run_cmd('/bin/rm -f logs/*.BIN logs/LASTLOG.TXT')
|
2014-11-13 01:31:26 -04:00
|
|
|
|
2014-08-04 17:28:59 -03:00
|
|
|
if step == "prerequisites":
|
|
|
|
return test_prerequisites()
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2017-09-08 01:17:22 -03:00
|
|
|
build_opts = {
|
|
|
|
"j": opts.j,
|
|
|
|
"debug": opts.debug,
|
|
|
|
"clean": not opts.no_clean,
|
|
|
|
"configure": not opts.no_configure,
|
2018-09-30 20:04:57 -03:00
|
|
|
"extra_configure_args": opts.waf_configure_args,
|
2017-09-08 01:17:22 -03:00
|
|
|
}
|
2018-05-10 22:31:29 -03:00
|
|
|
|
|
|
|
vehicle_binary = None
|
2011-11-09 01:15:53 -04:00
|
|
|
if step == 'build.ArduPlane':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/arduplane'
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2012-11-27 19:43:11 -04:00
|
|
|
if step == 'build.APMrover2':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/ardurover'
|
2012-11-27 19:43:11 -04:00
|
|
|
|
2011-11-09 01:15:53 -04:00
|
|
|
if step == 'build.ArduCopter':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/arducopter'
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2015-09-15 19:02:51 -03:00
|
|
|
if step == 'build.AntennaTracker':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/antennatracker'
|
2015-09-15 19:02:51 -03:00
|
|
|
|
2015-05-27 05:13:55 -03:00
|
|
|
if step == 'build.Helicopter':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/arducopter-heli'
|
|
|
|
|
2017-02-24 19:22:38 -04:00
|
|
|
if step == 'build.ArduSub':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/ardusub'
|
|
|
|
|
|
|
|
if vehicle_binary is not None:
|
|
|
|
return util.build_SITL(vehicle_binary, **build_opts)
|
2016-05-21 12:19:50 -03:00
|
|
|
|
|
|
|
binary = binary_path(step, debug=opts.debug)
|
2015-05-27 05:13:55 -03:00
|
|
|
|
2018-03-28 19:19:36 -03:00
|
|
|
if step.startswith("defaults"):
|
|
|
|
vehicle = step[9:]
|
2017-08-09 06:10:18 -03:00
|
|
|
return get_default_params(vehicle, binary)
|
2012-11-27 19:43:11 -04:00
|
|
|
|
2017-08-26 01:59:36 -03:00
|
|
|
fly_opts = {
|
|
|
|
"viewerip": opts.viewerip,
|
|
|
|
"use_map": opts.map,
|
|
|
|
"valgrind": opts.valgrind,
|
|
|
|
"gdb": opts.gdb,
|
2019-09-24 14:44:02 -03:00
|
|
|
"lldb": opts.lldb,
|
2017-08-26 01:59:36 -03:00
|
|
|
"gdbserver": opts.gdbserver,
|
2018-07-23 04:06:00 -03:00
|
|
|
"breakpoints": opts.breakpoint,
|
2019-07-11 21:58:46 -03:00
|
|
|
"disable_breakpoints": opts.disable_breakpoints,
|
2019-02-08 20:21:56 -04:00
|
|
|
"frame": opts.frame,
|
2018-08-03 22:15:44 -03:00
|
|
|
"_show_test_timings": opts.show_test_timings,
|
2017-08-26 01:59:36 -03:00
|
|
|
}
|
|
|
|
if opts.speedup is not None:
|
2018-02-12 21:12:27 -04:00
|
|
|
fly_opts["speedup"] = opts.speedup
|
2017-08-26 01:59:36 -03:00
|
|
|
|
2019-03-08 21:28:27 -04:00
|
|
|
# handle "fly.ArduCopter" etc:
|
|
|
|
if step in tester_class_map:
|
2019-05-07 20:14:23 -03:00
|
|
|
t = tester_class_map[step](binary, **fly_opts)
|
|
|
|
return (t.autotest(), t)
|
2019-02-20 19:07:53 -04:00
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
specific_test_to_run = find_specific_test_to_run(step)
|
|
|
|
if specific_test_to_run is not None:
|
2019-02-08 20:21:56 -04:00
|
|
|
return run_specific_test(specific_test_to_run, binary, **fly_opts)
|
2018-12-13 21:40:01 -04:00
|
|
|
|
2012-02-19 02:05:21 -04:00
|
|
|
if step == 'build.All':
|
|
|
|
return build_all()
|
|
|
|
|
2013-03-10 03:16:56 -03:00
|
|
|
if step == 'build.Binaries':
|
|
|
|
return build_binaries()
|
|
|
|
|
2017-08-02 08:08:28 -03:00
|
|
|
if step == 'build.examples':
|
2012-11-24 06:12:05 -04:00
|
|
|
return build_examples()
|
|
|
|
|
2017-08-02 08:08:28 -03:00
|
|
|
if step == 'run.examples':
|
|
|
|
return examples.run_examples(debug=opts.debug, valgrind=False, gdb=False)
|
|
|
|
|
2013-05-21 04:01:59 -03:00
|
|
|
if step == 'build.Parameters':
|
|
|
|
return build_parameters()
|
|
|
|
|
2011-11-09 05:27:00 -04:00
|
|
|
if step == 'convertgpx':
|
|
|
|
return convert_gpx()
|
|
|
|
|
2018-08-14 21:33:52 -03:00
|
|
|
if step == 'build.unit_tests':
|
|
|
|
return build_unit_tests()
|
|
|
|
|
|
|
|
if step == 'run.unit_tests':
|
|
|
|
return run_unit_tests()
|
|
|
|
|
2011-11-09 01:15:53 -04:00
|
|
|
raise RuntimeError("Unknown step %s" % step)
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
class TestResult(object):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Test result class."""
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self, name, result, elapsed):
|
|
|
|
self.name = name
|
|
|
|
self.result = result
|
|
|
|
self.elapsed = "%.1f" % elapsed
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
class TestFile(object):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Test result file."""
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self, name, fname):
|
|
|
|
self.name = name
|
|
|
|
self.fname = fname
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
class TestResults(object):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Test results class."""
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self):
|
|
|
|
self.date = time.asctime()
|
2018-07-03 21:51:22 -03:00
|
|
|
self.githash = util.run_cmd('git rev-parse HEAD',
|
|
|
|
output=True,
|
|
|
|
directory=util.reltopdir('.')).strip()
|
2011-11-09 08:25:08 -04:00
|
|
|
self.tests = []
|
|
|
|
self.files = []
|
2013-05-05 23:32:42 -03:00
|
|
|
self.images = []
|
2011-11-09 08:25:08 -04:00
|
|
|
|
|
|
|
def add(self, name, result, elapsed):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Add a result."""
|
2011-11-09 08:25:08 -04:00
|
|
|
self.tests.append(TestResult(name, result, elapsed))
|
|
|
|
|
|
|
|
def addfile(self, name, fname):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Add a result file."""
|
2011-11-09 08:25:08 -04:00
|
|
|
self.files.append(TestFile(name, fname))
|
|
|
|
|
2013-05-05 23:32:42 -03:00
|
|
|
def addimage(self, name, fname):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Add a result image."""
|
2013-05-05 23:32:42 -03:00
|
|
|
self.images.append(TestFile(name, fname))
|
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
def addglob(self, name, pattern):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Add a set of files."""
|
2017-08-30 03:18:32 -03:00
|
|
|
for f in glob.glob(buildlogs_path(pattern)):
|
2011-11-09 08:25:08 -04:00
|
|
|
self.addfile(name, os.path.basename(f))
|
|
|
|
|
2013-05-05 23:32:42 -03:00
|
|
|
def addglobimage(self, name, pattern):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Add a set of images."""
|
2017-08-30 03:18:32 -03:00
|
|
|
for f in glob.glob(buildlogs_path(pattern)):
|
2013-05-05 23:32:42 -03:00
|
|
|
self.addimage(name, os.path.basename(f))
|
|
|
|
|
2019-02-07 12:11:45 -04:00
|
|
|
def generate_badge(self):
|
|
|
|
"""
|
|
|
|
Gets the badge template, populates and saves the result to buildlogs
|
|
|
|
path.
|
|
|
|
"""
|
|
|
|
passed_tests = len([t for t in self.tests if "PASSED" in t.result])
|
|
|
|
total_tests = len(self.tests)
|
|
|
|
badge_color = "#4c1" if passed_tests == total_tests else "#e05d44"
|
|
|
|
|
|
|
|
badge_text = "{0}/{1}".format(passed_tests, total_tests)
|
|
|
|
# Text length so it is not stretched by svg
|
|
|
|
text_length = len(badge_text) * 70
|
|
|
|
|
|
|
|
# Load template file
|
|
|
|
template_path = 'Tools/autotest/web/autotest-badge-template.svg'
|
|
|
|
with open(util.reltopdir(template_path), "r") as f:
|
|
|
|
template = f.read()
|
|
|
|
|
|
|
|
# Add our results to the template
|
|
|
|
badge = template.format(color=badge_color,
|
|
|
|
text=badge_text,
|
|
|
|
text_length=text_length)
|
|
|
|
with open(buildlogs_path("autotest-badge.svg"), "w") as f:
|
|
|
|
f.write(badge)
|
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
def write_webresults(results_to_write):
|
|
|
|
"""Write webpage results."""
|
2011-11-09 08:25:08 -04:00
|
|
|
t = mavtemplate.MAVTemplate()
|
2011-11-09 09:23:46 -04:00
|
|
|
for h in glob.glob(util.reltopdir('Tools/autotest/web/*.html')):
|
|
|
|
html = util.loadfile(h)
|
2017-08-30 03:18:32 -03:00
|
|
|
f = open(buildlogs_path(os.path.basename(h)), mode='w')
|
2016-07-31 07:22:06 -03:00
|
|
|
t.write(f, html, results_to_write)
|
2011-11-09 09:23:46 -04:00
|
|
|
f.close()
|
2011-11-09 09:31:50 -04:00
|
|
|
for f in glob.glob(util.reltopdir('Tools/autotest/web/*.png')):
|
2017-08-30 03:18:32 -03:00
|
|
|
shutil.copy(f, buildlogs_path(os.path.basename(f)))
|
2019-02-07 12:11:45 -04:00
|
|
|
results_to_write.generate_badge()
|
2011-11-09 08:25:08 -04:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-07-08 19:48:17 -03:00
|
|
|
def write_fullresults():
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Write out full results set."""
|
2013-07-08 19:48:17 -03:00
|
|
|
global results
|
|
|
|
results.addglob("Google Earth track", '*.kmz')
|
|
|
|
results.addfile('Full Logs', 'autotest-output.txt')
|
2013-12-28 06:47:12 -04:00
|
|
|
results.addglob('DataFlash Log', '*-log.bin')
|
2013-07-08 19:48:17 -03:00
|
|
|
results.addglob("MAVLink log", '*.tlog')
|
|
|
|
results.addglob("GPX track", '*.gpx')
|
2016-03-19 01:07:18 -03:00
|
|
|
|
|
|
|
# results common to all vehicles:
|
2018-07-03 21:51:22 -03:00
|
|
|
vehicle_files = [('{vehicle} build log', '{vehicle}.txt'),
|
|
|
|
('{vehicle} code size', '{vehicle}.sizes.txt'),
|
|
|
|
('{vehicle} stack sizes', '{vehicle}.framesizes.txt'),
|
|
|
|
('{vehicle} defaults', '{vehicle}-defaults.parm'),
|
|
|
|
('{vehicle} core', '{vehicle}.core'),
|
|
|
|
('{vehicle} ELF', '{vehicle}.elf'), ]
|
|
|
|
vehicle_globs = [('{vehicle} log', '{vehicle}-*.BIN'), ]
|
|
|
|
for vehicle in all_vehicles():
|
|
|
|
subs = {'vehicle': vehicle}
|
2016-03-19 01:07:18 -03:00
|
|
|
for vehicle_file in vehicle_files:
|
|
|
|
description = vehicle_file[0].format(**subs)
|
|
|
|
filename = vehicle_file[1].format(**subs)
|
|
|
|
results.addfile(description, filename)
|
|
|
|
for vehicle_glob in vehicle_globs:
|
|
|
|
description = vehicle_glob[0].format(**subs)
|
|
|
|
glob = vehicle_glob[1].format(**subs)
|
|
|
|
results.addglob(description, glob)
|
|
|
|
|
2014-11-13 01:31:26 -04:00
|
|
|
results.addglob("CopterAVC log", 'CopterAVC-*.BIN')
|
2016-03-19 01:07:18 -03:00
|
|
|
results.addfile("CopterAVC core", 'CopterAVC.core')
|
|
|
|
|
2013-08-14 20:08:08 -03:00
|
|
|
results.addglob('APM:Libraries documentation', 'docs/libraries/index.html')
|
|
|
|
results.addglob('APM:Plane documentation', 'docs/ArduPlane/index.html')
|
|
|
|
results.addglob('APM:Copter documentation', 'docs/ArduCopter/index.html')
|
|
|
|
results.addglob('APM:Rover documentation', 'docs/APMrover2/index.html')
|
2017-02-24 19:22:38 -04:00
|
|
|
results.addglob('APM:Sub documentation', 'docs/ArduSub/index.html')
|
2013-07-08 19:48:17 -03:00
|
|
|
results.addglobimage("Flight Track", '*.png')
|
|
|
|
|
|
|
|
write_webresults(results)
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2014-11-13 01:31:26 -04:00
|
|
|
def check_logs(step):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Check for log files from a step."""
|
2014-11-13 01:31:26 -04:00
|
|
|
print("check step: ", step)
|
|
|
|
if step.startswith('fly.'):
|
|
|
|
vehicle = step[4:]
|
|
|
|
elif step.startswith('drive.'):
|
|
|
|
vehicle = step[6:]
|
2018-11-04 17:39:01 -04:00
|
|
|
elif step.startswith('dive.'):
|
|
|
|
vehicle = step[5:]
|
2014-11-13 01:31:26 -04:00
|
|
|
else:
|
|
|
|
return
|
2014-11-13 06:52:48 -04:00
|
|
|
logs = glob.glob("logs/*.BIN")
|
2014-11-13 01:31:26 -04:00
|
|
|
for log in logs:
|
|
|
|
bname = os.path.basename(log)
|
2017-08-30 03:18:32 -03:00
|
|
|
newname = buildlogs_path("%s-%s" % (vehicle, bname))
|
2014-11-13 01:31:26 -04:00
|
|
|
print("Renaming %s to %s" % (log, newname))
|
2017-08-30 03:18:32 -03:00
|
|
|
shutil.move(log, newname)
|
2014-11-13 01:31:26 -04:00
|
|
|
|
2014-11-13 06:52:48 -04:00
|
|
|
corefile = "core"
|
2014-11-13 02:27:02 -04:00
|
|
|
if os.path.exists(corefile):
|
2017-08-30 03:18:32 -03:00
|
|
|
newname = buildlogs_path("%s.core" % vehicle)
|
2014-11-13 02:27:02 -04:00
|
|
|
print("Renaming %s to %s" % (corefile, newname))
|
2017-08-30 03:18:32 -03:00
|
|
|
shutil.move(corefile, newname)
|
2017-12-11 17:45:56 -04:00
|
|
|
try:
|
|
|
|
util.run_cmd('/bin/cp build/sitl/bin/* %s' % buildlogs_dirpath(),
|
|
|
|
directory=util.reltopdir('.'))
|
|
|
|
except Exception:
|
|
|
|
print("Unable to save binary")
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2011-11-09 00:45:18 -04:00
|
|
|
def run_tests(steps):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Run a list of steps."""
|
2012-06-15 03:52:55 -03:00
|
|
|
global results
|
2011-11-09 08:25:08 -04:00
|
|
|
|
2011-11-09 01:15:53 -04:00
|
|
|
passed = True
|
2011-11-09 02:16:20 -04:00
|
|
|
failed = []
|
2019-05-07 20:14:23 -03:00
|
|
|
failed_testinstances = dict()
|
2011-11-09 00:45:18 -04:00
|
|
|
for step in steps:
|
2011-12-02 00:21:15 -04:00
|
|
|
util.pexpect_close_all()
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
t1 = time.time()
|
2011-11-09 01:15:53 -04:00
|
|
|
print(">>>> RUNNING STEP: %s at %s" % (step, time.asctime()))
|
|
|
|
try:
|
2019-05-07 20:14:23 -03:00
|
|
|
success = run_step(step)
|
|
|
|
testinstance = None
|
|
|
|
if type(success) == tuple:
|
|
|
|
(success, testinstance) = success
|
|
|
|
if success:
|
2018-07-03 21:51:22 -03:00
|
|
|
results.add(step, '<span class="passed-text">PASSED</span>',
|
|
|
|
time.time() - t1)
|
2017-08-09 05:25:04 -03:00
|
|
|
print(">>>> PASSED STEP: %s at %s" % (step, time.asctime()))
|
|
|
|
check_logs(step)
|
|
|
|
else:
|
2011-11-09 01:15:53 -04:00
|
|
|
print(">>>> FAILED STEP: %s at %s" % (step, time.asctime()))
|
|
|
|
passed = False
|
2011-11-09 02:16:20 -04:00
|
|
|
failed.append(step)
|
2019-05-07 20:14:23 -03:00
|
|
|
if testinstance is not None:
|
|
|
|
if failed_testinstances.get(step) is None:
|
|
|
|
failed_testinstances[step] = []
|
|
|
|
failed_testinstances[step].append(testinstance)
|
2018-07-03 21:51:22 -03:00
|
|
|
results.add(step, '<span class="failed-text">FAILED</span>',
|
|
|
|
time.time() - t1)
|
2016-07-31 07:22:06 -03:00
|
|
|
except Exception as msg:
|
2011-11-09 01:15:53 -04:00
|
|
|
passed = False
|
2011-11-09 02:16:20 -04:00
|
|
|
failed.append(step)
|
2018-07-03 21:51:22 -03:00
|
|
|
print(">>>> FAILED STEP: %s at %s (%s)" %
|
|
|
|
(step, time.asctime(), msg))
|
2011-11-09 08:43:25 -04:00
|
|
|
traceback.print_exc(file=sys.stdout)
|
2018-07-03 21:51:22 -03:00
|
|
|
results.add(step,
|
|
|
|
'<span class="failed-text">FAILED</span>',
|
|
|
|
time.time() - t1)
|
2014-11-13 01:31:26 -04:00
|
|
|
check_logs(step)
|
2011-11-09 02:16:20 -04:00
|
|
|
if not passed:
|
2019-05-07 20:14:23 -03:00
|
|
|
keys = failed_testinstances.keys()
|
|
|
|
if len(keys):
|
|
|
|
print("Failure Summary:")
|
|
|
|
for key in keys:
|
|
|
|
print(" %s:" % key)
|
|
|
|
for testinstance in failed_testinstances[key]:
|
|
|
|
for failure in testinstance.fail_list:
|
|
|
|
(desc, exception, debug_filename) = failure
|
|
|
|
print(" %s (%s) (see %s)" % (desc, exception, debug_filename))
|
|
|
|
|
2011-11-09 02:16:20 -04:00
|
|
|
print("FAILED %u tests: %s" % (len(failed), failed))
|
2011-11-09 08:25:08 -04:00
|
|
|
|
2011-12-02 00:21:15 -04:00
|
|
|
util.pexpect_close_all()
|
|
|
|
|
2013-07-08 19:48:17 -03:00
|
|
|
write_fullresults()
|
2011-11-09 08:25:08 -04:00
|
|
|
|
2011-11-09 01:15:53 -04:00
|
|
|
return passed
|
2011-11-09 00:45:18 -04:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
if __name__ == "__main__":
|
2018-07-03 21:51:22 -03:00
|
|
|
''' main program '''
|
2017-08-09 05:14:45 -03:00
|
|
|
os.environ['PYTHONUNBUFFERED'] = '1'
|
2011-11-09 08:53:09 -04:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
os.putenv('TMPDIR', util.reltopdir('tmp'))
|
2013-04-14 04:16:30 -03:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
parser = optparse.OptionParser("autotest")
|
2018-07-03 21:51:22 -03:00
|
|
|
parser.add_option("--skip",
|
|
|
|
type='string',
|
|
|
|
default='',
|
|
|
|
help='list of steps to skip (comma separated)')
|
|
|
|
parser.add_option("--list",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='list the available steps')
|
|
|
|
parser.add_option("--viewerip",
|
|
|
|
default=None,
|
|
|
|
help='IP address to send MAVLink and fg packets to')
|
|
|
|
parser.add_option("--map",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='show map')
|
|
|
|
parser.add_option("--experimental",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='enable experimental tests')
|
|
|
|
parser.add_option("--timeout",
|
2019-02-13 20:38:29 -04:00
|
|
|
default=3600,
|
2018-07-03 21:51:22 -03:00
|
|
|
type='int',
|
|
|
|
help='maximum runtime in seconds')
|
|
|
|
parser.add_option("--frame",
|
|
|
|
type='string',
|
|
|
|
default=None,
|
|
|
|
help='specify frame type')
|
2018-08-03 22:15:44 -03:00
|
|
|
parser.add_option("--show-test-timings",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="show how long each test took to run")
|
2018-05-10 22:31:29 -03:00
|
|
|
|
|
|
|
group_build = optparse.OptionGroup(parser, "Build options")
|
2018-07-03 21:51:22 -03:00
|
|
|
group_build.add_option("--no-configure",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='do not configure before building',
|
|
|
|
dest="no_configure")
|
2018-09-30 20:04:57 -03:00
|
|
|
group_build.add_option("", "--waf-configure-args",
|
|
|
|
action="append",
|
|
|
|
dest="waf_configure_args",
|
|
|
|
type="string",
|
|
|
|
default=[],
|
|
|
|
help="extra arguments passed to waf in configure")
|
2018-05-10 22:31:29 -03:00
|
|
|
group_build.add_option("-j", default=None, type='int', help='build CPUs')
|
|
|
|
group_build.add_option("--no-clean",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='do not clean before building',
|
|
|
|
dest="no_clean")
|
|
|
|
group_build.add_option("--debug",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='make built binaries debug binaries')
|
|
|
|
parser.add_option_group(group_build)
|
|
|
|
|
|
|
|
group_sim = optparse.OptionGroup(parser, "Simulation options")
|
|
|
|
group_sim.add_option("--speedup",
|
|
|
|
default=None,
|
|
|
|
type='int',
|
|
|
|
help='speedup to run the simulations at')
|
|
|
|
group_sim.add_option("--valgrind",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='run ArduPilot binaries under valgrind')
|
|
|
|
group_sim.add_option("--gdb",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='run ArduPilot binaries under gdb')
|
|
|
|
group_sim.add_option("--gdbserver",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='run ArduPilot binaries under gdbserver')
|
2019-09-24 14:44:02 -03:00
|
|
|
group_sim.add_option("--lldb",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='run ArduPilot binaries under lldb')
|
2018-07-23 04:06:00 -03:00
|
|
|
group_sim.add_option("-B", "--breakpoint",
|
|
|
|
type='string',
|
|
|
|
action="append",
|
|
|
|
default=[],
|
|
|
|
help="add a breakpoint at given location in debugger")
|
2019-07-11 21:58:46 -03:00
|
|
|
group_sim.add_option("--disable-breakpoints",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help="disable all breakpoints before starting")
|
2018-05-10 22:31:29 -03:00
|
|
|
parser.add_option_group(group_sim)
|
2011-11-09 08:53:09 -04:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
opts, args = parser.parse_args()
|
2011-12-02 00:21:15 -04:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
steps = [
|
2018-07-03 21:51:22 -03:00
|
|
|
'prerequisites',
|
|
|
|
'build.Binaries',
|
2019-06-03 04:57:21 -03:00
|
|
|
'build.All',
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.Parameters',
|
2012-11-29 03:09:44 -04:00
|
|
|
|
2018-08-14 21:33:52 -03:00
|
|
|
'build.unit_tests',
|
|
|
|
'run.unit_tests',
|
2017-08-02 08:08:28 -03:00
|
|
|
'build.examples',
|
|
|
|
'run.examples',
|
2018-08-14 21:33:52 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.ArduPlane',
|
|
|
|
'defaults.ArduPlane',
|
|
|
|
'fly.ArduPlane',
|
|
|
|
'fly.QuadPlane',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.APMrover2',
|
|
|
|
'defaults.APMrover2',
|
|
|
|
'drive.APMrover2',
|
2018-07-20 08:53:31 -03:00
|
|
|
'drive.balancebot',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.ArduCopter',
|
|
|
|
'defaults.ArduCopter',
|
|
|
|
'fly.ArduCopter',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.Helicopter',
|
|
|
|
'fly.CopterAVC',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.AntennaTracker',
|
2019-02-20 19:07:53 -04:00
|
|
|
'defaults.AntennaTracker',
|
|
|
|
'test.AntennaTracker',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.ArduSub',
|
|
|
|
'defaults.ArduSub',
|
|
|
|
'dive.ArduSub',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'convertgpx',
|
2017-08-09 05:14:45 -03:00
|
|
|
]
|
|
|
|
|
|
|
|
skipsteps = opts.skip.split(',')
|
|
|
|
|
|
|
|
# ensure we catch timeouts
|
|
|
|
signal.signal(signal.SIGALRM, alarm_handler)
|
|
|
|
signal.alarm(opts.timeout)
|
|
|
|
|
|
|
|
if opts.list:
|
|
|
|
for step in steps:
|
|
|
|
print(step)
|
|
|
|
sys.exit(0)
|
|
|
|
|
2017-08-30 03:18:32 -03:00
|
|
|
util.mkdir_p(buildlogs_dirpath())
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2017-08-30 03:18:32 -03:00
|
|
|
lckfile = buildlogs_path('autotest.lck')
|
|
|
|
print("lckfile=%s" % repr(lckfile))
|
2017-08-09 05:14:45 -03:00
|
|
|
lck = util.lock_file(lckfile)
|
|
|
|
|
|
|
|
if lck is None:
|
|
|
|
print("autotest is locked - exiting. lckfile=(%s)" % (lckfile,))
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
atexit.register(util.pexpect_close_all)
|
|
|
|
|
|
|
|
if len(args) > 0:
|
|
|
|
# allow a wildcard list of steps
|
|
|
|
matched = []
|
|
|
|
for a in args:
|
2018-07-03 21:51:22 -03:00
|
|
|
matches = [step for step in steps
|
|
|
|
if fnmatch.fnmatch(step.lower(), a.lower())]
|
2018-12-13 21:40:01 -04:00
|
|
|
x = find_specific_test_to_run(a)
|
|
|
|
if x is not None:
|
|
|
|
matches.append(x)
|
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
if not len(matches):
|
|
|
|
print("No steps matched {}".format(a))
|
2017-09-08 08:51:26 -03:00
|
|
|
sys.exit(1)
|
2017-08-09 05:14:45 -03:00
|
|
|
matched.extend(matches)
|
|
|
|
steps = matched
|
|
|
|
|
2017-08-09 05:25:04 -03:00
|
|
|
# skip steps according to --skip option:
|
2018-07-03 21:51:22 -03:00
|
|
|
steps_to_run = [s for s in steps if should_run_step(s)]
|
2017-08-09 05:25:04 -03:00
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
results = TestResults()
|
|
|
|
|
|
|
|
try:
|
2017-09-08 08:51:26 -03:00
|
|
|
if not run_tests(steps_to_run):
|
2017-08-09 05:14:45 -03:00
|
|
|
sys.exit(1)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
util.pexpect_close_all()
|
2011-11-09 01:15:53 -04:00
|
|
|
sys.exit(1)
|
2017-08-09 05:14:45 -03:00
|
|
|
except Exception:
|
2018-07-03 21:51:22 -03:00
|
|
|
# make sure we kill off any children
|
2017-08-09 05:14:45 -03:00
|
|
|
util.pexpect_close_all()
|
|
|
|
raise
|