blob: 735628e7e37027c42346d209b740abf7048312f6 [file] [log] [blame]
Simon Glass2f520182017-11-12 21:52:10 -07001#!/bin/bash
2
Simon Glassc9adb352018-10-01 21:12:38 -06003# Script to run all U-Boot tests that use sandbox.
Simon Glass499fde52018-11-18 08:14:29 -07004# $1: tests to run (empty for all, 'quick' for quick ones only)
Simon Glassc9adb352018-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 Glass2f520182017-11-12 21:52:10 -07009run_test() {
Simon Glassc9adb352018-10-01 21:12:38 -060010 echo -n "$1: "
11 shift
12 "$@"
Simon Glass3bc11e82018-10-01 21:12:39 -060013 [ $? -ne 0 ] && failures=$((failures+1))
Simon Glass2f520182017-11-12 21:52:10 -070014}
Simon Glass07f4ead2016-07-03 09:40:34 -060015
Simon Glass499fde52018-11-18 08:14:29 -070016# SKip slow tests if requested
17[ "$1" == "quick" ] && mark_expr="not slow"
Simon Glass76160802020-04-17 18:08:59 -060018[ "$1" == "quick" ] && skip=--skip-net-tests
19[ "$1" == "tools" ] && tools_only=y
Simon Glass499fde52018-11-18 08:14:29 -070020
Simon Glass3bc11e82018-10-01 21:12:39 -060021failures=0
Simon Glass73a01d92017-11-26 20:25:55 -070022
Simon Glass76160802020-04-17 18:08:59 -060023if [ -z "$tools_only" ]; then
24 # Run all tests that the standard sandbox build can support
25 run_test "sandbox" ./test/py/test.py --bd sandbox --build \
26 -m "${mark_expr}"
27fi
Simon Glass029ab152017-05-18 20:09:25 -060028
29# Run tests which require sandbox_spl
Simon Glassc9adb352018-10-01 21:12:38 -060030run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
Simon Glass7b51bf72020-10-25 20:38:32 -060031 -k 'test_ofplatdata or test_handoff or test_spl'
Simon Glass029ab152017-05-18 20:09:25 -060032
Simon Glass76160802020-04-17 18:08:59 -060033if [ -z "$tools_only" ]; then
34 # Run tests for the flat-device-tree version of sandbox. This is a special
35 # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
36 # check that functionality is the same. The standard sandbox build (above) uses
37 # CONFIG_OF_LIVE.
38 run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree \
39 --build -k test_ut
40fi
Simon Glass2f520182017-11-12 21:52:10 -070041
Simon Glass734f3de2018-10-01 21:12:37 -060042# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
Simon Glass8acce602019-07-08 13:18:50 -060043# provides and which is built by the sandbox_spl config. Also set up the path
44# to tools build by the build.
Simon Glassed772fe2017-12-24 12:12:08 -070045DTC_DIR=build-sandbox_spl/scripts/dtc
Simon Glass734f3de2018-10-01 21:12:37 -060046export PYTHONPATH=${DTC_DIR}/pylibfdt
47export DTC=${DTC_DIR}/dtc
Simon Glass8acce602019-07-08 13:18:50 -060048TOOLS_DIR=build-sandbox_spl/tools
Simon Glassed772fe2017-12-24 12:12:08 -070049
Simon Glass53cd5d92019-07-08 14:25:29 -060050run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
Simon Glass6bb74de2020-07-05 21:41:55 -060051run_test "patman" ./tools/patman/patman test
Simon Glass499fde52018-11-18 08:14:29 -070052
Simon Glass499fde52018-11-18 08:14:29 -070053run_test "buildman" ./tools/buildman/buildman -t ${skip}
Simon Glass3bc11e82018-10-01 21:12:39 -060054run_test "fdt" ./tools/dtoc/test_fdt -t
Simon Glassc9adb352018-10-01 21:12:38 -060055run_test "dtoc" ./tools/dtoc/dtoc -t
Simon Glass72d81722017-11-26 20:25:56 -070056
Simon Glass30d704c2017-11-26 20:26:01 -070057# This needs you to set up Python test coverage tools.
58# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
Tom Rini16d836c2018-07-06 10:27:14 -060059# $ sudo apt-get install python-pytest python-coverage
Simon Glass8acce602019-07-08 13:18:50 -060060export PATH=$PATH:${TOOLS_DIR}
Simon Glass53cd5d92019-07-08 14:25:29 -060061run_test "binman code coverage" ./tools/binman/binman test -T
Simon Glassc9adb352018-10-01 21:12:38 -060062run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
63run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
Simon Glass30d704c2017-11-26 20:26:01 -070064
Simon Glass3bc11e82018-10-01 21:12:39 -060065if [ $failures == 0 ]; then
Simon Glass2f520182017-11-12 21:52:10 -070066 echo "Tests passed!"
67else
68 echo "Tests FAILED"
69 exit 1
70fi