2023-04-21 02:27:49 -03:00
|
|
|
#!/usr/bin/env python3
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
2021-09-17 23:46:53 -03:00
|
|
|
ArduPilot automatic test suite.
|
2021-06-12 17:54:17 -03:00
|
|
|
|
|
|
|
Andrew Tridgell, October 2011
|
2021-02-10 19:35:25 -04:00
|
|
|
|
|
|
|
AP_FLAKE8_CLEAN
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
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
|
2022-06-26 21:40:06 -03:00
|
|
|
import copy
|
2016-07-31 07:22:06 -03:00
|
|
|
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
|
|
|
|
|
2023-08-04 05:32:39 -03:00
|
|
|
import blimp
|
2020-04-14 20:37:23 -03:00
|
|
|
import rover
|
2018-07-03 21:51:22 -03:00
|
|
|
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
|
2021-04-10 22:28:49 -03:00
|
|
|
import sailboat
|
2021-09-26 21:24:57 -03:00
|
|
|
import helicopter
|
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.generator import mavtemplate
|
2011-12-02 00:21:15 -04:00
|
|
|
|
2022-02-23 08:07:15 -04:00
|
|
|
from vehicle_test_suite import Test
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2020-12-28 21:30:53 -04:00
|
|
|
tester = None
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2022-06-26 21:40:06 -03:00
|
|
|
build_opts = None
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2017-08-30 03:18:32 -03:00
|
|
|
def buildlogs_dirpath():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Return BUILDLOGS directory path."""
|
2017-08-30 03:18:32 -03:00
|
|
|
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):
|
2021-06-12 17:54:17 -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
|
|
|
|
|
|
|
def build_all_filepath():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get build_all.sh path."""
|
2018-07-03 21:51:22 -03:00
|
|
|
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")
|
2020-03-06 22:41:41 -04:00
|
|
|
|
|
|
|
# copy the script (and various libraries used by the script) as it
|
|
|
|
# changes git branch, which can change the script while running
|
2022-01-11 18:06:47 -04:00
|
|
|
for thing in [
|
|
|
|
"board_list.py",
|
|
|
|
"build_binaries_history.py",
|
|
|
|
"build_binaries.py",
|
2022-01-11 18:13:31 -04:00
|
|
|
"build_sizes/build_sizes.py",
|
2022-01-11 18:06:47 -04:00
|
|
|
"generate_manifest.py",
|
|
|
|
"gen_stable.py",
|
|
|
|
]:
|
2020-03-06 22:41:41 -04:00
|
|
|
orig = util.reltopdir('Tools/scripts/%s' % thing)
|
2022-01-11 18:13:31 -04:00
|
|
|
copy = util.reltopdir('./%s' % os.path.basename(thing))
|
2020-03-06 22:41:41 -04:00
|
|
|
shutil.copy2(orig, copy)
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2020-03-06 22:41:41 -04:00
|
|
|
if util.run_cmd("./build_binaries.py", 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
|
|
|
|
2021-05-20 11:27:59 -03:00
|
|
|
def build_examples(**kwargs):
|
2016-07-31 07:22:06 -03:00
|
|
|
"""Build examples."""
|
2023-10-09 07:04:00 -03:00
|
|
|
for target in 'Pixhawk1', 'navio', 'linux':
|
2016-06-01 07:17:13 -03:00
|
|
|
print("Running build.examples for %s" % target)
|
|
|
|
try:
|
2021-05-20 11:27:59 -03:00
|
|
|
util.build_examples(target, **kwargs)
|
2016-06-01 07:17:13 -03:00
|
|
|
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
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2021-05-20 11:27:59 -03:00
|
|
|
def build_unit_tests(**kwargs):
|
2018-08-14 21:33:52 -03:00
|
|
|
"""Build tests."""
|
2021-08-19 19:44:17 -03:00
|
|
|
for target in ['linux', 'sitl']:
|
2018-08-14 21:33:52 -03:00
|
|
|
print("Running build.unit_tests for %s" % target)
|
|
|
|
try:
|
2021-05-20 11:27:59 -03:00
|
|
|
util.build_tests(target, **kwargs)
|
2018-08-14 21:33:52 -03:00
|
|
|
except Exception as e:
|
|
|
|
print("Failed build.unit_tests on board=%s" % target)
|
|
|
|
print(str(e))
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2018-08-14 21:33:52 -03:00
|
|
|
def run_unit_test(test):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Run unit test file."""
|
2018-08-14 21:33:52 -03:00
|
|
|
print("Running (%s)" % test)
|
2021-06-22 05:16:27 -03:00
|
|
|
subprocess.check_call([test])
|
2018-08-14 21:33:52 -03:00
|
|
|
|
|
|
|
|
|
|
|
def run_unit_tests():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Run all unit tests files."""
|
2018-08-14 21:33:52 -03:00
|
|
|
success = True
|
2021-06-12 17:53:52 -03:00
|
|
|
fail_list = []
|
2021-08-19 19:44:17 -03:00
|
|
|
for target in ['linux', 'sitl']:
|
|
|
|
binary_dir = util.reltopdir(os.path.join('build',
|
|
|
|
target,
|
|
|
|
'tests',
|
|
|
|
))
|
|
|
|
tests = glob.glob("%s/*" % binary_dir)
|
|
|
|
for test in tests:
|
|
|
|
try:
|
|
|
|
run_unit_test(test)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
print("Exception running (%s)" % test)
|
|
|
|
fail_list.append(target + '/' + os.path.basename(test))
|
|
|
|
success = False
|
|
|
|
|
2021-06-12 17:53:52 -03:00
|
|
|
print("Failing tests:")
|
|
|
|
for failure in fail_list:
|
|
|
|
print(" %s" % failure)
|
2018-08-14 21:33:52 -03:00
|
|
|
return success
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2020-03-27 20:39:38 -03:00
|
|
|
def run_clang_scan_build():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Run Clang Scan-build utility."""
|
2020-03-27 20:39:38 -03:00
|
|
|
if util.run_cmd("scan-build python waf configure",
|
|
|
|
directory=util.reltopdir('.')) != 0:
|
|
|
|
print("Failed scan-build-configure")
|
|
|
|
return False
|
|
|
|
|
|
|
|
if util.run_cmd("scan-build python waf clean",
|
|
|
|
directory=util.reltopdir('.')) != 0:
|
|
|
|
print("Failed scan-build-clean")
|
|
|
|
return False
|
|
|
|
|
|
|
|
if util.run_cmd("scan-build python waf build",
|
|
|
|
directory=util.reltopdir('.')) != 0:
|
|
|
|
print("Failed scan-build-build")
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
def param_parse_filepath():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get param_parse.py script path."""
|
2018-07-03 21:51:22 -03:00
|
|
|
return util.reltopdir('Tools/autotest/param_metadata/param_parse.py')
|
|
|
|
|
|
|
|
|
|
|
|
def all_vehicles():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get all vehicles name."""
|
2018-07-03 21:51:22 -03:00
|
|
|
return ('ArduPlane',
|
|
|
|
'ArduCopter',
|
2020-03-26 20:14:17 -03:00
|
|
|
'Rover',
|
2018-07-03 21:51:22 -03:00
|
|
|
'AntennaTracker',
|
2021-11-13 23:49:18 -04:00
|
|
|
'ArduSub',
|
2023-11-22 19:16:39 -04:00
|
|
|
'Blimp',
|
|
|
|
'AP_Periph',
|
|
|
|
)
|
2018-07-03 21:51:22 -03:00
|
|
|
|
|
|
|
|
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():
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get mavtogpx script path."""
|
2018-07-03 21:51:22 -03:00
|
|
|
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))
|
2021-02-10 19:35:25 -04:00
|
|
|
except subprocess.CalledProcessError:
|
2018-03-21 19:11:44 -03:00
|
|
|
passed = False
|
|
|
|
try:
|
|
|
|
util.run_cmd('zip %s.kmz %s.kml' % (m, m))
|
2021-02-10 19:35:25 -04:00
|
|
|
except subprocess.CalledProcessError:
|
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."""
|
2020-12-28 21:30:53 -04:00
|
|
|
global results, opts, tester
|
2012-06-15 03:52:55 -03:00
|
|
|
try:
|
2019-02-04 16:41:09 -04:00
|
|
|
print("Alarm handler called")
|
2020-12-28 21:30:53 -04:00
|
|
|
if tester is not None:
|
|
|
|
if tester.rc_thread is not None:
|
|
|
|
tester.rc_thread_should_quit = True
|
|
|
|
tester.rc_thread.join()
|
|
|
|
tester.rc_thread = None
|
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 = {
|
2020-03-25 17:47:28 -03:00
|
|
|
"Copter": "arducopter",
|
2020-10-14 02:18:10 -03:00
|
|
|
"CopterTests1a": "arducopter",
|
|
|
|
"CopterTests1b": "arducopter",
|
|
|
|
"CopterTests1c": "arducopter",
|
|
|
|
"CopterTests1d": "arducopter",
|
|
|
|
"CopterTests1e": "arducopter",
|
|
|
|
|
|
|
|
"CopterTests2a": "arducopter",
|
|
|
|
"CopterTests2b": "arducopter",
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
"Plane": "arduplane",
|
|
|
|
"Rover": "ardurover",
|
|
|
|
"Tracker": "antennatracker",
|
|
|
|
"Helicopter": "arducopter-heli",
|
2018-07-03 21:51:22 -03:00
|
|
|
"QuadPlane": "arduplane",
|
2020-03-25 17:47:28 -03:00
|
|
|
"Sub": "ardusub",
|
2021-11-13 23:49:18 -04:00
|
|
|
"Blimp": "blimp",
|
2018-12-15 03:43:20 -04:00
|
|
|
"BalanceBot": "ardurover",
|
2021-04-10 22:28:49 -03:00
|
|
|
"Sailboat": "ardurover",
|
2024-01-24 02:31:15 -04:00
|
|
|
"SITLPeriphUniversal": ("sitl_periph_universal", "AP_Periph"),
|
2021-02-10 19:35:25 -04:00
|
|
|
"CAN": "arducopter",
|
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):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get vehicle binary path."""
|
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
|
|
|
|
2024-01-24 02:31:15 -04:00
|
|
|
if vehicle not in __bin_names:
|
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
|
|
|
|
2024-01-24 02:31:15 -04:00
|
|
|
try:
|
|
|
|
(config_name, binary_name) = __bin_names[vehicle]
|
|
|
|
except ValueError:
|
|
|
|
config_name = "sitl"
|
|
|
|
binary_name = __bin_names[vehicle]
|
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
binary = util.reltopdir(os.path.join('build',
|
2020-09-29 15:54:02 -03:00
|
|
|
config_name,
|
2018-07-03 21:51:22 -03:00
|
|
|
'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
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
def split_specific_test_step(step):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Extract test from argument."""
|
2018-12-13 21:40:01 -04:00
|
|
|
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
|
2021-02-10 19:35:25 -04:00
|
|
|
return ((m.group(1), m.group(3)))
|
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
|
|
|
|
def find_specific_test_to_run(step):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Find test to run in argument."""
|
2018-12-13 21:40:01 -04:00
|
|
|
t = split_specific_test_step(step)
|
|
|
|
if t is None:
|
|
|
|
return None
|
|
|
|
(testname, test) = t
|
|
|
|
return "%s.%s" % (testname, test)
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2019-03-08 21:28:27 -04:00
|
|
|
tester_class_map = {
|
2023-08-04 05:32:39 -03:00
|
|
|
"test.Blimp": blimp.AutoTestBlimp,
|
2020-03-25 17:47:28 -03:00
|
|
|
"test.Copter": arducopter.AutoTestCopter,
|
2020-10-14 02:18:10 -03:00
|
|
|
"test.CopterTests1a": arducopter.AutoTestCopterTests1a, # 8m43s
|
2021-02-10 19:35:25 -04:00
|
|
|
"test.CopterTests1b": arducopter.AutoTestCopterTests1b, # 8m5s
|
|
|
|
"test.CopterTests1c": arducopter.AutoTestCopterTests1c, # 5m17s
|
2020-10-14 02:18:10 -03:00
|
|
|
"test.CopterTests1d": arducopter.AutoTestCopterTests1d, # 8m20s
|
|
|
|
"test.CopterTests1e": arducopter.AutoTestCopterTests1e, # 8m32s
|
|
|
|
"test.CopterTests2a": arducopter.AutoTestCopterTests2a, # 8m23s
|
|
|
|
"test.CopterTests2b": arducopter.AutoTestCopterTests2b, # 8m18s
|
2020-03-25 17:47:28 -03:00
|
|
|
"test.Plane": arduplane.AutoTestPlane,
|
|
|
|
"test.QuadPlane": quadplane.AutoTestQuadPlane,
|
2020-04-14 20:37:23 -03:00
|
|
|
"test.Rover": rover.AutoTestRover,
|
2020-03-25 17:47:28 -03:00
|
|
|
"test.BalanceBot": balancebot.AutoTestBalanceBot,
|
2021-04-10 22:28:49 -03:00
|
|
|
"test.Sailboat": sailboat.AutoTestSailboat,
|
2021-09-26 21:24:57 -03:00
|
|
|
"test.Helicopter": helicopter.AutoTestHelicopter,
|
2020-03-25 17:47:28 -03:00
|
|
|
"test.Sub": ardusub.AutoTestSub,
|
|
|
|
"test.Tracker": antennatracker.AutoTestTracker,
|
2020-09-29 15:54:02 -03:00
|
|
|
"test.CAN": arducopter.AutoTestCAN,
|
|
|
|
}
|
|
|
|
|
2023-07-17 05:45:54 -03:00
|
|
|
supplementary_test_binary_map = {
|
2024-01-11 22:50:43 -04:00
|
|
|
"test.CAN": ["sitl_periph_universal:AP_Periph:0:Tools/autotest/default_params/periph.parm,Tools/autotest/default_params/quad-periph.parm", # noqa: E501
|
|
|
|
"sitl_periph_universal:AP_Periph:1:Tools/autotest/default_params/periph.parm"],
|
2019-03-08 21:28:27 -04:00
|
|
|
}
|
|
|
|
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2018-12-13 21:40:01 -04:00
|
|
|
def run_specific_test(step, *args, **kwargs):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Run a specific test."""
|
2018-12-13 21:40:01 -04:00
|
|
|
t = split_specific_test_step(step)
|
|
|
|
if t is None:
|
|
|
|
return []
|
|
|
|
(testname, test) = t
|
|
|
|
|
|
|
|
tester_class = tester_class_map[testname]
|
2020-12-28 21:30:53 -04:00
|
|
|
global tester
|
2018-12-13 21:40:01 -04:00
|
|
|
tester = tester_class(*args, **kwargs)
|
|
|
|
|
2023-03-08 21:38:10 -04:00
|
|
|
# print("Got %s" % str(tester))
|
2018-12-13 21:40:01 -04:00
|
|
|
for a in tester.tests():
|
2023-08-31 18:45:12 -03:00
|
|
|
if not isinstance(a, Test):
|
2022-09-11 01:32:17 -03:00
|
|
|
a = Test(a)
|
2021-01-21 07:09:34 -04:00
|
|
|
print("Got %s" % (a.name))
|
|
|
|
if a.name == test:
|
2023-10-10 09:30:46 -03:00
|
|
|
return tester.autotest(tests=[a], allow_skips=False, step_name=step), tester
|
2018-12-13 21:40:01 -04:00
|
|
|
print("Failed to find test %s on %s" % (test, testname))
|
|
|
|
sys.exit(1)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2021-02-10 19:35:25 -04: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,
|
2020-04-27 22:37:33 -03:00
|
|
|
"math_check_indexes": opts.math_check_indexes,
|
2021-07-08 19:47:07 -03:00
|
|
|
"ekf_single": opts.ekf_single,
|
|
|
|
"postype_single": opts.postype_single,
|
2018-09-30 20:04:57 -03:00
|
|
|
"extra_configure_args": opts.waf_configure_args,
|
2021-05-24 10:48:42 -03:00
|
|
|
"coverage": opts.coverage,
|
2023-01-08 18:56:33 -04:00
|
|
|
"force_32bit" : opts.force_32bit,
|
2022-07-10 20:16:55 -03:00
|
|
|
"ubsan" : opts.ubsan,
|
|
|
|
"ubsan_abort" : opts.ubsan_abort,
|
2023-03-03 19:53:50 -04:00
|
|
|
"num_aux_imus" : opts.num_aux_imus,
|
2023-01-22 03:32:44 -04:00
|
|
|
"dronecan_tests" : opts.dronecan_tests,
|
2017-09-08 01:17:22 -03:00
|
|
|
}
|
2018-05-10 22:31:29 -03:00
|
|
|
|
2020-09-07 05:29:44 -03:00
|
|
|
if opts.Werror:
|
|
|
|
build_opts['extra_configure_args'].append("--Werror")
|
|
|
|
|
2022-06-26 21:40:06 -03:00
|
|
|
build_opts = build_opts
|
|
|
|
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = None
|
2024-01-24 02:31:15 -04:00
|
|
|
board = "sitl"
|
2020-03-25 17:47:28 -03:00
|
|
|
if step == 'build.Plane':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/arduplane'
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
if step == 'build.Rover':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/ardurover'
|
2012-11-27 19:43:11 -04:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
if step == 'build.Copter':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/arducopter'
|
2011-11-09 01:15:53 -04:00
|
|
|
|
2021-11-13 23:49:18 -04:00
|
|
|
if step == 'build.Blimp':
|
|
|
|
vehicle_binary = 'bin/blimp'
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
if step == 'build.Tracker':
|
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'
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
if step == 'build.Sub':
|
2018-05-10 22:31:29 -03:00
|
|
|
vehicle_binary = 'bin/ardusub'
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2024-01-11 22:50:43 -04:00
|
|
|
if step == 'build.SITLPeriphUniversal':
|
2024-01-24 02:31:15 -04:00
|
|
|
vehicle_binary = 'bin/AP_Periph'
|
|
|
|
board = 'sitl_periph_universal'
|
2018-05-10 22:31:29 -03:00
|
|
|
|
2020-11-08 06:29:20 -04:00
|
|
|
if step == 'build.Replay':
|
2021-04-05 00:59:42 -03:00
|
|
|
return util.build_replay(board='SITL')
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2018-05-10 22:31:29 -03:00
|
|
|
if vehicle_binary is not None:
|
2023-07-06 03:00:47 -03:00
|
|
|
try:
|
|
|
|
binary = binary_path(step, debug=opts.debug)
|
|
|
|
os.unlink(binary)
|
|
|
|
except (FileNotFoundError, ValueError):
|
|
|
|
pass
|
2024-01-24 02:31:15 -04:00
|
|
|
return util.build_SITL(
|
|
|
|
vehicle_binary,
|
|
|
|
board=board,
|
|
|
|
**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
|
|
|
|
2023-07-17 05:45:54 -03:00
|
|
|
# see if we need any supplementary binaries
|
2021-01-01 11:48:40 -04:00
|
|
|
supplementary_binaries = []
|
2023-07-17 05:45:54 -03:00
|
|
|
for k in supplementary_test_binary_map.keys():
|
|
|
|
if step.startswith(k):
|
|
|
|
# this test needs to use supplementary binaries
|
|
|
|
for supplementary_test_binary in supplementary_test_binary_map[k]:
|
2023-08-20 22:15:04 -03:00
|
|
|
a = supplementary_test_binary.split(':')
|
|
|
|
if len(a) != 4:
|
|
|
|
raise ValueError("Bad supplementary_test_binary %s" % supplementary_test_binary)
|
|
|
|
config_name = a[0]
|
|
|
|
binary_name = a[1]
|
|
|
|
instance_num = int(a[2])
|
|
|
|
param_file = a[3].split(",")
|
|
|
|
bin_path = util.reltopdir(os.path.join('build', config_name, 'bin', binary_name))
|
|
|
|
customisation = '-I {}'.format(instance_num)
|
|
|
|
sup_binary = {"binary" : bin_path,
|
|
|
|
"customisation" : customisation,
|
|
|
|
"param_file" : param_file}
|
|
|
|
supplementary_binaries.append(sup_binary)
|
2023-07-17 05:45:54 -03:00
|
|
|
# we are running in conjunction with a supplementary app
|
|
|
|
# can't have speedup
|
|
|
|
opts.speedup = 1.0
|
|
|
|
break
|
|
|
|
|
2017-08-26 01:59:36 -03:00
|
|
|
fly_opts = {
|
|
|
|
"viewerip": opts.viewerip,
|
|
|
|
"use_map": opts.map,
|
|
|
|
"valgrind": opts.valgrind,
|
2021-11-29 02:18:13 -04:00
|
|
|
"callgrind": opts.callgrind,
|
2017-08-26 01:59:36 -03:00
|
|
|
"gdb": opts.gdb,
|
2021-06-10 01:17:04 -03:00
|
|
|
"gdb_no_tui": opts.gdb_no_tui,
|
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,
|
2020-04-23 03:37:23 -03:00
|
|
|
"force_ahrs_type": opts.force_ahrs_type,
|
2023-03-03 19:53:50 -04:00
|
|
|
"num_aux_imus" : opts.num_aux_imus,
|
2021-07-16 07:31:13 -03:00
|
|
|
"replay": opts.replay,
|
2020-05-04 04:12:26 -03:00
|
|
|
"logs_dir": buildlogs_dirpath(),
|
2021-01-01 11:48:40 -04:00
|
|
|
"sup_binaries": supplementary_binaries,
|
2021-08-02 19:55:56 -03:00
|
|
|
"reset_after_every_test": opts.reset_after_every_test,
|
2022-06-26 21:40:06 -03:00
|
|
|
"build_opts": copy.copy(build_opts),
|
2023-10-10 09:30:46 -03:00
|
|
|
"generate_junit": opts.junit,
|
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
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
# handle "test.Copter" etc:
|
2019-03-08 21:28:27 -04:00
|
|
|
if step in tester_class_map:
|
2020-12-28 21:30:53 -04:00
|
|
|
# create an instance of the tester class:
|
|
|
|
global tester
|
|
|
|
tester = tester_class_map[step](binary, **fly_opts)
|
|
|
|
# run the test and return its result and the tester itself
|
2023-10-10 09:30:46 -03:00
|
|
|
return tester.autotest(None, step_name=step), tester
|
2019-02-20 19:07:53 -04:00
|
|
|
|
2020-12-28 21:30:53 -04:00
|
|
|
# handle "test.Copter.CPUFailsafe" etc:
|
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':
|
2021-05-20 11:27:59 -03:00
|
|
|
return build_examples(**build_opts)
|
2012-11-24 06:12:05 -04:00
|
|
|
|
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':
|
2021-05-20 11:27:59 -03:00
|
|
|
return build_unit_tests(**build_opts)
|
2018-08-14 21:33:52 -03:00
|
|
|
|
|
|
|
if step == 'run.unit_tests':
|
|
|
|
return run_unit_tests()
|
|
|
|
|
2020-03-27 20:39:38 -03:00
|
|
|
if step == 'clang-scan-build':
|
|
|
|
return run_clang_scan_build()
|
|
|
|
|
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."""
|
2021-06-12 17:54:17 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self, name, result, elapsed):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Init test result class."""
|
2011-11-09 08:25:08 -04:00
|
|
|
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."""
|
2021-06-12 17:54:17 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self, name, fname):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Init test result file."""
|
2011-11-09 08:25:08 -04:00
|
|
|
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."""
|
2021-06-12 17:54:17 -03:00
|
|
|
|
2011-11-09 08:25:08 -04:00
|
|
|
def __init__(self):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Init test results class."""
|
2011-11-09 08:25:08 -04:00
|
|
|
self.date = time.asctime()
|
2023-11-16 10:09:45 -04:00
|
|
|
self.githash = util.get_git_hash()
|
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):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Get the badge template, populates and saves the result to buildlogs path."""
|
2019-02-07 12:11:45 -04:00
|
|
|
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
|
|
|
|
2022-11-23 20:10:32 -04:00
|
|
|
def copy_tree(f, t, dirs_exist_ok=False):
|
2022-12-16 16:47:17 -04:00
|
|
|
shutil.copytree(f, t, dirs_exist_ok=dirs_exist_ok)
|
2022-11-23 20:10:32 -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)))
|
2022-11-23 20:10:32 -04:00
|
|
|
copy_tree(util.reltopdir("Tools/autotest/web/css"), buildlogs_path("css"), dirs_exist_ok=True)
|
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:
|
2023-08-26 03:24:58 -03:00
|
|
|
vehicle_files = [
|
|
|
|
('{vehicle} core', '{vehicle}.core'),
|
|
|
|
('{vehicle} ELF', '{vehicle}.elf'),
|
|
|
|
]
|
2018-07-03 21:51:22 -03:00
|
|
|
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')
|
2020-03-26 20:14:17 -03:00
|
|
|
results.addglob('APM:Rover documentation', 'docs/Rover/index.html')
|
2017-02-24 19:22:38 -04:00
|
|
|
results.addglob('APM:Sub documentation', 'docs/ArduSub/index.html')
|
2023-08-24 01:28:48 -03:00
|
|
|
results.addglob('APM:Blimp documentation', 'docs/Blimp/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
|
|
|
|
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
|
|
|
|
2021-04-28 01:58:04 -03:00
|
|
|
corefiles = glob.glob("core*")
|
2021-07-06 02:47:15 -03:00
|
|
|
corefiles.extend(glob.glob("ap-*.core"))
|
2021-04-28 01:58:04 -03:00
|
|
|
if corefiles:
|
|
|
|
print('Removing corefiles: %s' % str(corefiles))
|
|
|
|
for f in corefiles:
|
|
|
|
os.unlink(f)
|
|
|
|
|
2021-07-06 02:47:15 -03:00
|
|
|
diagnostic_files = []
|
|
|
|
for p in "dumpstack.sh_*", "dumpcore.sh_*", "autotest-*tlog":
|
2021-07-06 02:53:19 -03:00
|
|
|
diagnostic_files.extend(glob.glob(p))
|
2021-07-06 02:47:15 -03:00
|
|
|
if diagnostic_files:
|
|
|
|
print('Removing diagnostic files: %s' % str(diagnostic_files))
|
|
|
|
for f in diagnostic_files:
|
|
|
|
os.unlink(f)
|
|
|
|
|
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
|
2023-08-31 18:45:12 -03:00
|
|
|
if isinstance(success, tuple):
|
2019-05-07 20:14:23 -03:00
|
|
|
(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()))
|
|
|
|
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)
|
2021-03-31 09:36:14 -03:00
|
|
|
|
|
|
|
global tester
|
|
|
|
if tester is not None and tester.rc_thread is not None:
|
|
|
|
if passed:
|
|
|
|
print("BAD: RC Thread still alive after run_step")
|
|
|
|
tester.rc_thread_should_quit = True
|
|
|
|
tester.rc_thread.join()
|
|
|
|
tester.rc_thread = None
|
|
|
|
|
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:
|
2022-09-11 07:39:29 -03:00
|
|
|
print(" " + str(failure))
|
2019-05-07 20:14:23 -03:00
|
|
|
|
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
|
|
|
|
2020-07-30 11:59:28 -03:00
|
|
|
|
2023-08-04 05:32:39 -03:00
|
|
|
vehicle_list = ['Sub', 'Copter', 'Plane', 'Tracker', 'Rover', 'QuadPlane', 'BalanceBot', 'Helicopter', 'Sailboat', 'Blimp']
|
2020-07-30 11:59:28 -03:00
|
|
|
|
|
|
|
|
|
|
|
def list_subtests():
|
|
|
|
"""Print the list of tests and tests description for each vehicle."""
|
|
|
|
for vehicle in sorted(vehicle_list):
|
2020-04-02 22:35:00 -03:00
|
|
|
tester_class = tester_class_map["test.%s" % vehicle]
|
|
|
|
tester = tester_class("/bin/true", None)
|
|
|
|
subtests = tester.tests()
|
2021-01-26 15:35:11 -04:00
|
|
|
sorted_list = []
|
|
|
|
for subtest in subtests:
|
2023-03-08 21:47:31 -04:00
|
|
|
if str(type(subtest)) == "<class 'method'>":
|
|
|
|
subtest = Test(subtest)
|
|
|
|
sorted_list.append([subtest.name, subtest.description])
|
2021-01-26 15:35:11 -04:00
|
|
|
sorted_list.sort()
|
|
|
|
|
2020-04-02 22:35:00 -03:00
|
|
|
print("%s:" % vehicle)
|
2021-01-26 15:35:11 -04:00
|
|
|
for subtest in sorted_list:
|
|
|
|
print(" %s: %s" % (subtest[0], subtest[1]))
|
2020-04-02 22:35:00 -03:00
|
|
|
print("")
|
2018-07-03 21:51:22 -03:00
|
|
|
|
2020-07-30 11:59:28 -03:00
|
|
|
|
|
|
|
def list_subtests_for_vehicle(vehicle_type):
|
|
|
|
"""Print the list of tests for a vehicle."""
|
|
|
|
# Check that we aren't in a sub test
|
|
|
|
if "Test" in vehicle_type:
|
|
|
|
vehicle_type = re.findall('[A-Z][a-z0-9]*', vehicle_type)[0]
|
|
|
|
if vehicle_type in vehicle_list:
|
|
|
|
tester_class = tester_class_map["test.%s" % vehicle_type]
|
|
|
|
tester = tester_class("/bin/true", None)
|
|
|
|
subtests = tester.tests()
|
2021-01-26 15:35:11 -04:00
|
|
|
sorted_list = []
|
|
|
|
for subtest in subtests:
|
2023-08-31 18:45:12 -03:00
|
|
|
if not isinstance(subtest, Test):
|
2022-09-11 01:32:17 -03:00
|
|
|
subtest = Test(subtest)
|
|
|
|
sorted_list.append([subtest.name, subtest.description])
|
2021-01-26 15:35:11 -04:00
|
|
|
sorted_list.sort()
|
|
|
|
for subtest in sorted_list:
|
|
|
|
print("%s " % subtest[0], end='')
|
2020-07-30 11:59:28 -03:00
|
|
|
print("") # needed to clear the trailing %
|
|
|
|
|
2021-02-10 19:35:25 -04: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'
|
2021-02-10 19:35:25 -04:00
|
|
|
|
2020-05-13 14:06:54 -03:00
|
|
|
if sys.platform != "darwin":
|
|
|
|
os.putenv('TMPDIR', util.reltopdir('tmp'))
|
2013-04-14 04:16:30 -03:00
|
|
|
|
2020-04-02 22:27:52 -03:00
|
|
|
class MyOptionParser(optparse.OptionParser):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Custom option parse class."""
|
|
|
|
|
2020-04-02 22:27:52 -03:00
|
|
|
def format_epilog(self, formatter):
|
2021-06-12 17:54:17 -03:00
|
|
|
"""Retun customized option parser epilog."""
|
2020-04-02 22:27:52 -03:00
|
|
|
return self.epilog
|
|
|
|
|
|
|
|
parser = MyOptionParser(
|
|
|
|
"autotest", epilog=""
|
|
|
|
"e.g. autotest.py build.Rover test.Rover # test Rover\n"
|
|
|
|
"e.g. autotest.py build.Rover test.Rover build.Plane test.Plane # test Rover and Plane\n"
|
|
|
|
"e.g. autotest.py --debug --valgrind build.Rover test.Rover # test Rover under Valgrind\n"
|
|
|
|
"e.g. autotest.py --debug --gdb build.Tracker test.Tracker # run Tracker under gdb\n"
|
|
|
|
"e.g. autotest.py --debug --gdb build.Sub test.Sub.DiveManual # do specific Sub test\n"
|
|
|
|
)
|
2021-03-26 01:00:42 -03:00
|
|
|
parser.add_option("--autotest-server",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Run in autotest-server mode; dangerous!')
|
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')
|
2020-04-02 22:35:00 -03:00
|
|
|
parser.add_option("--list-subtests",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='list available subtests e.g. test.Copter')
|
2018-07-03 21:51:22 -03:00
|
|
|
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",
|
2021-02-13 04:29:20 -04:00
|
|
|
default=None,
|
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")
|
2020-02-12 23:35:12 -04:00
|
|
|
parser.add_option("--validate-parameters",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="validate vehicle parameter files")
|
2020-09-07 05:29:44 -03:00
|
|
|
parser.add_option("--Werror",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='configure with --Werror')
|
2023-10-10 09:30:46 -03:00
|
|
|
parser.add_option("--junit",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='Generate Junit XML tests report')
|
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",
|
2021-07-06 02:00:37 -03:00
|
|
|
default=None,
|
|
|
|
action='store_true',
|
|
|
|
help='make built SITL binaries debug binaries')
|
|
|
|
group_build.add_option("--no-debug",
|
|
|
|
default=None,
|
2018-05-10 22:31:29 -03:00
|
|
|
action='store_true',
|
2021-07-06 02:00:37 -03:00
|
|
|
help='do not make built SITL binaries debug binaries')
|
2021-05-24 10:48:42 -03:00
|
|
|
group_build.add_option("--coverage",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='make built binaries coverage binaries')
|
2020-04-27 22:37:33 -03:00
|
|
|
group_build.add_option("--enable-math-check-indexes",
|
|
|
|
default=False,
|
|
|
|
action="store_true",
|
|
|
|
dest="math_check_indexes",
|
|
|
|
help="enable checking of math indexes")
|
2021-07-08 19:47:07 -03:00
|
|
|
group_build.add_option("--postype-single",
|
|
|
|
default=False,
|
|
|
|
action="store_true",
|
|
|
|
dest="postype_single",
|
|
|
|
help="force single precision copter position controller")
|
|
|
|
group_build.add_option("--ekf-single",
|
|
|
|
default=False,
|
|
|
|
action="store_true",
|
|
|
|
dest="ekf_single",
|
|
|
|
help="force single precision EKF")
|
2023-01-08 18:56:33 -04:00
|
|
|
group_build.add_option("--force-32bit",
|
2021-09-07 16:32:24 -03:00
|
|
|
default=False,
|
|
|
|
action='store_true',
|
2023-01-08 18:56:33 -04:00
|
|
|
dest="force_32bit",
|
2021-09-07 16:32:24 -03:00
|
|
|
help="compile sitl using 32-bit")
|
2022-07-10 20:16:55 -03:00
|
|
|
group_build.add_option("", "--ubsan",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
dest="ubsan",
|
|
|
|
help="compile sitl with undefined behaviour sanitiser")
|
|
|
|
group_build.add_option("", "--ubsan-abort",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
dest="ubsan_abort",
|
|
|
|
help="compile sitl with undefined behaviour sanitiser and abort on error")
|
2023-03-03 19:53:50 -04:00
|
|
|
group_build.add_option("--num-aux-imus",
|
|
|
|
dest="num_aux_imus",
|
|
|
|
default=0,
|
|
|
|
type='int',
|
|
|
|
help='number of auxiliary IMUs to simulate')
|
2023-01-22 03:32:44 -04:00
|
|
|
group_build.add_option("--enable-dronecan-tests",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
dest="dronecan_tests",
|
|
|
|
help="enable dronecan tests")
|
2018-05-10 22:31:29 -03:00
|
|
|
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')
|
2021-11-29 02:18:13 -04:00
|
|
|
group_sim.add_option("", "--callgrind",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="enable valgrind for performance analysis (slow!!)")
|
2018-05-10 22:31:29 -03:00
|
|
|
group_sim.add_option("--gdb",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='run ArduPilot binaries under gdb')
|
2021-06-10 01:17:04 -03:00
|
|
|
group_sim.add_option("--gdb-no-tui",
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='when running under GDB do NOT start in TUI mode')
|
2018-05-10 22:31:29 -03:00
|
|
|
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")
|
2020-04-23 03:37:23 -03:00
|
|
|
group_sim.add_option("", "--force-ahrs-type",
|
|
|
|
dest="force_ahrs_type",
|
|
|
|
default=None,
|
|
|
|
help="force a specific AHRS type (e.g. 10 for SITL-ekf")
|
2021-07-16 07:31:13 -03:00
|
|
|
group_sim.add_option("", "--replay",
|
|
|
|
action='store_true',
|
|
|
|
help="enable replay logging for tests")
|
2018-05-10 22:31:29 -03:00
|
|
|
parser.add_option_group(group_sim)
|
2011-11-09 08:53:09 -04:00
|
|
|
|
2020-07-30 11:59:28 -03:00
|
|
|
group_completion = optparse.OptionGroup(parser, "Completion helpers")
|
|
|
|
group_completion.add_option("--list-vehicles",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='list available vehicles')
|
|
|
|
group_completion.add_option("--list-vehicles-test",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='list available vehicle tester')
|
|
|
|
group_completion.add_option("--list-subtests-for-vehicle",
|
|
|
|
type='string',
|
|
|
|
default="",
|
2021-02-10 19:35:25 -04:00
|
|
|
help='list available subtests for a vehicle e.g Copter')
|
2021-08-02 19:55:56 -03:00
|
|
|
group_completion.add_option("--reset-after-every-test",
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='reset everything after every test run')
|
2020-07-30 11:59:28 -03:00
|
|
|
parser.add_option_group(group_completion)
|
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
opts, args = parser.parse_args()
|
2011-12-02 00:21:15 -04:00
|
|
|
|
2021-07-06 02:00:37 -03:00
|
|
|
# canonicalise on opts.debug:
|
|
|
|
if opts.debug is None and opts.no_debug is None:
|
|
|
|
# default is to create debug SITL binaries
|
|
|
|
opts.debug = True
|
|
|
|
elif opts.debug is not None and opts.no_debug is not None:
|
|
|
|
if opts.debug == opts.no_debug:
|
|
|
|
raise ValueError("no_debug != !debug")
|
|
|
|
elif opts.no_debug is not None:
|
|
|
|
opts.debug = not opts.no_debug
|
|
|
|
|
2021-02-13 04:29:20 -04:00
|
|
|
if opts.timeout is None:
|
|
|
|
opts.timeout = 5400
|
|
|
|
# adjust if we're running in a regime which may slow us down e.g. Valgrind
|
|
|
|
if opts.valgrind:
|
|
|
|
opts.timeout *= 10
|
2021-11-29 02:18:13 -04:00
|
|
|
elif opts.callgrind:
|
|
|
|
opts.timeout *= 10
|
2021-02-13 04:29:20 -04:00
|
|
|
elif opts.gdb:
|
|
|
|
opts.timeout = None
|
|
|
|
|
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
|
|
|
|
2020-11-08 06:29:20 -04:00
|
|
|
'build.Replay',
|
|
|
|
|
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
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
'build.Plane',
|
|
|
|
'test.Plane',
|
|
|
|
'test.QuadPlane',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
'build.Rover',
|
|
|
|
'test.Rover',
|
|
|
|
'test.BalanceBot',
|
2021-04-10 22:28:49 -03:00
|
|
|
'test.Sailboat',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
'build.Copter',
|
|
|
|
'test.Copter',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2018-07-03 21:51:22 -03:00
|
|
|
'build.Helicopter',
|
2020-03-25 17:47:28 -03:00
|
|
|
'test.Helicopter',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
'build.Tracker',
|
|
|
|
'test.Tracker',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
'build.Sub',
|
|
|
|
'test.Sub',
|
2017-08-09 05:14:45 -03:00
|
|
|
|
2021-11-13 23:49:18 -04:00
|
|
|
'build.Blimp',
|
2023-08-04 05:32:39 -03:00
|
|
|
'test.Blimp',
|
2021-11-13 23:49:18 -04:00
|
|
|
|
2024-01-11 22:50:43 -04:00
|
|
|
'build.SITLPeriphUniversal',
|
2020-09-29 15:54:02 -03:00
|
|
|
'test.CAN',
|
|
|
|
|
2022-07-03 21:08:36 -03:00
|
|
|
# convertgps disabled as it takes 5 hours
|
|
|
|
# 'convertgpx',
|
2017-08-09 05:14:45 -03:00
|
|
|
]
|
|
|
|
|
2020-02-21 21:32:43 -04:00
|
|
|
moresteps = [
|
2020-10-14 02:18:10 -03:00
|
|
|
'test.CopterTests1a',
|
|
|
|
'test.CopterTests1b',
|
|
|
|
'test.CopterTests1c',
|
|
|
|
'test.CopterTests1d',
|
|
|
|
'test.CopterTests1e',
|
|
|
|
|
|
|
|
'test.CopterTests2a',
|
|
|
|
'test.CopterTests2b',
|
|
|
|
|
2020-03-27 20:39:38 -03:00
|
|
|
'clang-scan-build',
|
2020-02-21 21:32:43 -04:00
|
|
|
]
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
# canonicalise the step names. This allows
|
|
|
|
# backwards-compatability from the hodge-podge
|
|
|
|
# fly.ArduCopter/drive.APMrover2 to the more common test.Copter
|
|
|
|
# test.Rover
|
|
|
|
step_mapping = {
|
|
|
|
"build.ArduPlane": "build.Plane",
|
|
|
|
"build.ArduCopter": "build.Copter",
|
|
|
|
"build.APMrover2": "build.Rover",
|
|
|
|
"build.ArduSub": "build.Sub",
|
|
|
|
"build.AntennaTracker": "build.Tracker",
|
|
|
|
"fly.ArduCopter": "test.Copter",
|
|
|
|
"fly.ArduPlane": "test.Plane",
|
|
|
|
"fly.QuadPlane": "test.QuadPlane",
|
|
|
|
"dive.ArduSub": "test.Sub",
|
|
|
|
"drive.APMrover2": "test.Rover",
|
|
|
|
"drive.BalanceBot": "test.BalanceBot",
|
|
|
|
"drive.balancebot": "test.BalanceBot",
|
|
|
|
"fly.CopterAVC": "test.Helicopter",
|
|
|
|
"test.AntennaTracker": "test.Tracker",
|
2020-10-14 02:18:10 -03:00
|
|
|
"fly.ArduCopterTests1a": "test.CopterTests1a",
|
|
|
|
"fly.ArduCopterTests1b": "test.CopterTests1b",
|
|
|
|
"fly.ArduCopterTests1c": "test.CopterTests1c",
|
|
|
|
"fly.ArduCopterTests1d": "test.CopterTests1d",
|
|
|
|
"fly.ArduCopterTests1e": "test.CopterTests1e",
|
|
|
|
|
|
|
|
"fly.ArduCopterTests2a": "test.CopterTests2a",
|
|
|
|
"fly.ArduCopterTests2b": "test.CopterTests2b",
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
# form up a list of bits NOT to run, mapping from old step names
|
|
|
|
# to new step names as appropriate.
|
2017-08-09 05:14:45 -03:00
|
|
|
skipsteps = opts.skip.split(',')
|
2020-03-25 17:47:28 -03:00
|
|
|
new_skipsteps = []
|
|
|
|
for skipstep in skipsteps:
|
|
|
|
if skipstep in step_mapping:
|
|
|
|
new_skipsteps.append(step_mapping[skipstep])
|
|
|
|
else:
|
|
|
|
new_skipsteps.append(skipstep)
|
|
|
|
skipsteps = new_skipsteps
|
2017-08-09 05:14:45 -03:00
|
|
|
|
|
|
|
# ensure we catch timeouts
|
|
|
|
signal.signal(signal.SIGALRM, alarm_handler)
|
2021-02-13 04:29:20 -04:00
|
|
|
if opts.timeout is not None:
|
|
|
|
signal.alarm(opts.timeout)
|
2017-08-09 05:14:45 -03:00
|
|
|
|
|
|
|
if opts.list:
|
|
|
|
for step in steps:
|
|
|
|
print(step)
|
|
|
|
sys.exit(0)
|
|
|
|
|
2020-04-02 22:35:00 -03:00
|
|
|
if opts.list_subtests:
|
|
|
|
list_subtests()
|
|
|
|
sys.exit(0)
|
|
|
|
|
2020-07-30 11:59:28 -03:00
|
|
|
if opts.list_subtests_for_vehicle:
|
|
|
|
list_subtests_for_vehicle(opts.list_subtests_for_vehicle)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if opts.list_vehicles_test:
|
|
|
|
print(' '.join(__bin_names.keys()))
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if opts.list_vehicles:
|
|
|
|
print(' '.join(vehicle_list))
|
|
|
|
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)
|
|
|
|
|
2020-03-25 17:47:28 -03:00
|
|
|
# provide backwards-compatability from (e.g.) drive.APMrover2 -> test.Rover
|
|
|
|
newargs = []
|
|
|
|
for arg in args:
|
|
|
|
for _from, to in step_mapping.items():
|
|
|
|
arg = re.sub("^%s" % _from, to, arg)
|
|
|
|
newargs.append(arg)
|
|
|
|
args = newargs
|
|
|
|
|
2022-09-07 22:12:12 -03:00
|
|
|
if len(args) == 0 and not opts.autotest_server:
|
|
|
|
print("Steps must be supplied; try --list and/or --list-subtests or --help")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2017-08-09 05:14:45 -03:00
|
|
|
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)
|
|
|
|
|
2020-02-21 21:32:43 -04:00
|
|
|
if a in moresteps:
|
|
|
|
matches.append(a)
|
|
|
|
|
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:
|
2021-01-08 23:38:02 -04:00
|
|
|
print("KeyboardInterrupt caught; closing pexpect connections")
|
2017-08-09 05:14:45 -03:00
|
|
|
util.pexpect_close_all()
|
2021-01-08 23:38:02 -04:00
|
|
|
raise
|
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
|