xref: /openbmc/u-boot/test/run (revision 2673afe221d17b8d43df3ecae3e3a6024b209ffe)
12f52018cSSimon Glass#!/bin/bash
22f52018cSSimon Glass
3c9adb355SSimon Glass# Script to run all U-Boot tests that use sandbox.
4c9adb355SSimon Glass
5c9adb355SSimon Glass# Runs a test and checks the exit code to decide if it passed
6c9adb355SSimon Glass#  $1:         Test name
7c9adb355SSimon Glass#  $2 onwards: command line to run
82f52018cSSimon Glassrun_test() {
9c9adb355SSimon Glass	echo -n "$1: "
10c9adb355SSimon Glass	shift
11c9adb355SSimon Glass	"$@"
123bc11e81SSimon Glass	[ $? -ne 0 ] && failures=$((failures+1))
132f52018cSSimon Glass}
1407f4eadcSSimon Glass
153bc11e81SSimon Glassfailures=0
1673a01d90SSimon Glass
17029ab15aSSimon Glass# Run all tests that the standard sandbox build can support
18c9adb355SSimon Glassrun_test "sandbox" ./test/py/test.py --bd sandbox --build
19029ab15aSSimon Glass
20029ab15aSSimon Glass# Run tests which require sandbox_spl
21c9adb355SSimon Glassrun_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
22c9adb355SSimon Glass	-k test_ofplatdata.py
23029ab15aSSimon Glass
243bc11e81SSimon Glass# Run tests for the flat-device-tree version of sandbox. This is a special
253bc11e81SSimon Glass# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
263bc11e81SSimon Glass# check that functionality is the same. The standard sandbox build (above) uses
273bc11e81SSimon Glass# CONFIG_OF_LIVE.
28*2673afe2SSimon Glassrun_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \
29*2673afe2SSimon Glass	-k test_ut
302f52018cSSimon Glass
31734f3de9SSimon Glass# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
32734f3de9SSimon Glass# provides and which is built by the sandbox_spl config.
33ed772fe7SSimon GlassDTC_DIR=build-sandbox_spl/scripts/dtc
34734f3de9SSimon Glassexport PYTHONPATH=${DTC_DIR}/pylibfdt
35734f3de9SSimon Glassexport DTC=${DTC_DIR}/dtc
36ed772fe7SSimon Glass
37c9adb355SSimon Glassrun_test "binman" ./tools/binman/binman -t
38c9adb355SSimon Glassrun_test "patman" ./tools/patman/patman --test
39c9adb355SSimon Glassrun_test "buildman" ./tools/buildman/buildman -t
403bc11e81SSimon Glassrun_test "fdt" ./tools/dtoc/test_fdt -t
41c9adb355SSimon Glassrun_test "dtoc" ./tools/dtoc/dtoc -t
4272d8172bSSimon Glass
4330d704c6SSimon Glass# This needs you to set up Python test coverage tools.
4430d704c6SSimon Glass# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
4516d836cdSTom Rini#   $ sudo apt-get install python-pytest python-coverage
46c9adb355SSimon Glassrun_test "binman code coverage" ./tools/binman/binman -T
47c9adb355SSimon Glassrun_test "dtoc code coverage" ./tools/dtoc/dtoc -T
48c9adb355SSimon Glassrun_test "fdt code coverage" ./tools/dtoc/test_fdt -T
4930d704c6SSimon Glass
503bc11e81SSimon Glassif [ $failures == 0 ]; then
512f52018cSSimon Glass	echo "Tests passed!"
522f52018cSSimon Glasselse
532f52018cSSimon Glass	echo "Tests FAILED"
542f52018cSSimon Glass	exit 1
552f52018cSSimon Glassfi
56