mirror of https://github.com/ArduPilot/ardupilot
Tools: autotest: add steps to autotest to build and run unit tests
This is Linux-specific ATM
This commit is contained in:
parent
8e3b69bca0
commit
aa36d20aa1
|
@ -142,6 +142,38 @@ def build_examples():
|
|||
|
||||
return True
|
||||
|
||||
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
|
||||
|
||||
def param_parse_filepath():
|
||||
return util.reltopdir('Tools/autotest/param_metadata/param_parse.py')
|
||||
|
@ -367,6 +399,12 @@ def run_step(step):
|
|||
if step == 'convertgpx':
|
||||
return convert_gpx()
|
||||
|
||||
if step == 'build.unit_tests':
|
||||
return build_unit_tests()
|
||||
|
||||
if step == 'run.unit_tests':
|
||||
return run_unit_tests()
|
||||
|
||||
raise RuntimeError("Unknown step %s" % step)
|
||||
|
||||
|
||||
|
@ -630,6 +668,9 @@ if __name__ == "__main__":
|
|||
'build.Examples',
|
||||
'build.Parameters',
|
||||
|
||||
'build.unit_tests',
|
||||
'run.unit_tests',
|
||||
|
||||
'build.ArduPlane',
|
||||
'defaults.ArduPlane',
|
||||
'fly.ArduPlane',
|
||||
|
|
|
@ -134,6 +134,17 @@ def build_examples(board, j=None, debug=False, clean=False):
|
|||
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True)
|
||||
return True
|
||||
|
||||
def build_tests(board, j=None, debug=False, clean=False):
|
||||
# first configure
|
||||
waf_configure(board, j=j, debug=debug)
|
||||
|
||||
# then clean
|
||||
if clean:
|
||||
waf_clean()
|
||||
|
||||
# then build
|
||||
run_cmd([relwaf(), "tests"], directory=topdir(), checkfail=True, show=True)
|
||||
return True
|
||||
|
||||
# list of pexpect children to close on exit
|
||||
close_list = []
|
||||
|
|
Loading…
Reference in New Issue