blob: 0c8aeb5b0afd4621643730bc219c55335df70b30 [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.
Simon Glass3fcb8282018-11-18 08:14:29 -07004# $1: tests to run (empty for all, 'quick' for quick ones only)
Simon Glass6c9b0642018-10-01 21:12:38 -06005
6# Runs a test and checks the exit code to decide if it passed
7# $1: Test name
8# $2 onwards: command line to run
Simon Glass93c62052017-11-12 21:52:10 -07009run_test() {
Simon Glass6c9b0642018-10-01 21:12:38 -060010 echo -n "$1: "
11 shift
12 "$@"
Simon Glass526f55a2018-10-01 21:12:39 -060013 [ $? -ne 0 ] && failures=$((failures+1))
Simon Glass93c62052017-11-12 21:52:10 -070014}
Simon Glass8ab6cc32016-07-03 09:40:34 -060015
Simon Glass49d580c2022-08-06 17:51:55 -060016# Select test attributes
17if [ "$1" = "quick" ]; then
18 mark_expr="not slow"
19 skip=--skip-net-tests
20fi
21
Simon Glass2de5a102020-04-17 18:08:59 -060022[ "$1" == "tools" ] && tools_only=y
Simon Glass3fcb8282018-11-18 08:14:29 -070023
Simon Glass526f55a2018-10-01 21:12:39 -060024failures=0
Simon Glass2c0f8152017-11-26 20:25:55 -070025
Simon Glass2de5a102020-04-17 18:08:59 -060026if [ -z "$tools_only" ]; then
27 # Run all tests that the standard sandbox build can support
28 run_test "sandbox" ./test/py/test.py --bd sandbox --build \
Simon Glass49d580c2022-08-06 17:51:55 -060029 -k "${mark_expr}"
Simon Glass2de5a102020-04-17 18:08:59 -060030fi
Simon Glasse3c13272017-05-18 20:09:25 -060031
32# Run tests which require sandbox_spl
Simon Glass6c9b0642018-10-01 21:12:38 -060033run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
Simon Glasse43b1b52020-10-25 20:38:32 -060034 -k 'test_ofplatdata or test_handoff or test_spl'
Simon Glasse3c13272017-05-18 20:09:25 -060035
Simon Glass9deea132021-03-15 17:25:33 +130036# Run the sane tests with sandbox_noinst (i.e. without OF_PLATDATA_INST)
37run_test "sandbox_spl" ./test/py/test.py --bd sandbox_noinst --build \
38 -k 'test_ofplatdata or test_handoff or test_spl'
39
Simon Glass2de5a102020-04-17 18:08:59 -060040if [ -z "$tools_only" ]; then
41 # Run tests for the flat-device-tree version of sandbox. This is a special
42 # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
43 # check that functionality is the same. The standard sandbox build (above) uses
44 # CONFIG_OF_LIVE.
45 run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree \
46 --build -k test_ut
47fi
Simon Glass93c62052017-11-12 21:52:10 -070048
Simon Glass1935c4e2018-10-01 21:12:37 -060049# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
Simon Glasscebfab22019-07-08 13:18:50 -060050# provides and which is built by the sandbox_spl config. Also set up the path
51# to tools build by the build.
Simon Glassadef03d2017-12-24 12:12:08 -070052DTC_DIR=build-sandbox_spl/scripts/dtc
Simon Glass1935c4e2018-10-01 21:12:37 -060053export PYTHONPATH=${DTC_DIR}/pylibfdt
54export DTC=${DTC_DIR}/dtc
Simon Glasscebfab22019-07-08 13:18:50 -060055TOOLS_DIR=build-sandbox_spl/tools
Simon Glassadef03d2017-12-24 12:12:08 -070056
Simon Glassf46732a2019-07-08 14:25:29 -060057run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
Simon Glass109e84e2020-07-05 21:41:55 -060058run_test "patman" ./tools/patman/patman test
Simon Glass3fcb8282018-11-18 08:14:29 -070059
Simon Glass3fcb8282018-11-18 08:14:29 -070060run_test "buildman" ./tools/buildman/buildman -t ${skip}
Simon Glass526f55a2018-10-01 21:12:39 -060061run_test "fdt" ./tools/dtoc/test_fdt -t
Simon Glass6c9b0642018-10-01 21:12:38 -060062run_test "dtoc" ./tools/dtoc/dtoc -t
Simon Glass7465bd22017-11-26 20:25:56 -070063
Simon Glass2605acf2017-11-26 20:26:01 -070064# This needs you to set up Python test coverage tools.
65# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
Tom Rinic2a849d2018-07-06 10:27:14 -060066# $ sudo apt-get install python-pytest python-coverage
Simon Glasscebfab22019-07-08 13:18:50 -060067export PATH=$PATH:${TOOLS_DIR}
Simon Glassf46732a2019-07-08 14:25:29 -060068run_test "binman code coverage" ./tools/binman/binman test -T
Simon Glass6c9b0642018-10-01 21:12:38 -060069run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
70run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
Simon Glass2605acf2017-11-26 20:26:01 -070071
Simon Glass526f55a2018-10-01 21:12:39 -060072if [ $failures == 0 ]; then
Simon Glass93c62052017-11-12 21:52:10 -070073 echo "Tests passed!"
74else
75 echo "Tests FAILED"
76 exit 1
77fi