xref: /openbmc/u-boot/test/run (revision 3bc11e818c3ad049a24ba2c2deb27ddd651a6e3b)
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	"$@"
12*3bc11e81SSimon Glass	[ $? -ne 0 ] && failures=$((failures+1))
132f52018cSSimon Glass}
1407f4eadcSSimon Glass
15*3bc11e81SSimon 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
24*3bc11e81SSimon Glass# Run tests for the flat-device-tree version of sandbox. This is a special
25*3bc11e81SSimon Glass# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
26*3bc11e81SSimon Glass# check that functionality is the same. The standard sandbox build (above) uses
27*3bc11e81SSimon Glass# CONFIG_OF_LIVE.
28c9adb355SSimon Glassrun_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build
292f52018cSSimon Glass
30734f3de9SSimon Glass# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
31734f3de9SSimon Glass# provides and which is built by the sandbox_spl config.
32ed772fe7SSimon GlassDTC_DIR=build-sandbox_spl/scripts/dtc
33734f3de9SSimon Glassexport PYTHONPATH=${DTC_DIR}/pylibfdt
34734f3de9SSimon Glassexport DTC=${DTC_DIR}/dtc
35ed772fe7SSimon Glass
36c9adb355SSimon Glassrun_test "binman" ./tools/binman/binman -t
37c9adb355SSimon Glassrun_test "patman" ./tools/patman/patman --test
38c9adb355SSimon Glassrun_test "buildman" ./tools/buildman/buildman -t
39*3bc11e81SSimon Glassrun_test "fdt" ./tools/dtoc/test_fdt -t
40c9adb355SSimon Glassrun_test "dtoc" ./tools/dtoc/dtoc -t
4172d8172bSSimon Glass
4230d704c6SSimon Glass# This needs you to set up Python test coverage tools.
4330d704c6SSimon Glass# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
4416d836cdSTom Rini#   $ sudo apt-get install python-pytest python-coverage
45c9adb355SSimon Glassrun_test "binman code coverage" ./tools/binman/binman -T
46c9adb355SSimon Glassrun_test "dtoc code coverage" ./tools/dtoc/dtoc -T
47c9adb355SSimon Glassrun_test "fdt code coverage" ./tools/dtoc/test_fdt -T
4830d704c6SSimon Glass
49*3bc11e81SSimon Glassif [ $failures == 0 ]; then
502f52018cSSimon Glass	echo "Tests passed!"
512f52018cSSimon Glasselse
522f52018cSSimon Glass	echo "Tests FAILED"
532f52018cSSimon Glass	exit 1
542f52018cSSimon Glassfi
55