2
0

test.sh.in 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. case @abi@ in
  3. macho)
  4. export DYLD_FALLBACK_LIBRARY_PATH="@objroot@lib"
  5. ;;
  6. pecoff)
  7. export PATH="${PATH}:@objroot@lib"
  8. ;;
  9. *)
  10. ;;
  11. esac
  12. # Make a copy of the @JEMALLOC_CPREFIX@MALLOC_CONF passed in to this script, so
  13. # it can be repeatedly concatenated with per test settings.
  14. export MALLOC_CONF_ALL=${@JEMALLOC_CPREFIX@MALLOC_CONF}
  15. # Concatenate the individual test's MALLOC_CONF and MALLOC_CONF_ALL.
  16. export_malloc_conf() {
  17. if [ "x${MALLOC_CONF}" != "x" -a "x${MALLOC_CONF_ALL}" != "x" ] ; then
  18. export @JEMALLOC_CPREFIX@MALLOC_CONF="${MALLOC_CONF},${MALLOC_CONF_ALL}"
  19. else
  20. export @JEMALLOC_CPREFIX@MALLOC_CONF="${MALLOC_CONF}${MALLOC_CONF_ALL}"
  21. fi
  22. }
  23. # Corresponds to test_status_t.
  24. pass_code=0
  25. skip_code=1
  26. fail_code=2
  27. pass_count=0
  28. skip_count=0
  29. fail_count=0
  30. for t in $@; do
  31. if [ $pass_count -ne 0 -o $skip_count -ne 0 -o $fail_count != 0 ] ; then
  32. echo
  33. fi
  34. echo "=== ${t} ==="
  35. if [ -e "@srcroot@${t}.sh" ] ; then
  36. # Source the shell script corresponding to the test in a subshell and
  37. # execute the test. This allows the shell script to set MALLOC_CONF, which
  38. # is then used to set @JEMALLOC_CPREFIX@MALLOC_CONF (thus allowing the
  39. # per test shell script to ignore the @JEMALLOC_CPREFIX@ detail).
  40. enable_fill=@enable_fill@ \
  41. enable_prof=@enable_prof@ \
  42. . @srcroot@${t}.sh && \
  43. export_malloc_conf && \
  44. $JEMALLOC_TEST_PREFIX ${t}@exe@ @abs_srcroot@ @abs_objroot@
  45. else
  46. export MALLOC_CONF= && \
  47. export_malloc_conf && \
  48. $JEMALLOC_TEST_PREFIX ${t}@exe@ @abs_srcroot@ @abs_objroot@
  49. fi
  50. result_code=$?
  51. case ${result_code} in
  52. ${pass_code})
  53. pass_count=$((pass_count+1))
  54. ;;
  55. ${skip_code})
  56. skip_count=$((skip_count+1))
  57. ;;
  58. ${fail_code})
  59. fail_count=$((fail_count+1))
  60. ;;
  61. *)
  62. echo "Test harness error: ${t} w/ MALLOC_CONF=\"${MALLOC_CONF}\"" 1>&2
  63. echo "Use prefix to debug, e.g. JEMALLOC_TEST_PREFIX=\"gdb --args\" sh test/test.sh ${t}" 1>&2
  64. exit 1
  65. esac
  66. done
  67. total_count=`expr ${pass_count} + ${skip_count} + ${fail_count}`
  68. echo
  69. echo "Test suite summary: pass: ${pass_count}/${total_count}, skip: ${skip_count}/${total_count}, fail: ${fail_count}/${total_count}"
  70. if [ ${fail_count} -eq 0 ] ; then
  71. exit 0
  72. else
  73. exit 1
  74. fi