run 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. if [ -z "$tools_only" ]; then
  27. # Run tests for the flat-device-tree version of sandbox. This is a special
  28. # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
  29. # check that functionality is the same. The standard sandbox build (above) uses
  30. # CONFIG_OF_LIVE.
  31. run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree \
  32. --build -k test_ut
  33. fi
  34. # Set up a path to dtc (device-tree compiler) and libfdt.py, a library it
  35. # provides and which is built by the sandbox_spl config. Also set up the path
  36. # to tools build by the build.
  37. DTC_DIR=build-sandbox_spl/scripts/dtc
  38. export PYTHONPATH=${DTC_DIR}/pylibfdt
  39. export DTC=${DTC_DIR}/dtc
  40. TOOLS_DIR=build-sandbox_spl/tools
  41. run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
  42. run_test "patman" ./tools/patman/patman test
  43. run_test "buildman" ./tools/buildman/buildman -t ${skip}
  44. run_test "fdt" ./tools/dtoc/test_fdt -t
  45. run_test "dtoc" ./tools/dtoc/dtoc -t
  46. # This needs you to set up Python test coverage tools.
  47. # To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
  48. # $ sudo apt-get install python-pytest python-coverage
  49. export PATH=$PATH:${TOOLS_DIR}
  50. run_test "binman code coverage" ./tools/binman/binman test -T
  51. run_test "dtoc code coverage" ./tools/dtoc/dtoc -T
  52. run_test "fdt code coverage" ./tools/dtoc/test_fdt -T
  53. if [ $failures == 0 ]; then
  54. echo "Tests passed!"
  55. else
  56. echo "Tests FAILED"
  57. exit 1
  58. fi