xref: /openbmc/u-boot/test/run (revision 172e3c11901229f0fb88317ac73a47d944a74f46)
12f52018cSSimon Glass#!/bin/bash
22f52018cSSimon Glass
3c9adb355SSimon Glass# Script to run all U-Boot tests that use sandbox.
4*499fde5cSSimon Glass#  $1: tests to run (empty for all, 'quick' for quick ones only)
5c9adb355SSimon Glass
6c9adb355SSimon Glass# Runs a test and checks the exit code to decide if it passed
7c9adb355SSimon Glass#  $1:         Test name
8c9adb355SSimon Glass#  $2 onwards: command line to run
92f52018cSSimon Glassrun_test() {
10c9adb355SSimon Glass	echo -n "$1: "
11c9adb355SSimon Glass	shift
12c9adb355SSimon Glass	"$@"
133bc11e81SSimon Glass	[ $? -ne 0 ] && failures=$((failures+1))
142f52018cSSimon Glass}
1507f4eadcSSimon Glass
16*499fde5cSSimon Glass# SKip slow tests if requested
17*499fde5cSSimon Glass[ "$1" == "quick" ] && mark_expr="not slow"
18*499fde5cSSimon Glass
193bc11e81SSimon Glassfailures=0
2073a01d90SSimon Glass
21029ab15aSSimon Glass# Run all tests that the standard sandbox build can support
22*499fde5cSSimon Glassrun_test "sandbox" ./test/py/test.py --bd sandbox --build -m "${mark_expr}"
23029ab15aSSimon Glass
24029ab15aSSimon Glass# Run tests which require sandbox_spl
25c9adb355SSimon Glassrun_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
26b0edea3cSSimon Glass	-k 'test_ofplatdata or test_handoff'
27029ab15aSSimon Glass
283bc11e81SSimon Glass# Run tests for the flat-device-tree version of sandbox. This is a special
293bc11e81SSimon Glass# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
303bc11e81SSimon Glass# check that functionality is the same. The standard sandbox build (above) uses
313bc11e81SSimon Glass# CONFIG_OF_LIVE.
322673afe2SSimon Glassrun_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \
332673afe2SSimon Glass	-k test_ut
342f52018cSSimon Glass
35734f3de9SSimon Glass# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
36734f3de9SSimon Glass# provides and which is built by the sandbox_spl config.
37ed772fe7SSimon GlassDTC_DIR=build-sandbox_spl/scripts/dtc
38734f3de9SSimon Glassexport PYTHONPATH=${DTC_DIR}/pylibfdt
39734f3de9SSimon Glassexport DTC=${DTC_DIR}/dtc
40ed772fe7SSimon Glass
41c9adb355SSimon Glassrun_test "binman" ./tools/binman/binman -t
42c9adb355SSimon Glassrun_test "patman" ./tools/patman/patman --test
43*499fde5cSSimon Glass
44*499fde5cSSimon Glass[ "$1" == "quick" ] && skip=--skip-net-tests
45*499fde5cSSimon Glassrun_test "buildman" ./tools/buildman/buildman -t ${skip}
463bc11e81SSimon Glassrun_test "fdt" ./tools/dtoc/test_fdt -t
47c9adb355SSimon Glassrun_test "dtoc" ./tools/dtoc/dtoc -t
4872d8172bSSimon Glass
4930d704c6SSimon Glass# This needs you to set up Python test coverage tools.
5030d704c6SSimon Glass# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
5116d836cdSTom Rini#   $ sudo apt-get install python-pytest python-coverage
52c9adb355SSimon Glassrun_test "binman code coverage" ./tools/binman/binman -T
53c9adb355SSimon Glassrun_test "dtoc code coverage" ./tools/dtoc/dtoc -T
54c9adb355SSimon Glassrun_test "fdt code coverage" ./tools/dtoc/test_fdt -T
5530d704c6SSimon Glass
563bc11e81SSimon Glassif [ $failures == 0 ]; then
572f52018cSSimon Glass	echo "Tests passed!"
582f52018cSSimon Glasselse
592f52018cSSimon Glass	echo "Tests FAILED"
602f52018cSSimon Glass	exit 1
612f52018cSSimon Glassfi
62