blob: fb8ff5da0cbbca9c2836f6c6f0e1de036756c12e [file] [log] [blame]
Simon Glass93c62052017-11-12 21:52:10 -07001#!/bin/bash
2
Simon Glass6c9b0642018-10-01 21:12:38 -06003# Script to run all U-Boot tests that use sandbox.
4
5# Runs a test and checks the exit code to decide if it passed
6# $1: Test name
7# $2 onwards: command line to run
Simon Glass93c62052017-11-12 21:52:10 -07008run_test() {
Simon Glass6c9b0642018-10-01 21:12:38 -06009 echo -n "$1: "
10 shift
11 "$@"
Simon Glass526f55a2018-10-01 21:12:39 -060012 [ $? -ne 0 ] && failures=$((failures+1))
Simon Glass93c62052017-11-12 21:52:10 -070013}
Simon Glass8ab6cc32016-07-03 09:40:34 -060014
Simon Glass526f55a2018-10-01 21:12:39 -060015failures=0
Simon Glass2c0f8152017-11-26 20:25:55 -070016
Simon Glasse3c13272017-05-18 20:09:25 -060017# Run all tests that the standard sandbox build can support
Simon Glass6c9b0642018-10-01 21:12:38 -060018run_test "sandbox" ./test/py/test.py --bd sandbox --build
Simon Glasse3c13272017-05-18 20:09:25 -060019
20# Run tests which require sandbox_spl
Simon Glass6c9b0642018-10-01 21:12:38 -060021run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
22 -k test_ofplatdata.py
Simon Glasse3c13272017-05-18 20:09:25 -060023
Simon Glass526f55a2018-10-01 21:12:39 -060024# Run tests for the flat-device-tree version of sandbox. This is a special
25# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
26# check that functionality is the same. The standard sandbox build (above) uses
27# CONFIG_OF_LIVE.
Simon Glass3e6fbf52018-10-01 21:12:46 -060028run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \
29 -k test_ut
Simon Glass93c62052017-11-12 21:52:10 -070030
Simon Glass1935c4e2018-10-01 21:12:37 -060031# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
32# provides and which is built by the sandbox_spl config.
Simon Glassadef03d2017-12-24 12:12:08 -070033DTC_DIR=build-sandbox_spl/scripts/dtc
Simon Glass1935c4e2018-10-01 21:12:37 -060034export PYTHONPATH=${DTC_DIR}/pylibfdt
35export DTC=${DTC_DIR}/dtc
Simon Glassadef03d2017-12-24 12:12:08 -070036
Simon Glass6c9b0642018-10-01 21:12:38 -060037run_test "binman" ./tools/binman/binman -t
38run_test "patman" ./tools/patman/patman --test
39run_test "buildman" ./tools/buildman/buildman -t
Simon Glass526f55a2018-10-01 21:12:39 -060040run_test "fdt" ./tools/dtoc/test_fdt -t
Simon Glass6c9b0642018-10-01 21:12:38 -060041run_test "dtoc" ./tools/dtoc/dtoc -t
Simon Glass7465bd22017-11-26 20:25:56 -070042
Simon Glass2605acf2017-11-26 20:26:01 -070043# This needs you to set up Python test coverage tools.
44# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
Tom Rinic2a849d2018-07-06 10:27:14 -060045# $ sudo apt-get install python-pytest python-coverage
Simon Glass6c9b0642018-10-01 21:12:38 -060046run_test "binman code coverage" ./tools/binman/binman -T
47run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
48run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
Simon Glass2605acf2017-11-26 20:26:01 -070049
Simon Glass526f55a2018-10-01 21:12:39 -060050if [ $failures == 0 ]; then
Simon Glass93c62052017-11-12 21:52:10 -070051 echo "Tests passed!"
52else
53 echo "Tests FAILED"
54 exit 1
55fi