run 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Script to run all U-Boot tests that use sandbox.
  3. # $1: tests to run (empty for all, 'quick' for quick ones only)
  4. # Runs a test and checks the exit code to decide if it passed
  5. # $1: Test name
  6. # $2 onwards: command line to run
  7. run_test() {
  8. echo -n "$1: "
  9. shift
  10. "$@"
  11. [ $? -ne 0 ] && failures=$((failures+1))
  12. }
  13. # SKip slow tests if requested
  14. [ "$1" == "quick" ] && mark_expr="not slow"
  15. [ "$1" == "quick" ] && skip=--skip-net-tests
  16. [ "$1" == "tools" ] && tools_only=y
  17. failures=0
  18. if [ -z "$tools_only" ]; then
  19. # Run all tests that the standard sandbox build can support
  20. run_test "sandbox" ./test/py/test.py --bd sandbox --build \
  21. -m "${mark_expr}"
  22. fi
  23. # Run tests which require sandbox_spl
  24. run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
  25. -k 'test_ofplatdata or test_handoff or test_spl'
  26. # Run the sane tests with sandbox_noinst (i.e. without OF_PLATDATA_INST)
  27. run_test "sandbox_spl" ./test/py/test.py --bd sandbox_noinst --build \
  28. -k 'test_ofplatdata or test_handoff or test_spl'
  29. if [ -z "$tools_only" ]; then
  30. # Run tests for the flat-device-tree version of sandbox. This is a special
  31. # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
  32. # check that functionality is the same. The standard sandbox build (above) uses
  33. # CONFIG_OF_LIVE.
  34. run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree \
  35. --build -k test_ut
  36. fi
  37. # Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
  38. # provides and which is built by the sandbox_spl config. Also set up the path
  39. # to tools build by the build.
  40. DTC_DIR=build-sandbox_spl/scripts/dtc
  41. export PYTHONPATH=${DTC_DIR}/pylibfdt
  42. export DTC=${DTC_DIR}/dtc
  43. TOOLS_DIR=build-sandbox_spl/tools
  44. run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
  45. run_test "patman" ./tools/patman/patman test
  46. run_test "buildman" ./tools/buildman/buildman -t ${skip}
  47. run_test "fdt" ./tools/dtoc/test_fdt -t
  48. run_test "dtoc" ./tools/dtoc/dtoc -t
  49. # This needs you to set up Python test coverage tools.
  50. # To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
  51. # $ sudo apt-get install python-pytest python-coverage
  52. export PATH=$PATH:${TOOLS_DIR}
  53. run_test "binman code coverage" ./tools/binman/binman test -T
  54. run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
  55. run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
  56. if [ $failures == 0 ]; then
  57. echo "Tests passed!"
  58. else
  59. echo "Tests FAILED"
  60. exit 1
  61. fi