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