mirror of https://github.com/ArduPilot/ardupilot
autotest: add support for building alternate binaries
e.g. adding features ordinarily compiled out
This commit is contained in:
parent
c0243772b4
commit
28ed2e3cd5
|
@ -9,6 +9,7 @@ Andrew Tridgell, October 2011
|
|||
from __future__ import print_function
|
||||
import atexit
|
||||
import fnmatch
|
||||
import copy
|
||||
import glob
|
||||
import optparse
|
||||
import os
|
||||
|
@ -40,6 +41,8 @@ from common import Test
|
|||
|
||||
tester = None
|
||||
|
||||
build_opts = None
|
||||
|
||||
|
||||
def buildlogs_dirpath():
|
||||
"""Return BUILDLOGS directory path."""
|
||||
|
@ -454,6 +457,8 @@ def run_step(step):
|
|||
if opts.Werror:
|
||||
build_opts['extra_configure_args'].append("--Werror")
|
||||
|
||||
build_opts = build_opts
|
||||
|
||||
vehicle_binary = None
|
||||
if step == 'build.Plane':
|
||||
vehicle_binary = 'bin/arduplane'
|
||||
|
@ -533,6 +538,7 @@ def run_step(step):
|
|||
"logs_dir": buildlogs_dirpath(),
|
||||
"sup_binaries": supplementary_binaries,
|
||||
"reset_after_every_test": opts.reset_after_every_test,
|
||||
"build_opts": copy.copy(build_opts),
|
||||
}
|
||||
if opts.speedup is not None:
|
||||
fly_opts["speedup"] = opts.speedup
|
||||
|
|
|
@ -1467,7 +1467,8 @@ class AutoTest(ABC):
|
|||
reset_after_every_test=False,
|
||||
sitl_32bit=False,
|
||||
ubsan=False,
|
||||
ubsan_abort=False):
|
||||
ubsan_abort=False,
|
||||
build_opts={}):
|
||||
|
||||
self.start_time = time.time()
|
||||
global __autotest__ # FIXME; make progress a non-staticmethod
|
||||
|
@ -1495,6 +1496,7 @@ class AutoTest(ABC):
|
|||
self.sitl_32bit = sitl_32bit
|
||||
self.ubsan = ubsan
|
||||
self.ubsan_abort = ubsan_abort
|
||||
self.build_opts = build_opts
|
||||
|
||||
self.mavproxy = None
|
||||
self._mavproxy = None # for auto-cleanup on failed tests
|
||||
|
@ -4992,6 +4994,32 @@ class AutoTest(ABC):
|
|||
dead_parameters_dict[p[0]] = p[1]
|
||||
self.set_parameters(dead_parameters_dict, add_to_context=False)
|
||||
|
||||
if getattr(self, "old_binary", None) is not None:
|
||||
self.stop_SITL()
|
||||
with open(self.binary, "wb") as f:
|
||||
f.write(self.old_binary)
|
||||
f.close()
|
||||
self.start_SITL(wipe=False)
|
||||
self.set_streamrate(self.sitl_streamrate())
|
||||
|
||||
def context_start_custom_binary(self, extra_defines={}):
|
||||
# grab copy of current binary:
|
||||
context = self.context_get()
|
||||
if getattr(context, "old_binary", None) is not None:
|
||||
raise ValueError("Not nestable at the moment")
|
||||
with open(self.binary, "rb") as f:
|
||||
self.old_binary = f.read()
|
||||
f.close()
|
||||
build_opts = copy.copy(self.build_opts)
|
||||
build_opts["extra_defines"] = extra_defines
|
||||
util.build_SITL(
|
||||
'bin/arducopter', # FIXME!
|
||||
**build_opts,
|
||||
)
|
||||
self.stop_SITL()
|
||||
self.start_SITL(wipe=False)
|
||||
self.set_streamrate(self.sitl_streamrate())
|
||||
|
||||
class Context(object):
|
||||
def __init__(self, testsuite):
|
||||
self.testsuite = testsuite
|
||||
|
|
|
@ -99,7 +99,7 @@ def relwaf():
|
|||
return "./modules/waf/waf-light"
|
||||
|
||||
|
||||
def waf_configure(board, j=None, debug=False, math_check_indexes=False, coverage=False, ekf_single=False, postype_single=False, sitl_32bit=False, ubsan=False, ubsan_abort=False, extra_args=[], extra_hwdef=None):
|
||||
def waf_configure(board, j=None, debug=False, math_check_indexes=False, coverage=False, ekf_single=False, postype_single=False, sitl_32bit=False, extra_args=[], extra_hwdef=None, ubsan=False, ubsan_abort=False, extra_defines={}):
|
||||
cmd_configure = [relwaf(), "configure", "--board", board]
|
||||
if debug:
|
||||
cmd_configure.append('--debug')
|
||||
|
@ -119,6 +119,8 @@ def waf_configure(board, j=None, debug=False, math_check_indexes=False, coverage
|
|||
cmd_configure.append('--ubsan-abort')
|
||||
if extra_hwdef is not None:
|
||||
cmd_configure.extend(['--extra-hwdef', extra_hwdef])
|
||||
for nv in extra_defines.items():
|
||||
cmd_configure.extend(['--define', "%s=%s" % nv])
|
||||
if j is not None:
|
||||
cmd_configure.extend(['-j', str(j)])
|
||||
pieces = [shlex.split(x) for x in extra_args]
|
||||
|
@ -137,8 +139,23 @@ def waf_build(target=None):
|
|||
cmd.append(target)
|
||||
run_cmd(cmd, directory=topdir(), checkfail=True)
|
||||
|
||||
def build_SITL(build_target, j=None, debug=False, board='sitl', clean=True, configure=True, math_check_indexes=False, coverage=False,
|
||||
ekf_single=False, postype_single=False, sitl_32bit=False, ubsan=False, ubsan_abort=False, extra_configure_args=[]):
|
||||
def build_SITL(
|
||||
build_target,
|
||||
board='sitl',
|
||||
clean=True,
|
||||
configure=True,
|
||||
coverage=False,
|
||||
debug=False,
|
||||
ekf_single=False,
|
||||
extra_configure_args=[],
|
||||
extra_defines={},
|
||||
j=None,
|
||||
math_check_indexes=False,
|
||||
postype_single=False,
|
||||
sitl_32bit=False,
|
||||
ubsan=False,
|
||||
ubsan_abort=False,
|
||||
):
|
||||
|
||||
# first configure
|
||||
if configure:
|
||||
|
@ -152,6 +169,7 @@ def build_SITL(build_target, j=None, debug=False, board='sitl', clean=True, conf
|
|||
sitl_32bit=sitl_32bit,
|
||||
ubsan=ubsan,
|
||||
ubsan_abort=ubsan_abort,
|
||||
extra_defines=extra_defines,
|
||||
extra_args=extra_configure_args)
|
||||
|
||||
# then clean
|
||||
|
|
|
@ -370,6 +370,9 @@ def do_build(opts, frame_options):
|
|||
if opts.ubsan_abort:
|
||||
cmd_configure.append("--ubsan-abort")
|
||||
|
||||
for nv in opts.define:
|
||||
cmd_configure.append("--define=%s" % nv)
|
||||
|
||||
pieces = [shlex.split(x) for x in opts.waf_configure_args]
|
||||
for piece in pieces:
|
||||
cmd_configure.extend(piece)
|
||||
|
@ -967,6 +970,11 @@ group_build.add_option("", "--sitl-32bit",
|
|||
action='store_true',
|
||||
dest="sitl_32bit",
|
||||
help="compile sitl using 32-bit")
|
||||
group_build.add_option("", "--configure-define",
|
||||
default=[],
|
||||
action='append',
|
||||
dest="define",
|
||||
help="create a preprocessor define")
|
||||
group_build.add_option("", "--rebuild-on-failure",
|
||||
dest="rebuild_on_failure",
|
||||
action='store_true',
|
||||
|
|
Loading…
Reference in New Issue