1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 00:32:04 +02:00

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>
This commit is contained in:
Simon Glass
2019-07-08 13:18:50 -06:00
parent d5164a7970
commit 8acce60b10
5 changed files with 24 additions and 9 deletions

View File

@@ -176,7 +176,7 @@ Run binman and dtoc testsuite:
./tools/buildman/buildman -P sandbox_spl && ./tools/buildman/buildman -P sandbox_spl &&
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
./tools/binman/binman -t && ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools -t &&
./tools/dtoc/dtoc -t ./tools/dtoc/dtoc -t
# Test sandbox with test.py # Test sandbox with test.py

View File

@@ -146,7 +146,7 @@ script:
if [[ -n "${TEST_PY_TOOLS}" ]]; then if [[ -n "${TEST_PY_TOOLS}" ]]; then
PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt" PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"
PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}" PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"
./tools/binman/binman -t && ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools -t &&
./tools/patman/patman --test && ./tools/patman/patman --test &&
./tools/buildman/buildman -t && ./tools/buildman/buildman -t &&
PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt" PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"

View File

@@ -33,12 +33,14 @@ run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \
-k test_ut -k test_ut
# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it # Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
# provides and which is built by the sandbox_spl config. # provides and which is built by the sandbox_spl config. Also set up the path
# to tools build by the build.
DTC_DIR=build-sandbox_spl/scripts/dtc DTC_DIR=build-sandbox_spl/scripts/dtc
export PYTHONPATH=${DTC_DIR}/pylibfdt export PYTHONPATH=${DTC_DIR}/pylibfdt
export DTC=${DTC_DIR}/dtc export DTC=${DTC_DIR}/dtc
TOOLS_DIR=build-sandbox_spl/tools
run_test "binman" ./tools/binman/binman -t run_test "binman" ./tools/binman/binman -t --toolpath ${TOOLS_DIR}
run_test "patman" ./tools/patman/patman --test run_test "patman" ./tools/patman/patman --test
[ "$1" == "quick" ] && skip=--skip-net-tests [ "$1" == "quick" ] && skip=--skip-net-tests
@@ -49,7 +51,8 @@ run_test "dtoc" ./tools/dtoc/dtoc -t
# This needs you to set up Python test coverage tools. # This needs you to set up Python test coverage tools.
# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu): # To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
# $ sudo apt-get install python-pytest python-coverage # $ sudo apt-get install python-pytest python-coverage
run_test "binman code coverage" ./tools/binman/binman -T export PATH=$PATH:${TOOLS_DIR}
run_test "binman code coverage" ./tools/binman/binman -T --toolpath ${TOOLS_DIR}
run_test "dtoc code coverage" ./tools/dtoc/dtoc -T run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
run_test "fdt code coverage" ./tools/dtoc/test_fdt -T run_test "fdt code coverage" ./tools/dtoc/test_fdt -T

View File

@@ -46,7 +46,7 @@ except:
import control import control
import test_util 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 """Run the functional tests and any embedded doctests
Args: Args:
@@ -60,6 +60,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args):
processes: Number of processes to use to run tests (None=same as #CPUs) 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 args: List of positional args provided to binman. This can hold a test
name to execute (as in 'binman -t testSections', for example) name to execute (as in 'binman -t testSections', for example)
toolpath: List of paths to use for tools
""" """
import elf_test import elf_test
import entry_test import entry_test
@@ -79,6 +80,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args):
sys.argv.append('-D') sys.argv.append('-D')
if verbosity: if verbosity:
sys.argv.append('-v%d' % 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 # Run the entry tests first ,since these need to be the first to import the
# 'entry' module. # 'entry' module.
@@ -91,7 +95,8 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args):
if hasattr(module, 'setup_test_args'): if hasattr(module, 'setup_test_args'):
setup_test_args = getattr(module, 'setup_test_args') setup_test_args = getattr(module, 'setup_test_args')
setup_test_args(preserve_indir=test_preserve_dirs, 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: if test_name:
try: try:
suite.addTests(loader.loadTestsFromName(test_name, module)) suite.addTests(loader.loadTestsFromName(test_name, module))
@@ -167,7 +172,8 @@ def RunBinman(options, args):
if options.test: if options.test:
ret_code = RunTests(options.debug, options.verbosity, options.processes, 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: elif options.test_coverage:
RunTestCoverage() RunTestCoverage()

View File

@@ -144,7 +144,8 @@ class TestFunctional(unittest.TestCase):
self._indir = None self._indir = None
@classmethod @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 """Accept arguments controlling test execution
Args: Args:
@@ -153,9 +154,11 @@ class TestFunctional(unittest.TestCase):
preserve_outdir: Preserve the output directories used by tests. Each preserve_outdir: Preserve the output directories used by tests. Each
test has its own, so this is normally only useful when running a test has its own, so this is normally only useful when running a
single test. single test.
toolpath: ist of paths to use for tools
""" """
cls.preserve_indir = preserve_indir cls.preserve_indir = preserve_indir
cls.preserve_outdirs = preserve_outdirs cls.preserve_outdirs = preserve_outdirs
cls.toolpath = toolpath
def setUp(self): def setUp(self):
# Enable this to turn on debugging output # Enable this to turn on debugging output
@@ -256,6 +259,9 @@ class TestFunctional(unittest.TestCase):
if images: if images:
for image in images: for image in images:
args += ['-i', image] args += ['-i', image]
if self.toolpath:
for path in self.toolpath:
args += ['--toolpath', path]
return self._DoBinman(*args) return self._DoBinman(*args)
def _SetupDtb(self, fname, outfile='u-boot.dtb'): def _SetupDtb(self, fname, outfile='u-boot.dtb'):