run_test_scripts.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash -eu
  2. # Copyright 2013 The Chromium OS Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Load common constants and variables.
  6. SCRIPTDIR=$(dirname $(readlink -f "$0"))
  7. . "$SCRIPTDIR/common.sh"
  8. # Mandatory arg is the directory where futility is installed.
  9. [ -z "${1:-}" ] && error "Directory argument is required"
  10. BINDIR="$1"
  11. shift
  12. FUTILITY="$BINDIR/futility"
  13. # The Makefile should export the $BUILD directory, but if it's not just warn
  14. # and guess (mostly so we can run the script manually).
  15. if [ -z "${BUILD:-}" ]; then
  16. BUILD=$(dirname "${BINDIR}")
  17. yellow "Assuming BUILD=$BUILD"
  18. fi
  19. # Same for $SRCDIR
  20. if [ -z "${SRCDIR:-}" ]; then
  21. SRCDIR=$(readlink -f "${SCRIPTDIR}/../..")
  22. yellow "Assuming SRCDIR=$SRCDIR"
  23. fi
  24. OUTDIR="${BUILD}/tests/futility_test_results"
  25. [ -d "$OUTDIR" ] || mkdir -p "$OUTDIR"
  26. # Let each test know where to find things...
  27. export BUILD
  28. export SRCDIR
  29. export FUTILITY
  30. export SCRIPTDIR
  31. export BINDIR
  32. export OUTDIR
  33. # These are the scripts to run. Binaries are invoked directly by the Makefile.
  34. TESTS="
  35. ${SCRIPTDIR}/test_bdb.sh
  36. ${SCRIPTDIR}/test_create.sh
  37. ${SCRIPTDIR}/test_dump_fmap.sh
  38. ${SCRIPTDIR}/test_gbb_utility.sh
  39. ${SCRIPTDIR}/test_load_fmap.sh
  40. ${SCRIPTDIR}/test_main.sh
  41. ${SCRIPTDIR}/test_show_contents.sh
  42. ${SCRIPTDIR}/test_show_kernel.sh
  43. ${SCRIPTDIR}/test_show_vs_verify.sh
  44. ${SCRIPTDIR}/test_show_usbpd1.sh
  45. ${SCRIPTDIR}/test_sign_firmware.sh
  46. ${SCRIPTDIR}/test_sign_fw_main.sh
  47. ${SCRIPTDIR}/test_sign_kernel.sh
  48. ${SCRIPTDIR}/test_sign_keyblocks.sh
  49. ${SCRIPTDIR}/test_sign_usbpd1.sh
  50. ${SCRIPTDIR}/test_file_types.sh
  51. "
  52. # Get ready...
  53. pass=0
  54. progs=0
  55. ##############################################################################
  56. # Invoke the scripts that test the builtin functions.
  57. # Let the test scripts use >&3 to indicate progress
  58. exec 3>&1
  59. echo "-- builtin --"
  60. for i in $TESTS; do
  61. j=${i##*/}
  62. : $(( progs++ ))
  63. echo -n "$j ... "
  64. rm -rf "${OUTDIR}/$j."*
  65. rc=$("$i" "$FUTILITY" 1>"${OUTDIR}/$j.stdout" \
  66. 2>"${OUTDIR}/$j.stderr" || echo "$?")
  67. echo "${rc:-0}" > "${OUTDIR}/$j.return"
  68. if [ ! "$rc" ]; then
  69. green "PASSED"
  70. : $(( pass++ ))
  71. rm -f ${OUTDIR}/$j.{stdout,stderr,return}
  72. else
  73. red "FAILED. Stdout is recorded in ${OUTDIR}/$j.stdout"
  74. cat ${OUTDIR}/$j.stderr
  75. fi
  76. done
  77. ##############################################################################
  78. # How'd we do?
  79. if [ "$pass" -eq "$progs" ]; then
  80. green "Success: $pass / $progs passed"
  81. exit 0
  82. fi
  83. red "FAIL: $pass / $progs passed"
  84. exit 1