summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-02-22 07:40:06 (GMT)
committerJason Evans <jasone@canonware.com>2017-02-23 16:57:02 (GMT)
commitde49674fbde4d124a0a7e7e97f5656e190980759 (patch)
tree9a29c6d5f569ea6098cc85663b4cb0e7bba4dc3f
parent8ac7937eb5ce011945188ef3553dbc2bcc294a25 (diff)
downloadjemalloc-de49674fbde4d124a0a7e7e97f5656e190980759.zip
jemalloc-de49674fbde4d124a0a7e7e97f5656e190980759.tar.gz
jemalloc-de49674fbde4d124a0a7e7e97f5656e190980759.tar.bz2
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.
-rw-r--r--test/integration/extent.c4
-rw-r--r--test/integration/extent.sh5
-rw-r--r--test/integration/mallocx.c4
-rw-r--r--test/integration/mallocx.sh5
-rw-r--r--test/integration/xallocx.c4
-rw-r--r--test/integration/xallocx.sh5
-rw-r--r--test/test.sh.in29
-rw-r--r--test/unit/arena_reset_prof.c1
-rw-r--r--test/unit/arena_reset_prof.sh3
-rw-r--r--test/unit/decay.c6
-rw-r--r--test/unit/decay.sh6
-rw-r--r--test/unit/junk.c8
-rw-r--r--test/unit/junk.sh5
-rw-r--r--test/unit/junk_alloc.c2
-rw-r--r--test/unit/junk_alloc.sh5
-rw-r--r--test/unit/junk_free.c2
-rw-r--r--test/unit/junk_free.sh5
-rw-r--r--test/unit/pack.c3
-rw-r--r--test/unit/pack.sh4
-rw-r--r--test/unit/prof_accum.c5
-rw-r--r--test/unit/prof_accum.sh5
-rw-r--r--test/unit/prof_active.c5
-rw-r--r--test/unit/prof_active.sh5
-rw-r--r--test/unit/prof_gdump.c4
-rw-r--r--test/unit/prof_gdump.sh6
-rw-r--r--test/unit/prof_idump.c13
-rw-r--r--test/unit/prof_idump.sh12
-rw-r--r--test/unit/prof_reset.c5
-rw-r--r--test/unit/prof_reset.sh5
-rw-r--r--test/unit/prof_tctx.c4
-rw-r--r--test/unit/prof_tctx.sh5
-rw-r--r--test/unit/prof_thread_name.c4
-rw-r--r--test/unit/prof_thread_name.sh5
-rw-r--r--test/unit/zero.c5
-rw-r--r--test/unit/zero.sh5
35 files changed, 119 insertions, 80 deletions
diff --git a/test/integration/extent.c b/test/integration/extent.c
index 08792df..32432af 100644
--- a/test/integration/extent.c
+++ b/test/integration/extent.c
@@ -1,9 +1,5 @@
#include "test/jemalloc_test.h"
-#ifdef JEMALLOC_FILL
-const char *malloc_conf = "junk:false";
-#endif
-
#include "test/extent_hooks.h"
static void
diff --git a/test/integration/extent.sh b/test/integration/extent.sh
new file mode 100644
index 0000000..0cc2187
--- /dev/null
+++ b/test/integration/extent.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="junk:false"
+fi
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index b60e27b..b0b5cda 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -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) {
unsigned ret;
diff --git a/test/integration/mallocx.sh b/test/integration/mallocx.sh
new file mode 100644
index 0000000..0cc2187
--- /dev/null
+++ b/test/integration/mallocx.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="junk:false"
+fi
diff --git a/test/integration/xallocx.c b/test/integration/xallocx.c
index c95fbf1..cd0ca04 100644
--- a/test/integration/xallocx.c
+++ b/test/integration/xallocx.c
@@ -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
diff --git a/test/integration/xallocx.sh b/test/integration/xallocx.sh
new file mode 100644
index 0000000..0cc2187
--- /dev/null
+++ b/test/integration/xallocx.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="junk:false"
+fi
diff --git a/test/test.sh.in b/test/test.sh.in
index a39f99f..f0f0f97 100644
--- a/test/test.sh.in
+++ b/test/test.sh.in
@@ -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})
diff --git a/test/unit/arena_reset_prof.c b/test/unit/arena_reset_prof.c
index 6d83c84..38d8012 100644
--- a/test/unit/arena_reset_prof.c
+++ b/test/unit/arena_reset_prof.c
@@ -1,5 +1,4 @@
#include "test/jemalloc_test.h"
#define ARENA_RESET_PROF_C_
-const char *malloc_conf = "prof:true,lg_prof_sample:0";
#include "arena_reset.c"
diff --git a/test/unit/arena_reset_prof.sh b/test/unit/arena_reset_prof.sh
new file mode 100644
index 0000000..041dc1c
--- /dev/null
+++ b/test/unit/arena_reset_prof.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+export MALLOC_CONF="prof:true,lg_prof_sample:0"
diff --git a/test/unit/decay.c b/test/unit/decay.c
index fc8fabc..9845322 100644
--- a/test/unit/decay.c
+++ b/test/unit/decay.c
@@ -1,11 +1,5 @@
#include "test/jemalloc_test.h"
-const char *malloc_conf = "decay_time:1"
-#ifdef JEMALLOC_TCACHE
- ",lg_tcache_max:0"
-#endif
- ;
-
static nstime_monotonic_t *nstime_monotonic_orig;
static nstime_update_t *nstime_update_orig;
diff --git a/test/unit/decay.sh b/test/unit/decay.sh
new file mode 100644
index 0000000..284af81
--- /dev/null
+++ b/test/unit/decay.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export MALLOC_CONF="decay_time:1"
+if [ "x${enable_tcache}" = "x1" ] ; then
+ export MALLOC_CONF="${MALLOC_CONF},lg_tcache_max:0"
+fi
diff --git a/test/unit/junk.c b/test/unit/junk.c
index 86c5108..cfa8d0f 100644
--- a/test/unit/junk.c
+++ b/test/unit/junk.c
@@ -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," JEMALLOC_TEST_JUNK_OPT;
-#endif
-
static arena_dalloc_junk_small_t *arena_dalloc_junk_small_orig;
static large_dalloc_junk_t *large_dalloc_junk_orig;
static large_dalloc_maybe_junk_t *large_dalloc_maybe_junk_orig;
diff --git a/test/unit/junk.sh b/test/unit/junk.sh
new file mode 100644
index 0000000..97cd8ca
--- /dev/null
+++ b/test/unit/junk.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="abort:false,zero:false,junk:true"
+fi
diff --git a/test/unit/junk_alloc.c b/test/unit/junk_alloc.c
index 8db3331..a442a0c 100644
--- a/test/unit/junk_alloc.c
+++ b/test/unit/junk_alloc.c
@@ -1,3 +1 @@
-#define JEMALLOC_TEST_JUNK_OPT "junk:alloc"
#include "junk.c"
-#undef JEMALLOC_TEST_JUNK_OPT
diff --git a/test/unit/junk_alloc.sh b/test/unit/junk_alloc.sh
new file mode 100644
index 0000000..e1008c2
--- /dev/null
+++ b/test/unit/junk_alloc.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="abort:false,zero:false,junk:alloc"
+fi
diff --git a/test/unit/junk_free.c b/test/unit/junk_free.c
index 482a61d..a442a0c 100644
--- a/test/unit/junk_free.c
+++ b/test/unit/junk_free.c
@@ -1,3 +1 @@
-#define JEMALLOC_TEST_JUNK_OPT "junk:free"
#include "junk.c"
-#undef JEMALLOC_TEST_JUNK_OPT
diff --git a/test/unit/junk_free.sh b/test/unit/junk_free.sh
new file mode 100644
index 0000000..402196c
--- /dev/null
+++ b/test/unit/junk_free.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="abort:false,zero:false,junk:free"
+fi
diff --git a/test/unit/pack.c b/test/unit/pack.c
index d35ac5e..5da4ae1 100644
--- a/test/unit/pack.c
+++ b/test/unit/pack.c
@@ -1,8 +1,5 @@
#include "test/jemalloc_test.h"
-/* Immediately purge to minimize fragmentation. */
-const char *malloc_conf = "decay_time:-1";
-
/*
* Size class that is a divisor of the page size, ideally 4+ regions per run.
*/
diff --git a/test/unit/pack.sh b/test/unit/pack.sh
new file mode 100644
index 0000000..de12e55
--- /dev/null
+++ b/test/unit/pack.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Immediately purge to minimize fragmentation.
+export MALLOC_CONF="decay_time:-1"
diff --git a/test/unit/prof_accum.c b/test/unit/prof_accum.c
index bcd1d88..6ccab82 100644
--- a/test/unit/prof_accum.c
+++ b/test/unit/prof_accum.c
@@ -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) {
int fd;
diff --git a/test/unit/prof_accum.sh b/test/unit/prof_accum.sh
new file mode 100644
index 0000000..b3e13fc
--- /dev/null
+++ b/test/unit/prof_accum.sh
@@ -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
diff --git a/test/unit/prof_active.c b/test/unit/prof_active.c
index c0e085a..275aac8 100644
--- a/test/unit/prof_active.c
+++ b/test/unit/prof_active.c
@@ -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) {
bool old;
diff --git a/test/unit/prof_active.sh b/test/unit/prof_active.sh
new file mode 100644
index 0000000..0167cb1
--- /dev/null
+++ b/test/unit/prof_active.sh
@@ -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
diff --git a/test/unit/prof_gdump.c b/test/unit/prof_gdump.c
index 30320b7..97ade68 100644
--- a/test/unit/prof_gdump.c
+++ b/test/unit/prof_gdump.c
@@ -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
diff --git a/test/unit/prof_gdump.sh b/test/unit/prof_gdump.sh
new file mode 100644
index 0000000..3f600d2
--- /dev/null
+++ b/test/unit/prof_gdump.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ "x${enable_prof}" = "x1" ] ; then
+ export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true"
+fi
+
diff --git a/test/unit/prof_idump.c b/test/unit/prof_idump.c
index 1fed7b3..1cc6c98 100644
--- a/test/unit/prof_idump.c
+++ b/test/unit/prof_idump.c
@@ -1,18 +1,5 @@
#include "test/jemalloc_test.h"
-const char *malloc_conf = ""
-#ifdef JEMALLOC_PROF
- "prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0"
- ",lg_prof_interval:0"
-# ifdef JEMALLOC_TCACHE
- ","
-# endif
-#endif
-#ifdef JEMALLOC_TCACHE
- "tcache:false"
-#endif
- ;
-
static bool did_prof_dump_open;
static int
diff --git a/test/unit/prof_idump.sh b/test/unit/prof_idump.sh
new file mode 100644
index 0000000..fdb5813
--- /dev/null
+++ b/test/unit/prof_idump.sh
@@ -0,0 +1,12 @@
+#!/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"
+ if [ "x${enable_tcache}" = "x1" ] ; then
+ export MALLOC_CONF="${MALLOC_CONF},tcache:false"
+ fi
+elif [ "x${enable_tcache}" = "x1" ] ; then
+ export MALLOC_CONF="tcache:false"
+fi
+
+
diff --git a/test/unit/prof_reset.c b/test/unit/prof_reset.c
index fc954f9..6120714 100644
--- a/test/unit/prof_reset.c
+++ b/test/unit/prof_reset.c
@@ -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) {
int fd;
diff --git a/test/unit/prof_reset.sh b/test/unit/prof_reset.sh
new file mode 100644
index 0000000..43c516a
--- /dev/null
+++ b/test/unit/prof_reset.sh
@@ -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
diff --git a/test/unit/prof_tctx.c b/test/unit/prof_tctx.c
index 2e35b7e..14510c6 100644
--- a/test/unit/prof_tctx.c
+++ b/test/unit/prof_tctx.c
@@ -1,9 +1,5 @@
#include "test/jemalloc_test.h"
-#ifdef JEMALLOC_PROF
-const char *malloc_conf = "prof:true,lg_prof_sample:0";
-#endif
-
TEST_BEGIN(test_prof_realloc) {
tsdn_t *tsdn;
int flags;
diff --git a/test/unit/prof_tctx.sh b/test/unit/prof_tctx.sh
new file mode 100644
index 0000000..8fcc7d8
--- /dev/null
+++ b/test/unit/prof_tctx.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_prof}" = "x1" ] ; then
+ export MALLOC_CONF="prof:true,lg_prof_sample:0"
+fi
diff --git a/test/unit/prof_thread_name.c b/test/unit/prof_thread_name.c
index a094a1c..c9c2a2b 100644
--- a/test/unit/prof_thread_name.c
+++ b/test/unit/prof_thread_name.c
@@ -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) {
diff --git a/test/unit/prof_thread_name.sh b/test/unit/prof_thread_name.sh
new file mode 100644
index 0000000..298c105
--- /dev/null
+++ b/test/unit/prof_thread_name.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_prof}" = "x1" ] ; then
+ export MALLOC_CONF="prof:true,prof_active:false"
+fi
diff --git a/test/unit/zero.c b/test/unit/zero.c
index d5b03f8..553692b 100644
--- a/test/unit/zero.c
+++ b/test/unit/zero.c
@@ -1,10 +1,5 @@
#include "test/jemalloc_test.h"
-#ifdef JEMALLOC_FILL
-const char *malloc_conf =
- "abort:false,junk:false,zero:true";
-#endif
-
static void
test_zero(size_t sz_min, size_t sz_max) {
uint8_t *s;
diff --git a/test/unit/zero.sh b/test/unit/zero.sh
new file mode 100644
index 0000000..b4540b2
--- /dev/null
+++ b/test/unit/zero.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ "x${enable_fill}" = "x1" ] ; then
+ export MALLOC_CONF="abort:false,junk:false,zero:true"
+fi