summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2014-05-28 18:08:17 (GMT)
committerJason Evans <je@fb.com>2014-05-28 18:08:17 (GMT)
commit26f44df742893306a53a90328e15a62ed11b9e57 (patch)
tree709c0c8a057ef98246b650434aae8f7599e3d1d3
parentccf046659a7c83e4e1573a1df30415144b4efdb6 (diff)
downloadjemalloc-26f44df742893306a53a90328e15a62ed11b9e57.zip
jemalloc-26f44df742893306a53a90328e15a62ed11b9e57.tar.gz
jemalloc-26f44df742893306a53a90328e15a62ed11b9e57.tar.bz2
Make sure initialization occurs prior to running tests.
-rw-r--r--test/src/test.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/src/test.c b/test/src/test.c
index 3acf845..17728ca 100644
--- a/test/src/test.c
+++ b/test/src/test.c
@@ -63,9 +63,22 @@ p_test_fini(void)
test_status_t
p_test(test_t *t, ...)
{
- test_status_t ret = test_status_pass;
+ test_status_t ret;
va_list ap;
+ /*
+ * Make sure initialization occurs prior to running tests. Tests are
+ * special because they may use internal facilities prior to triggering
+ * initialization as a side effect of calling into the public API. This
+ * is a final safety that works even if jemalloc_constructor() doesn't
+ * run, as for MSVC builds.
+ */
+ if (mallctl("version", NULL, NULL, NULL, 0) != 0) {
+ malloc_printf("Initialization error");
+ return (test_status_fail);
+ }
+
+ ret = test_status_pass;
va_start(ap, t);
for (; t != NULL; t = va_arg(ap, test_t *)) {
t();