Use MALLOC_CONF rather than malloc_conf for tests.
malloc_conf does not reliably work with MSVC, which complains of "inconsistent dll linkage", i.e. its inability to support the application overriding malloc_conf when dynamically linking/loading. Work around this limitation by adding test harness support for per test shell script sourcing, and converting all tests to use MALLOC_CONF instead of malloc_conf.
This commit is contained in:
parent
3ecc3c8486
commit
e85e588e45
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
const char *malloc_conf = "junk:false";
|
||||
#endif
|
||||
|
||||
static chunk_hooks_t orig_hooks;
|
||||
static chunk_hooks_t old_hooks;
|
||||
|
||||
|
5
test/integration/chunk.sh
Normal file
5
test/integration/chunk.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="junk:false"
|
||||
fi
|
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
const char *malloc_conf = "junk:false";
|
||||
#endif
|
||||
|
||||
static unsigned
|
||||
get_nsizes_impl(const char *cmd)
|
||||
{
|
||||
|
5
test/integration/mallocx.sh
Normal file
5
test/integration/mallocx.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="junk:false"
|
||||
fi
|
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
const char *malloc_conf = "junk:false";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use a separate arena for xallocx() extension/contraction tests so that
|
||||
* internal allocation e.g. by heap profiling can't interpose allocations where
|
||||
|
5
test/integration/xallocx.sh
Normal file
5
test/integration/xallocx.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="junk:false"
|
||||
fi
|
@ -11,6 +11,18 @@ case @abi@ in
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# Corresponds to test_status_t.
|
||||
pass_code=0
|
||||
skip_code=1
|
||||
@ -24,7 +36,22 @@ for t in $@; do
|
||||
echo
|
||||
fi
|
||||
echo "=== ${t} ==="
|
||||
${t}@exe@ @abs_srcroot@ @abs_objroot@
|
||||
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).
|
||||
$(enable_fill=@enable_fill@ \
|
||||
enable_prof=@enable_prof@ \
|
||||
enable_tcache=@enable_tcache@ \
|
||||
. @srcroot@${t}.sh && \
|
||||
export_malloc_conf && \
|
||||
${t}@exe@ @abs_srcroot@ @abs_objroot@)
|
||||
else
|
||||
$(export MALLOC_CONF= && \
|
||||
export_malloc_conf &&
|
||||
${t}@exe@ @abs_srcroot@ @abs_objroot@)
|
||||
fi
|
||||
result_code=$?
|
||||
case ${result_code} in
|
||||
${pass_code})
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf = "prof:true,lg_prof_sample:0";
|
||||
#endif
|
||||
|
||||
static unsigned
|
||||
get_nsizes_impl(const char *cmd)
|
||||
{
|
||||
|
5
test/unit/arena_reset.sh
Normal file
5
test/unit/arena_reset.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,lg_prof_sample:0"
|
||||
fi
|
@ -1,7 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
const char *malloc_conf = "purge:decay,decay_time:1";
|
||||
|
||||
static nstime_monotonic_t *nstime_monotonic_orig;
|
||||
static nstime_update_t *nstime_update_orig;
|
||||
|
||||
|
3
test/unit/decay.sh
Normal file
3
test/unit/decay.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
export MALLOC_CONF="purge:decay,decay_time:1"
|
@ -1,13 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
# ifndef JEMALLOC_TEST_JUNK_OPT
|
||||
# define JEMALLOC_TEST_JUNK_OPT "junk:true"
|
||||
# endif
|
||||
const char *malloc_conf =
|
||||
"abort:false,zero:false,redzone:true,quarantine:0," JEMALLOC_TEST_JUNK_OPT;
|
||||
#endif
|
||||
|
||||
static arena_dalloc_junk_small_t *arena_dalloc_junk_small_orig;
|
||||
static arena_dalloc_junk_large_t *arena_dalloc_junk_large_orig;
|
||||
static huge_dalloc_junk_t *huge_dalloc_junk_orig;
|
||||
|
5
test/unit/junk.sh
Normal file
5
test/unit/junk.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="abort:false,zero:false,redzone:true,quarantine:0,junk:true"
|
||||
fi
|
@ -1,3 +1 @@
|
||||
#define JEMALLOC_TEST_JUNK_OPT "junk:alloc"
|
||||
#include "junk.c"
|
||||
#undef JEMALLOC_TEST_JUNK_OPT
|
||||
|
5
test/unit/junk_alloc.sh
Normal file
5
test/unit/junk_alloc.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="abort:false,zero:false,redzone:true,quarantine:0,junk:alloc"
|
||||
fi
|
@ -1,3 +1 @@
|
||||
#define JEMALLOC_TEST_JUNK_OPT "junk:free"
|
||||
#include "junk.c"
|
||||
#undef JEMALLOC_TEST_JUNK_OPT
|
||||
|
5
test/unit/junk_free.sh
Normal file
5
test/unit/junk_free.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="abort:false,zero:false,redzone:true,quarantine:0,junk:free"
|
||||
fi
|
@ -1,12 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
/*
|
||||
* Make sure that opt.lg_chunk clamping is sufficient. In practice, this test
|
||||
* program will fail a debug assertion during initialization and abort (rather
|
||||
* than the test soft-failing) if clamping is insufficient.
|
||||
*/
|
||||
const char *malloc_conf = "lg_chunk:0";
|
||||
|
||||
TEST_BEGIN(test_lg_chunk_clamp)
|
||||
{
|
||||
void *p;
|
||||
|
6
test/unit/lg_chunk.sh
Normal file
6
test/unit/lg_chunk.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Make sure that opt.lg_chunk clamping is sufficient. In practice, this test
|
||||
# program will fail a debug assertion during initialization and abort (rather
|
||||
# than the test soft-failing) if clamping is insufficient.
|
||||
export MALLOC_CONF="lg_chunk:0"
|
@ -1,13 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
const char *malloc_conf =
|
||||
/* Use smallest possible chunk size. */
|
||||
"lg_chunk:0"
|
||||
/* Immediately purge to minimize fragmentation. */
|
||||
",lg_dirty_mult:-1"
|
||||
",decay_time:-1"
|
||||
;
|
||||
|
||||
/*
|
||||
* Size class that is a divisor of the page size, ideally 4+ regions per run.
|
||||
*/
|
||||
|
5
test/unit/pack.sh
Normal file
5
test/unit/pack.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Use smallest possible chunk size. Immediately purge to minimize
|
||||
# fragmentation.
|
||||
export MALLOC_CONF="lg_chunk:0,lg_dirty_mult:-1,decay_time:-1"
|
@ -5,11 +5,6 @@
|
||||
#define DUMP_INTERVAL 1
|
||||
#define BT_COUNT_CHECK_INTERVAL 5
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf =
|
||||
"prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0";
|
||||
#endif
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
|
5
test/unit/prof_accum.sh
Normal file
5
test/unit/prof_accum.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0"
|
||||
fi
|
@ -1,10 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf =
|
||||
"prof:true,prof_thread_active_init:false,lg_prof_sample:0";
|
||||
#endif
|
||||
|
||||
static void
|
||||
mallctl_bool_get(const char *name, bool expected, const char *func, int line)
|
||||
{
|
||||
|
5
test/unit/prof_active.sh
Normal file
5
test/unit/prof_active.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_thread_active_init:false,lg_prof_sample:0"
|
||||
fi
|
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf = "prof:true,prof_active:false,prof_gdump:true";
|
||||
#endif
|
||||
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
|
6
test/unit/prof_gdump.sh
Normal file
6
test/unit/prof_gdump.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true"
|
||||
fi
|
||||
|
@ -1,11 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf =
|
||||
"prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,"
|
||||
"lg_prof_interval:0";
|
||||
#endif
|
||||
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
|
7
test/unit/prof_idump.sh
Normal file
7
test/unit/prof_idump.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0"
|
||||
fi
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf =
|
||||
"prof:true,prof_active:false,lg_prof_sample:0";
|
||||
#endif
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
|
5
test/unit/prof_reset.sh
Normal file
5
test/unit/prof_reset.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_active:false,lg_prof_sample:0"
|
||||
fi
|
5
test/unit/prof_tctx.sh
Normal file
5
test/unit/prof_tctx.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,lg_prof_sample:0"
|
||||
fi
|
@ -1,9 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf = "prof:true,prof_active:false";
|
||||
#endif
|
||||
|
||||
static void
|
||||
mallctl_thread_name_get_impl(const char *thread_name_expected, const char *func,
|
||||
int line)
|
||||
|
5
test/unit/prof_thread_name.sh
Normal file
5
test/unit/prof_thread_name.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_active:false"
|
||||
fi
|
@ -1,13 +1,7 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
/* Keep in sync with definition in quarantine.sh. */
|
||||
#define QUARANTINE_SIZE 8192
|
||||
#define STRINGIFY_HELPER(x) #x
|
||||
#define STRINGIFY(x) STRINGIFY_HELPER(x)
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
const char *malloc_conf = "abort:false,junk:true,redzone:true,quarantine:"
|
||||
STRINGIFY(QUARANTINE_SIZE);
|
||||
#endif
|
||||
|
||||
void
|
||||
quarantine_clear(void)
|
||||
|
8
test/unit/quarantine.sh
Normal file
8
test/unit/quarantine.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Keep in sync with definition in quarantine.c.
|
||||
export QUARANTINE_SIZE=8192
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="abort:false,junk:true,redzone:true,quarantine:${QUARANTINE_SIZE}"
|
||||
fi
|
@ -1,10 +1,5 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#ifdef JEMALLOC_FILL
|
||||
const char *malloc_conf =
|
||||
"abort:false,junk:false,zero:true,redzone:false,quarantine:0";
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_zero(size_t sz_min, size_t sz_max)
|
||||
{
|
||||
|
5
test/unit/zero.sh
Normal file
5
test/unit/zero.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_fill}" = "x1" ] ; then
|
||||
export MALLOC_CONF="abort:false,junk:false,zero:true,redzone:false,quarantine:0"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user