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