binman: Pass the toolpath to tests
Tools like ifwitool may not be available in the PATH, but are available in
the build. These tools may be needed by tests, so allow tests to use the
--toolpath flag.
Also use this flag with travis.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/binman.py b/tools/binman/binman.py
index 9878eb8..52c03f6 100755
--- a/tools/binman/binman.py
+++ b/tools/binman/binman.py
@@ -46,7 +46,7 @@
import control
import test_util
-def RunTests(debug, verbosity, processes, test_preserve_dirs, args):
+def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
"""Run the functional tests and any embedded doctests
Args:
@@ -60,6 +60,7 @@
processes: Number of processes to use to run tests (None=same as #CPUs)
args: List of positional args provided to binman. This can hold a test
name to execute (as in 'binman -t testSections', for example)
+ toolpath: List of paths to use for tools
"""
import elf_test
import entry_test
@@ -79,6 +80,9 @@
sys.argv.append('-D')
if verbosity:
sys.argv.append('-v%d' % verbosity)
+ if toolpath:
+ for path in toolpath:
+ sys.argv += ['--toolpath', path]
# Run the entry tests first ,since these need to be the first to import the
# 'entry' module.
@@ -91,7 +95,8 @@
if hasattr(module, 'setup_test_args'):
setup_test_args = getattr(module, 'setup_test_args')
setup_test_args(preserve_indir=test_preserve_dirs,
- preserve_outdirs=test_preserve_dirs and test_name is not None)
+ preserve_outdirs=test_preserve_dirs and test_name is not None,
+ toolpath=toolpath)
if test_name:
try:
suite.addTests(loader.loadTestsFromName(test_name, module))
@@ -167,7 +172,8 @@
if options.test:
ret_code = RunTests(options.debug, options.verbosity, options.processes,
- options.test_preserve_dirs, args[1:])
+ options.test_preserve_dirs, args[1:],
+ options.toolpath)
elif options.test_coverage:
RunTestCoverage()
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 256d4a1..3455b8c 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -144,7 +144,8 @@
self._indir = None
@classmethod
- def setup_test_args(cls, preserve_indir=False, preserve_outdirs=False):
+ def setup_test_args(cls, preserve_indir=False, preserve_outdirs=False,
+ toolpath=None):
"""Accept arguments controlling test execution
Args:
@@ -153,9 +154,11 @@
preserve_outdir: Preserve the output directories used by tests. Each
test has its own, so this is normally only useful when running a
single test.
+ toolpath: ist of paths to use for tools
"""
cls.preserve_indir = preserve_indir
cls.preserve_outdirs = preserve_outdirs
+ cls.toolpath = toolpath
def setUp(self):
# Enable this to turn on debugging output
@@ -256,6 +259,9 @@
if images:
for image in images:
args += ['-i', image]
+ if self.toolpath:
+ for path in self.toolpath:
+ args += ['--toolpath', path]
return self._DoBinman(*args)
def _SetupDtb(self, fname, outfile='u-boot.dtb'):