run 2.1 KB

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