blob: 55a6649a9c523866f4daea467b24ecdc7ce84c0b [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"
18
Simon Glass3bc11e82018-10-01 21:12:39 -060019failures=0
Simon Glass73a01d92017-11-26 20:25:55 -070020
Simon Glass029ab152017-05-18 20:09:25 -060021# Run all tests that the standard sandbox build can support
Simon Glass499fde52018-11-18 08:14:29 -070022run_test "sandbox" ./test/py/test.py --bd sandbox --build -m "${mark_expr}"
Simon Glass029ab152017-05-18 20:09:25 -060023
24# Run tests which require sandbox_spl
Simon Glassc9adb352018-10-01 21:12:38 -060025run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
Simon Glassb0edea32018-11-15 18:44:09 -070026 -k 'test_ofplatdata or test_handoff'
Simon Glass029ab152017-05-18 20:09:25 -060027
Simon Glass3bc11e82018-10-01 21:12:39 -060028# Run tests for the flat-device-tree version of sandbox. This is a special
29# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
30# check that functionality is the same. The standard sandbox build (above) uses
31# CONFIG_OF_LIVE.
Simon Glass2673afe2018-10-01 21:12:46 -060032run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \
33 -k test_ut
Simon Glass2f520182017-11-12 21:52:10 -070034
Simon Glass734f3de2018-10-01 21:12:37 -060035# Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
36# provides and which is built by the sandbox_spl config.
Simon Glassed772fe2017-12-24 12:12:08 -070037DTC_DIR=build-sandbox_spl/scripts/dtc
Simon Glass734f3de2018-10-01 21:12:37 -060038export PYTHONPATH=${DTC_DIR}/pylibfdt
39export DTC=${DTC_DIR}/dtc
Simon Glassed772fe2017-12-24 12:12:08 -070040
Simon Glassc9adb352018-10-01 21:12:38 -060041run_test "binman" ./tools/binman/binman -t
42run_test "patman" ./tools/patman/patman --test
Simon Glass499fde52018-11-18 08:14:29 -070043
44[ "$1" == "quick" ] && skip=--skip-net-tests
45run_test "buildman" ./tools/buildman/buildman -t ${skip}
Simon Glass3bc11e82018-10-01 21:12:39 -060046run_test "fdt" ./tools/dtoc/test_fdt -t
Simon Glassc9adb352018-10-01 21:12:38 -060047run_test "dtoc" ./tools/dtoc/dtoc -t
Simon Glass72d81722017-11-26 20:25:56 -070048
Simon Glass30d704c2017-11-26 20:26:01 -070049# This needs you to set up Python test coverage tools.
50# To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
Tom Rini16d836c2018-07-06 10:27:14 -060051# $ sudo apt-get install python-pytest python-coverage
Simon Glassc9adb352018-10-01 21:12:38 -060052run_test "binman code coverage" ./tools/binman/binman -T
53run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
54run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
Simon Glass30d704c2017-11-26 20:26:01 -070055
Simon Glass3bc11e82018-10-01 21:12:39 -060056if [ $failures == 0 ]; then
Simon Glass2f520182017-11-12 21:52:10 -070057 echo "Tests passed!"
58else
59 echo "Tests FAILED"
60 exit 1
61fi