Refactor to support more varied testing.
Refactor the test harness to support three types of tests:
- unit: White box unit tests. These tests have full access to all
internal jemalloc library symbols. Though in actuality all symbols
are prefixed by jet_, macro-based name mangling abstracts this away
from test code.
- integration: Black box integration tests. These tests link with
the installable shared jemalloc library, and with the exception of
some utility code and configure-generated macro definitions, they have
no access to jemalloc internals.
- stress: Black box stress tests. These tests link with the installable
shared jemalloc library, as well as with an internal allocator with
symbols prefixed by jet_ (same as for unit tests) that can be used to
allocate data structures that are internal to the test code.
Move existing tests into test/{unit,integration}/ as appropriate.
Split out internal parts of jemalloc_defs.h.in and put them in
jemalloc_internal_defs.h.in. This reduces internals exposure to
applications that #include <jemalloc/jemalloc.h>.
Refactor jemalloc.h header generation so that a single header file
results, and the prototypes can be used to generate jet_ prototypes for
tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in,
jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and
use a shell script to generate a unified jemalloc.h at configure time.
Change the default private namespace prefix from "" to "je_".
Add missing private namespace mangling.
Remove hard-coded private_namespace.h. Instead generate it and
private_unnamespace.h from private_symbols.txt. Use similar logic for
public symbols, which aids in name mangling for jet_ symbols.
Add test_warn() and test_fail(). Replace existing exit(1) calls with
test_fail() calls.
2013-12-01 07:25:42 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
case @abi@ in
|
|
|
|
macho)
|
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH="@objroot@lib"
|
|
|
|
;;
|
|
|
|
pecoff)
|
|
|
|
export PATH="${PATH}:@objroot@lib"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-02-22 15:40:06 +08:00
|
|
|
# Make a copy of the @JEMALLOC_CPREFIX@MALLOC_CONF passed in to this script, so
|
|
|
|
# it can be repeatedly concatenated with per test settings.
|
|
|
|
export MALLOC_CONF_ALL=${@JEMALLOC_CPREFIX@MALLOC_CONF}
|
|
|
|
# Concatenate the individual test's MALLOC_CONF and MALLOC_CONF_ALL.
|
|
|
|
export_malloc_conf() {
|
|
|
|
if [ "x${MALLOC_CONF}" != "x" -a "x${MALLOC_CONF_ALL}" != "x" ] ; then
|
|
|
|
export @JEMALLOC_CPREFIX@MALLOC_CONF="${MALLOC_CONF},${MALLOC_CONF_ALL}"
|
|
|
|
else
|
|
|
|
export @JEMALLOC_CPREFIX@MALLOC_CONF="${MALLOC_CONF}${MALLOC_CONF_ALL}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-09 12:52:21 +08:00
|
|
|
# Corresponds to test_status_t.
|
|
|
|
pass_code=0
|
|
|
|
skip_code=1
|
|
|
|
fail_code=2
|
|
|
|
|
|
|
|
pass_count=0
|
|
|
|
skip_count=0
|
|
|
|
fail_count=0
|
Refactor to support more varied testing.
Refactor the test harness to support three types of tests:
- unit: White box unit tests. These tests have full access to all
internal jemalloc library symbols. Though in actuality all symbols
are prefixed by jet_, macro-based name mangling abstracts this away
from test code.
- integration: Black box integration tests. These tests link with
the installable shared jemalloc library, and with the exception of
some utility code and configure-generated macro definitions, they have
no access to jemalloc internals.
- stress: Black box stress tests. These tests link with the installable
shared jemalloc library, as well as with an internal allocator with
symbols prefixed by jet_ (same as for unit tests) that can be used to
allocate data structures that are internal to the test code.
Move existing tests into test/{unit,integration}/ as appropriate.
Split out internal parts of jemalloc_defs.h.in and put them in
jemalloc_internal_defs.h.in. This reduces internals exposure to
applications that #include <jemalloc/jemalloc.h>.
Refactor jemalloc.h header generation so that a single header file
results, and the prototypes can be used to generate jet_ prototypes for
tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in,
jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and
use a shell script to generate a unified jemalloc.h at configure time.
Change the default private namespace prefix from "" to "je_".
Add missing private namespace mangling.
Remove hard-coded private_namespace.h. Instead generate it and
private_unnamespace.h from private_symbols.txt. Use similar logic for
public symbols, which aids in name mangling for jet_ symbols.
Add test_warn() and test_fail(). Replace existing exit(1) calls with
test_fail() calls.
2013-12-01 07:25:42 +08:00
|
|
|
for t in $@; do
|
2013-12-13 06:58:26 +08:00
|
|
|
if [ $pass_count -ne 0 -o $skip_count -ne 0 -o $fail_count != 0 ] ; then
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
echo "=== ${t} ==="
|
2017-02-22 15:40:06 +08:00
|
|
|
if [ -e "@srcroot@${t}.sh" ] ; then
|
|
|
|
# Source the shell script corresponding to the test in a subshell and
|
|
|
|
# execute the test. This allows the shell script to set MALLOC_CONF, which
|
|
|
|
# is then used to set @JEMALLOC_CPREFIX@MALLOC_CONF (thus allowing the
|
|
|
|
# per test shell script to ignore the @JEMALLOC_CPREFIX@ detail).
|
2017-04-22 05:49:17 +08:00
|
|
|
enable_fill=@enable_fill@ \
|
|
|
|
enable_prof=@enable_prof@ \
|
|
|
|
. @srcroot@${t}.sh && \
|
|
|
|
export_malloc_conf && \
|
|
|
|
$JEMALLOC_TEST_PREFIX ${t}@exe@ @abs_srcroot@ @abs_objroot@
|
2017-02-22 15:40:06 +08:00
|
|
|
else
|
2017-04-22 05:49:17 +08:00
|
|
|
export MALLOC_CONF= && \
|
|
|
|
export_malloc_conf && \
|
|
|
|
$JEMALLOC_TEST_PREFIX ${t}@exe@ @abs_srcroot@ @abs_objroot@
|
2017-02-22 15:40:06 +08:00
|
|
|
fi
|
2013-12-09 12:52:21 +08:00
|
|
|
result_code=$?
|
|
|
|
case ${result_code} in
|
|
|
|
${pass_code})
|
|
|
|
pass_count=$((pass_count+1))
|
|
|
|
;;
|
|
|
|
${skip_code})
|
|
|
|
skip_count=$((skip_count+1))
|
|
|
|
;;
|
|
|
|
${fail_code})
|
|
|
|
fail_count=$((fail_count+1))
|
|
|
|
;;
|
|
|
|
*)
|
2017-04-22 05:49:17 +08:00
|
|
|
echo "Test harness error: ${t} w/ MALLOC_CONF=\"${MALLOC_CONF}\"" 1>&2
|
|
|
|
echo "Use prefix to debug, e.g. JEMALLOC_TEST_PREFIX=\"gdb --args\" sh test/test.sh ${t}" 1>&2
|
2013-12-09 12:52:21 +08:00
|
|
|
exit 1
|
|
|
|
esac
|
Refactor to support more varied testing.
Refactor the test harness to support three types of tests:
- unit: White box unit tests. These tests have full access to all
internal jemalloc library symbols. Though in actuality all symbols
are prefixed by jet_, macro-based name mangling abstracts this away
from test code.
- integration: Black box integration tests. These tests link with
the installable shared jemalloc library, and with the exception of
some utility code and configure-generated macro definitions, they have
no access to jemalloc internals.
- stress: Black box stress tests. These tests link with the installable
shared jemalloc library, as well as with an internal allocator with
symbols prefixed by jet_ (same as for unit tests) that can be used to
allocate data structures that are internal to the test code.
Move existing tests into test/{unit,integration}/ as appropriate.
Split out internal parts of jemalloc_defs.h.in and put them in
jemalloc_internal_defs.h.in. This reduces internals exposure to
applications that #include <jemalloc/jemalloc.h>.
Refactor jemalloc.h header generation so that a single header file
results, and the prototypes can be used to generate jet_ prototypes for
tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in,
jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and
use a shell script to generate a unified jemalloc.h at configure time.
Change the default private namespace prefix from "" to "je_".
Add missing private namespace mangling.
Remove hard-coded private_namespace.h. Instead generate it and
private_unnamespace.h from private_symbols.txt. Use similar logic for
public symbols, which aids in name mangling for jet_ symbols.
Add test_warn() and test_fail(). Replace existing exit(1) calls with
test_fail() calls.
2013-12-01 07:25:42 +08:00
|
|
|
done
|
2013-12-13 06:58:26 +08:00
|
|
|
|
|
|
|
total_count=`expr ${pass_count} + ${skip_count} + ${fail_count}`
|
|
|
|
echo
|
|
|
|
echo "Test suite summary: pass: ${pass_count}/${total_count}, skip: ${skip_count}/${total_count}, fail: ${fail_count}/${total_count}"
|
2013-12-09 12:52:21 +08:00
|
|
|
|
|
|
|
if [ ${fail_count} -eq 0 ] ; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|