summaryrefslogtreecommitdiff
path: root/deps/jemalloc/test/include
diff options
context:
space:
mode:
Diffstat (limited to 'deps/jemalloc/test/include')
-rw-r--r--deps/jemalloc/test/include/test/arena_util.h155
-rw-r--r--deps/jemalloc/test/include/test/bench.h60
-rw-r--r--deps/jemalloc/test/include/test/bgthd.h17
-rw-r--r--deps/jemalloc/test/include/test/btalloc.h2
-rw-r--r--deps/jemalloc/test/include/test/extent_hooks.h40
-rw-r--r--deps/jemalloc/test/include/test/jemalloc_test.h.in15
-rw-r--r--deps/jemalloc/test/include/test/mq.h4
-rw-r--r--deps/jemalloc/test/include/test/nbits.h111
-rw-r--r--deps/jemalloc/test/include/test/san.h14
-rw-r--r--deps/jemalloc/test/include/test/sleep.h1
-rw-r--r--deps/jemalloc/test/include/test/test.h385
11 files changed, 707 insertions, 97 deletions
diff --git a/deps/jemalloc/test/include/test/arena_util.h b/deps/jemalloc/test/include/test/arena_util.h
new file mode 100644
index 000000000..9a41dacbd
--- /dev/null
+++ b/deps/jemalloc/test/include/test/arena_util.h
@@ -0,0 +1,155 @@
+static inline unsigned
+do_arena_create(ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms) {
+ unsigned arena_ind;
+ size_t sz = sizeof(unsigned);
+ expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
+ 0, "Unexpected mallctl() failure");
+ size_t mib[3];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+
+ expect_d_eq(mallctlnametomib("arena.0.dirty_decay_ms", mib, &miblen),
+ 0, "Unexpected mallctlnametomib() failure");
+ mib[1] = (size_t)arena_ind;
+ expect_d_eq(mallctlbymib(mib, miblen, NULL, NULL,
+ (void *)&dirty_decay_ms, sizeof(dirty_decay_ms)), 0,
+ "Unexpected mallctlbymib() failure");
+
+ expect_d_eq(mallctlnametomib("arena.0.muzzy_decay_ms", mib, &miblen),
+ 0, "Unexpected mallctlnametomib() failure");
+ mib[1] = (size_t)arena_ind;
+ expect_d_eq(mallctlbymib(mib, miblen, NULL, NULL,
+ (void *)&muzzy_decay_ms, sizeof(muzzy_decay_ms)), 0,
+ "Unexpected mallctlbymib() failure");
+
+ return arena_ind;
+}
+
+static inline void
+do_arena_destroy(unsigned arena_ind) {
+ /*
+ * For convenience, flush tcache in case there are cached items.
+ * However not assert success since the tcache may be disabled.
+ */
+ mallctl("thread.tcache.flush", NULL, NULL, NULL, 0);
+
+ size_t mib[3];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib("arena.0.destroy", mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[1] = (size_t)arena_ind;
+ expect_d_eq(mallctlbymib(mib, miblen, NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctlbymib() failure");
+}
+
+static inline void
+do_epoch(void) {
+ uint64_t epoch = 1;
+ expect_d_eq(mallctl("epoch", NULL, NULL, (void *)&epoch, sizeof(epoch)),
+ 0, "Unexpected mallctl() failure");
+}
+
+static inline void
+do_purge(unsigned arena_ind) {
+ size_t mib[3];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib("arena.0.purge", mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[1] = (size_t)arena_ind;
+ expect_d_eq(mallctlbymib(mib, miblen, NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctlbymib() failure");
+}
+
+static inline void
+do_decay(unsigned arena_ind) {
+ size_t mib[3];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib("arena.0.decay", mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[1] = (size_t)arena_ind;
+ expect_d_eq(mallctlbymib(mib, miblen, NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctlbymib() failure");
+}
+
+static inline uint64_t
+get_arena_npurge_impl(const char *mibname, unsigned arena_ind) {
+ size_t mib[4];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib(mibname, mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[2] = (size_t)arena_ind;
+ uint64_t npurge = 0;
+ size_t sz = sizeof(npurge);
+ expect_d_eq(mallctlbymib(mib, miblen, (void *)&npurge, &sz, NULL, 0),
+ config_stats ? 0 : ENOENT, "Unexpected mallctlbymib() failure");
+ return npurge;
+}
+
+static inline uint64_t
+get_arena_dirty_npurge(unsigned arena_ind) {
+ do_epoch();
+ return get_arena_npurge_impl("stats.arenas.0.dirty_npurge", arena_ind);
+}
+
+static inline uint64_t
+get_arena_dirty_purged(unsigned arena_ind) {
+ do_epoch();
+ return get_arena_npurge_impl("stats.arenas.0.dirty_purged", arena_ind);
+}
+
+static inline uint64_t
+get_arena_muzzy_npurge(unsigned arena_ind) {
+ do_epoch();
+ return get_arena_npurge_impl("stats.arenas.0.muzzy_npurge", arena_ind);
+}
+
+static inline uint64_t
+get_arena_npurge(unsigned arena_ind) {
+ do_epoch();
+ return get_arena_npurge_impl("stats.arenas.0.dirty_npurge", arena_ind) +
+ get_arena_npurge_impl("stats.arenas.0.muzzy_npurge", arena_ind);
+}
+
+static inline size_t
+get_arena_pdirty(unsigned arena_ind) {
+ do_epoch();
+ size_t mib[4];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib("stats.arenas.0.pdirty", mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[2] = (size_t)arena_ind;
+ size_t pdirty;
+ size_t sz = sizeof(pdirty);
+ expect_d_eq(mallctlbymib(mib, miblen, (void *)&pdirty, &sz, NULL, 0), 0,
+ "Unexpected mallctlbymib() failure");
+ return pdirty;
+}
+
+static inline size_t
+get_arena_pmuzzy(unsigned arena_ind) {
+ do_epoch();
+ size_t mib[4];
+ size_t miblen = sizeof(mib)/sizeof(size_t);
+ expect_d_eq(mallctlnametomib("stats.arenas.0.pmuzzy", mib, &miblen), 0,
+ "Unexpected mallctlnametomib() failure");
+ mib[2] = (size_t)arena_ind;
+ size_t pmuzzy;
+ size_t sz = sizeof(pmuzzy);
+ expect_d_eq(mallctlbymib(mib, miblen, (void *)&pmuzzy, &sz, NULL, 0), 0,
+ "Unexpected mallctlbymib() failure");
+ return pmuzzy;
+}
+
+static inline void *
+do_mallocx(size_t size, int flags) {
+ void *p = mallocx(size, flags);
+ expect_ptr_not_null(p, "Unexpected mallocx() failure");
+ return p;
+}
+
+static inline void
+generate_dirty(unsigned arena_ind, size_t size) {
+ int flags = MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE;
+ void *p = do_mallocx(size, flags);
+ dallocx(p, flags);
+}
+
diff --git a/deps/jemalloc/test/include/test/bench.h b/deps/jemalloc/test/include/test/bench.h
new file mode 100644
index 000000000..0397c9487
--- /dev/null
+++ b/deps/jemalloc/test/include/test/bench.h
@@ -0,0 +1,60 @@
+static inline void
+time_func(timedelta_t *timer, uint64_t nwarmup, uint64_t niter,
+ void (*func)(void)) {
+ uint64_t i;
+
+ for (i = 0; i < nwarmup; i++) {
+ func();
+ }
+ timer_start(timer);
+ for (i = 0; i < niter; i++) {
+ func();
+ }
+ timer_stop(timer);
+}
+
+#define FMT_NSECS_BUF_SIZE 100
+/* Print nanoseconds / iter into the buffer "buf". */
+static inline void
+fmt_nsecs(uint64_t usec, uint64_t iters, char *buf) {
+ uint64_t nsec = usec * 1000;
+ /* We'll display 3 digits after the decimal point. */
+ uint64_t nsec1000 = nsec * 1000;
+ uint64_t nsecs_per_iter1000 = nsec1000 / iters;
+ uint64_t intpart = nsecs_per_iter1000 / 1000;
+ uint64_t fracpart = nsecs_per_iter1000 % 1000;
+ malloc_snprintf(buf, FMT_NSECS_BUF_SIZE, "%"FMTu64".%03"FMTu64, intpart,
+ fracpart);
+}
+
+static inline void
+compare_funcs(uint64_t nwarmup, uint64_t niter, const char *name_a,
+ void (*func_a), const char *name_b, void (*func_b)) {
+ timedelta_t timer_a, timer_b;
+ char ratio_buf[6];
+ void *p;
+
+ p = mallocx(1, 0);
+ if (p == NULL) {
+ test_fail("Unexpected mallocx() failure");
+ return;
+ }
+
+ time_func(&timer_a, nwarmup, niter, func_a);
+ time_func(&timer_b, nwarmup, niter, func_b);
+
+ uint64_t usec_a = timer_usec(&timer_a);
+ char buf_a[FMT_NSECS_BUF_SIZE];
+ fmt_nsecs(usec_a, niter, buf_a);
+
+ uint64_t usec_b = timer_usec(&timer_b);
+ char buf_b[FMT_NSECS_BUF_SIZE];
+ fmt_nsecs(usec_b, niter, buf_b);
+
+ timer_ratio(&timer_a, &timer_b, ratio_buf, sizeof(ratio_buf));
+ malloc_printf("%"FMTu64" iterations, %s=%"FMTu64"us (%s ns/iter), "
+ "%s=%"FMTu64"us (%s ns/iter), ratio=1:%s\n",
+ niter, name_a, usec_a, buf_a, name_b, usec_b, buf_b, ratio_buf);
+
+ dallocx(p, 0);
+}
diff --git a/deps/jemalloc/test/include/test/bgthd.h b/deps/jemalloc/test/include/test/bgthd.h
new file mode 100644
index 000000000..4fa2395e5
--- /dev/null
+++ b/deps/jemalloc/test/include/test/bgthd.h
@@ -0,0 +1,17 @@
+/*
+ * Shared utility for checking if background_thread is enabled, which affects
+ * the purging behavior and assumptions in some tests.
+ */
+
+static inline bool
+is_background_thread_enabled(void) {
+ bool enabled;
+ size_t sz = sizeof(bool);
+ int ret = mallctl("background_thread", (void *)&enabled, &sz, NULL,0);
+ if (ret == ENOENT) {
+ return false;
+ }
+ assert_d_eq(ret, 0, "Unexpected mallctl error");
+
+ return enabled;
+}
diff --git a/deps/jemalloc/test/include/test/btalloc.h b/deps/jemalloc/test/include/test/btalloc.h
index 5877ea77e..8f3459936 100644
--- a/deps/jemalloc/test/include/test/btalloc.h
+++ b/deps/jemalloc/test/include/test/btalloc.h
@@ -25,6 +25,6 @@ btalloc_##n(size_t size, unsigned bits) { \
} \
} \
/* Intentionally sabotage tail call optimization. */ \
- assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
+ expect_ptr_not_null(p, "Unexpected mallocx() failure"); \
return p; \
}
diff --git a/deps/jemalloc/test/include/test/extent_hooks.h b/deps/jemalloc/test/include/test/extent_hooks.h
index 1f0620154..aad0a46c4 100644
--- a/deps/jemalloc/test/include/test/extent_hooks.h
+++ b/deps/jemalloc/test/include/test/extent_hooks.h
@@ -86,9 +86,9 @@ extent_alloc_hook(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
"*zero=%s, *commit=%s, arena_ind=%u)\n", __func__, extent_hooks,
new_addr, size, alignment, *zero ? "true" : "false", *commit ?
"true" : "false", arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->alloc, extent_alloc_hook,
+ expect_ptr_eq(extent_hooks->alloc, extent_alloc_hook,
"Wrong hook function");
called_alloc = true;
if (!try_alloc) {
@@ -108,9 +108,9 @@ extent_dalloc_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, committed=%s, "
"arena_ind=%u)\n", __func__, extent_hooks, addr, size, committed ?
"true" : "false", arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->dalloc, extent_dalloc_hook,
+ expect_ptr_eq(extent_hooks->dalloc, extent_dalloc_hook,
"Wrong hook function");
called_dalloc = true;
if (!try_dalloc) {
@@ -127,9 +127,9 @@ extent_destroy_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, committed=%s, "
"arena_ind=%u)\n", __func__, extent_hooks, addr, size, committed ?
"true" : "false", arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->destroy, extent_destroy_hook,
+ expect_ptr_eq(extent_hooks->destroy, extent_destroy_hook,
"Wrong hook function");
called_destroy = true;
if (!try_destroy) {
@@ -147,9 +147,9 @@ extent_commit_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
"length=%zu, arena_ind=%u)\n", __func__, extent_hooks, addr, size,
offset, length, arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->commit, extent_commit_hook,
+ expect_ptr_eq(extent_hooks->commit, extent_commit_hook,
"Wrong hook function");
called_commit = true;
if (!try_commit) {
@@ -169,9 +169,9 @@ extent_decommit_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
"length=%zu, arena_ind=%u)\n", __func__, extent_hooks, addr, size,
offset, length, arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->decommit, extent_decommit_hook,
+ expect_ptr_eq(extent_hooks->decommit, extent_decommit_hook,
"Wrong hook function");
called_decommit = true;
if (!try_decommit) {
@@ -191,9 +191,9 @@ extent_purge_lazy_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
"length=%zu arena_ind=%u)\n", __func__, extent_hooks, addr, size,
offset, length, arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->purge_lazy, extent_purge_lazy_hook,
+ expect_ptr_eq(extent_hooks->purge_lazy, extent_purge_lazy_hook,
"Wrong hook function");
called_purge_lazy = true;
if (!try_purge_lazy) {
@@ -214,9 +214,9 @@ extent_purge_forced_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
"length=%zu arena_ind=%u)\n", __func__, extent_hooks, addr, size,
offset, length, arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->purge_forced, extent_purge_forced_hook,
+ expect_ptr_eq(extent_hooks->purge_forced, extent_purge_forced_hook,
"Wrong hook function");
called_purge_forced = true;
if (!try_purge_forced) {
@@ -238,9 +238,9 @@ extent_split_hook(extent_hooks_t *extent_hooks, void *addr, size_t size,
"size_b=%zu, committed=%s, arena_ind=%u)\n", __func__, extent_hooks,
addr, size, size_a, size_b, committed ? "true" : "false",
arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->split, extent_split_hook,
+ expect_ptr_eq(extent_hooks->split, extent_split_hook,
"Wrong hook function");
called_split = true;
if (!try_split) {
@@ -262,11 +262,11 @@ extent_merge_hook(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
"size_b=%zu, committed=%s, arena_ind=%u)\n", __func__, extent_hooks,
addr_a, size_a, addr_b, size_b, committed ? "true" : "false",
arena_ind);
- assert_ptr_eq(extent_hooks, &hooks,
+ expect_ptr_eq(extent_hooks, &hooks,
"extent_hooks should be same as pointer used to set hooks");
- assert_ptr_eq(extent_hooks->merge, extent_merge_hook,
+ expect_ptr_eq(extent_hooks->merge, extent_merge_hook,
"Wrong hook function");
- assert_ptr_eq((void *)((uintptr_t)addr_a + size_a), addr_b,
+ expect_ptr_eq((void *)((uintptr_t)addr_a + size_a), addr_b,
"Extents not mergeable");
called_merge = true;
if (!try_merge) {
@@ -284,6 +284,6 @@ extent_hooks_prep(void) {
size_t sz;
sz = sizeof(default_hooks);
- assert_d_eq(mallctl("arena.0.extent_hooks", (void *)&default_hooks, &sz,
+ expect_d_eq(mallctl("arena.0.extent_hooks", (void *)&default_hooks, &sz,
NULL, 0), 0, "Unexpected mallctl() error");
}
diff --git a/deps/jemalloc/test/include/test/jemalloc_test.h.in b/deps/jemalloc/test/include/test/jemalloc_test.h.in
index c46af5d9b..3f8c0da7f 100644
--- a/deps/jemalloc/test/include/test/jemalloc_test.h.in
+++ b/deps/jemalloc/test/include/test/jemalloc_test.h.in
@@ -38,9 +38,9 @@ extern "C" {
/******************************************************************************/
/*
- * For unit tests, expose all public and private interfaces.
+ * For unit tests and analytics tests, expose all public and private interfaces.
*/
-#ifdef JEMALLOC_UNIT_TEST
+#if defined(JEMALLOC_UNIT_TEST) || defined (JEMALLOC_ANALYZE_TEST)
# define JEMALLOC_JET
# define JEMALLOC_MANGLE
# include "jemalloc/internal/jemalloc_preamble.h"
@@ -124,12 +124,19 @@ static const bool config_debug =
#include "test/math.h"
#include "test/mtx.h"
#include "test/mq.h"
+#include "test/sleep.h"
#include "test/test.h"
#include "test/timer.h"
#include "test/thd.h"
+#include "test/bgthd.h"
#define MEXP 19937
#include "test/SFMT.h"
+#ifndef JEMALLOC_HAVE_MALLOC_SIZE
+#define TEST_MALLOC_SIZE malloc_usable_size
+#else
+#define TEST_MALLOC_SIZE malloc_size
+#endif
/******************************************************************************/
/*
* Define always-enabled assertion macros, so that test assertions execute even
@@ -138,7 +145,7 @@ static const bool config_debug =
#undef assert
#undef not_reached
#undef not_implemented
-#undef assert_not_implemented
+#undef expect_not_implemented
#define assert(e) do { \
if (!(e)) { \
@@ -162,7 +169,7 @@ static const bool config_debug =
abort(); \
} while (0)
-#define assert_not_implemented(e) do { \
+#define expect_not_implemented(e) do { \
if (!(e)) { \
not_implemented(); \
} \
diff --git a/deps/jemalloc/test/include/test/mq.h b/deps/jemalloc/test/include/test/mq.h
index af2c078da..5dc6486c7 100644
--- a/deps/jemalloc/test/include/test/mq.h
+++ b/deps/jemalloc/test/include/test/mq.h
@@ -1,4 +1,4 @@
-void mq_nanosleep(unsigned ns);
+#include "test/sleep.h"
/*
* Simple templated message queue implementation that relies on only mutexes for
@@ -82,7 +82,7 @@ a_prefix##get(a_mq_type *mq) { \
\
ns = 1; \
while (true) { \
- mq_nanosleep(ns); \
+ sleep_ns(ns); \
msg = a_prefix##tryget(mq); \
if (msg != NULL) { \
return msg; \
diff --git a/deps/jemalloc/test/include/test/nbits.h b/deps/jemalloc/test/include/test/nbits.h
new file mode 100644
index 000000000..c06cf1b4a
--- /dev/null
+++ b/deps/jemalloc/test/include/test/nbits.h
@@ -0,0 +1,111 @@
+#ifndef TEST_NBITS_H
+#define TEST_NBITS_H
+
+/* Interesting bitmap counts to test. */
+
+#define NBITS_TAB \
+ NB( 1) \
+ NB( 2) \
+ NB( 3) \
+ NB( 4) \
+ NB( 5) \
+ NB( 6) \
+ NB( 7) \
+ NB( 8) \
+ NB( 9) \
+ NB(10) \
+ NB(11) \
+ NB(12) \
+ NB(13) \
+ NB(14) \
+ NB(15) \
+ NB(16) \
+ NB(17) \
+ NB(18) \
+ NB(19) \
+ NB(20) \
+ NB(21) \
+ NB(22) \
+ NB(23) \
+ NB(24) \
+ NB(25) \
+ NB(26) \
+ NB(27) \
+ NB(28) \
+ NB(29) \
+ NB(30) \
+ NB(31) \
+ NB(32) \
+ \
+ NB(33) \
+ NB(34) \
+ NB(35) \
+ NB(36) \
+ NB(37) \
+ NB(38) \
+ NB(39) \
+ NB(40) \
+ NB(41) \
+ NB(42) \
+ NB(43) \
+ NB(44) \
+ NB(45) \
+ NB(46) \
+ NB(47) \
+ NB(48) \
+ NB(49) \
+ NB(50) \
+ NB(51) \
+ NB(52) \
+ NB(53) \
+ NB(54) \
+ NB(55) \
+ NB(56) \
+ NB(57) \
+ NB(58) \
+ NB(59) \
+ NB(60) \
+ NB(61) \
+ NB(62) \
+ NB(63) \
+ NB(64) \
+ NB(65) \
+ NB(66) \
+ NB(67) \
+ \
+ NB(126) \
+ NB(127) \
+ NB(128) \
+ NB(129) \
+ NB(130) \
+ \
+ NB(254) \
+ NB(255) \
+ NB(256) \
+ NB(257) \
+ NB(258) \
+ \
+ NB(510) \
+ NB(511) \
+ NB(512) \
+ NB(513) \
+ NB(514) \
+ \
+ NB(1022) \
+ NB(1023) \
+ NB(1024) \
+ NB(1025) \
+ NB(1026) \
+ \
+ NB(2048) \
+ \
+ NB(4094) \
+ NB(4095) \
+ NB(4096) \
+ NB(4097) \
+ NB(4098) \
+ \
+ NB(8192) \
+ NB(16384)
+
+#endif /* TEST_NBITS_H */
diff --git a/deps/jemalloc/test/include/test/san.h b/deps/jemalloc/test/include/test/san.h
new file mode 100644
index 000000000..da07865ce
--- /dev/null
+++ b/deps/jemalloc/test/include/test/san.h
@@ -0,0 +1,14 @@
+#if defined(JEMALLOC_UAF_DETECTION) || defined(JEMALLOC_DEBUG)
+# define TEST_SAN_UAF_ALIGN_ENABLE "lg_san_uaf_align:12"
+# define TEST_SAN_UAF_ALIGN_DISABLE "lg_san_uaf_align:-1"
+#else
+# define TEST_SAN_UAF_ALIGN_ENABLE ""
+# define TEST_SAN_UAF_ALIGN_DISABLE ""
+#endif
+
+static inline bool
+extent_is_guarded(tsdn_t *tsdn, void *ptr) {
+ edata_t *edata = emap_edata_lookup(tsdn, &arena_emap_global, ptr);
+ return edata_guarded_get(edata);
+}
+
diff --git a/deps/jemalloc/test/include/test/sleep.h b/deps/jemalloc/test/include/test/sleep.h
new file mode 100644
index 000000000..c232f6334
--- /dev/null
+++ b/deps/jemalloc/test/include/test/sleep.h
@@ -0,0 +1 @@
+void sleep_ns(unsigned ns);
diff --git a/deps/jemalloc/test/include/test/test.h b/deps/jemalloc/test/include/test/test.h
index fd0e5265d..d4b65912d 100644
--- a/deps/jemalloc/test/include/test/test.h
+++ b/deps/jemalloc/test/include/test/test.h
@@ -1,8 +1,8 @@
#define ASSERT_BUFSIZE 256
-#define assert_cmp(t, a, b, cmp, neg_cmp, pri, ...) do { \
- t a_ = (a); \
- t b_ = (b); \
+#define verify_cmp(may_abort, t, a, b, cmp, neg_cmp, pri, ...) do { \
+ const t a_ = (a); \
+ const t b_ = (b); \
if (!(a_ cmp b_)) { \
char prefix[ASSERT_BUFSIZE]; \
char message[ASSERT_BUFSIZE]; \
@@ -13,10 +13,316 @@
__func__, __FILE__, __LINE__, \
#a, #b, a_, b_); \
malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
+ p_test_fail(prefix, message); \
+ } \
+ } \
+} while (0)
+
+#define expect_cmp(t, a, b, cmp, neg_cmp, pri, ...) verify_cmp(false, \
+ t, a, b, cmp, neg_cmp, pri, __VA_ARGS__)
+
+#define expect_ptr_eq(a, b, ...) expect_cmp(void *, a, b, ==, \
+ !=, "p", __VA_ARGS__)
+#define expect_ptr_ne(a, b, ...) expect_cmp(void *, a, b, !=, \
+ ==, "p", __VA_ARGS__)
+#define expect_ptr_null(a, ...) expect_cmp(void *, a, NULL, ==, \
+ !=, "p", __VA_ARGS__)
+#define expect_ptr_not_null(a, ...) expect_cmp(void *, a, NULL, !=, \
+ ==, "p", __VA_ARGS__)
+
+#define expect_c_eq(a, b, ...) expect_cmp(char, a, b, ==, !=, "c", __VA_ARGS__)
+#define expect_c_ne(a, b, ...) expect_cmp(char, a, b, !=, ==, "c", __VA_ARGS__)
+#define expect_c_lt(a, b, ...) expect_cmp(char, a, b, <, >=, "c", __VA_ARGS__)
+#define expect_c_le(a, b, ...) expect_cmp(char, a, b, <=, >, "c", __VA_ARGS__)
+#define expect_c_ge(a, b, ...) expect_cmp(char, a, b, >=, <, "c", __VA_ARGS__)
+#define expect_c_gt(a, b, ...) expect_cmp(char, a, b, >, <=, "c", __VA_ARGS__)
+
+#define expect_x_eq(a, b, ...) expect_cmp(int, a, b, ==, !=, "#x", __VA_ARGS__)
+#define expect_x_ne(a, b, ...) expect_cmp(int, a, b, !=, ==, "#x", __VA_ARGS__)
+#define expect_x_lt(a, b, ...) expect_cmp(int, a, b, <, >=, "#x", __VA_ARGS__)
+#define expect_x_le(a, b, ...) expect_cmp(int, a, b, <=, >, "#x", __VA_ARGS__)
+#define expect_x_ge(a, b, ...) expect_cmp(int, a, b, >=, <, "#x", __VA_ARGS__)
+#define expect_x_gt(a, b, ...) expect_cmp(int, a, b, >, <=, "#x", __VA_ARGS__)
+
+#define expect_d_eq(a, b, ...) expect_cmp(int, a, b, ==, !=, "d", __VA_ARGS__)
+#define expect_d_ne(a, b, ...) expect_cmp(int, a, b, !=, ==, "d", __VA_ARGS__)
+#define expect_d_lt(a, b, ...) expect_cmp(int, a, b, <, >=, "d", __VA_ARGS__)
+#define expect_d_le(a, b, ...) expect_cmp(int, a, b, <=, >, "d", __VA_ARGS__)
+#define expect_d_ge(a, b, ...) expect_cmp(int, a, b, >=, <, "d", __VA_ARGS__)
+#define expect_d_gt(a, b, ...) expect_cmp(int, a, b, >, <=, "d", __VA_ARGS__)
+
+#define expect_u_eq(a, b, ...) expect_cmp(int, a, b, ==, !=, "u", __VA_ARGS__)
+#define expect_u_ne(a, b, ...) expect_cmp(int, a, b, !=, ==, "u", __VA_ARGS__)
+#define expect_u_lt(a, b, ...) expect_cmp(int, a, b, <, >=, "u", __VA_ARGS__)
+#define expect_u_le(a, b, ...) expect_cmp(int, a, b, <=, >, "u", __VA_ARGS__)
+#define expect_u_ge(a, b, ...) expect_cmp(int, a, b, >=, <, "u", __VA_ARGS__)
+#define expect_u_gt(a, b, ...) expect_cmp(int, a, b, >, <=, "u", __VA_ARGS__)
+
+#define expect_ld_eq(a, b, ...) expect_cmp(long, a, b, ==, \
+ !=, "ld", __VA_ARGS__)
+#define expect_ld_ne(a, b, ...) expect_cmp(long, a, b, !=, \
+ ==, "ld", __VA_ARGS__)
+#define expect_ld_lt(a, b, ...) expect_cmp(long, a, b, <, \
+ >=, "ld", __VA_ARGS__)
+#define expect_ld_le(a, b, ...) expect_cmp(long, a, b, <=, \
+ >, "ld", __VA_ARGS__)
+#define expect_ld_ge(a, b, ...) expect_cmp(long, a, b, >=, \
+ <, "ld", __VA_ARGS__)
+#define expect_ld_gt(a, b, ...) expect_cmp(long, a, b, >, \
+ <=, "ld", __VA_ARGS__)
+
+#define expect_lu_eq(a, b, ...) expect_cmp(unsigned long, \
+ a, b, ==, !=, "lu", __VA_ARGS__)
+#define expect_lu_ne(a, b, ...) expect_cmp(unsigned long, \
+ a, b, !=, ==, "lu", __VA_ARGS__)
+#define expect_lu_lt(a, b, ...) expect_cmp(unsigned long, \
+ a, b, <, >=, "lu", __VA_ARGS__)
+#define expect_lu_le(a, b, ...) expect_cmp(unsigned long, \
+ a, b, <=, >, "lu", __VA_ARGS__)
+#define expect_lu_ge(a, b, ...) expect_cmp(unsigned long, \
+ a, b, >=, <, "lu", __VA_ARGS__)
+#define expect_lu_gt(a, b, ...) expect_cmp(unsigned long, \
+ a, b, >, <=, "lu", __VA_ARGS__)
+
+#define expect_qd_eq(a, b, ...) expect_cmp(long long, a, b, ==, \
+ !=, "qd", __VA_ARGS__)
+#define expect_qd_ne(a, b, ...) expect_cmp(long long, a, b, !=, \
+ ==, "qd", __VA_ARGS__)
+#define expect_qd_lt(a, b, ...) expect_cmp(long long, a, b, <, \
+ >=, "qd", __VA_ARGS__)
+#define expect_qd_le(a, b, ...) expect_cmp(long long, a, b, <=, \
+ >, "qd", __VA_ARGS__)
+#define expect_qd_ge(a, b, ...) expect_cmp(long long, a, b, >=, \
+ <, "qd", __VA_ARGS__)
+#define expect_qd_gt(a, b, ...) expect_cmp(long long, a, b, >, \
+ <=, "qd", __VA_ARGS__)
+
+#define expect_qu_eq(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, ==, !=, "qu", __VA_ARGS__)
+#define expect_qu_ne(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, !=, ==, "qu", __VA_ARGS__)
+#define expect_qu_lt(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, <, >=, "qu", __VA_ARGS__)
+#define expect_qu_le(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, <=, >, "qu", __VA_ARGS__)
+#define expect_qu_ge(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, >=, <, "qu", __VA_ARGS__)
+#define expect_qu_gt(a, b, ...) expect_cmp(unsigned long long, \
+ a, b, >, <=, "qu", __VA_ARGS__)
+
+#define expect_jd_eq(a, b, ...) expect_cmp(intmax_t, a, b, ==, \
+ !=, "jd", __VA_ARGS__)
+#define expect_jd_ne(a, b, ...) expect_cmp(intmax_t, a, b, !=, \
+ ==, "jd", __VA_ARGS__)
+#define expect_jd_lt(a, b, ...) expect_cmp(intmax_t, a, b, <, \
+ >=, "jd", __VA_ARGS__)
+#define expect_jd_le(a, b, ...) expect_cmp(intmax_t, a, b, <=, \
+ >, "jd", __VA_ARGS__)
+#define expect_jd_ge(a, b, ...) expect_cmp(intmax_t, a, b, >=, \
+ <, "jd", __VA_ARGS__)
+#define expect_jd_gt(a, b, ...) expect_cmp(intmax_t, a, b, >, \
+ <=, "jd", __VA_ARGS__)
+
+#define expect_ju_eq(a, b, ...) expect_cmp(uintmax_t, a, b, ==, \
+ !=, "ju", __VA_ARGS__)
+#define expect_ju_ne(a, b, ...) expect_cmp(uintmax_t, a, b, !=, \
+ ==, "ju", __VA_ARGS__)
+#define expect_ju_lt(a, b, ...) expect_cmp(uintmax_t, a, b, <, \
+ >=, "ju", __VA_ARGS__)
+#define expect_ju_le(a, b, ...) expect_cmp(uintmax_t, a, b, <=, \
+ >, "ju", __VA_ARGS__)
+#define expect_ju_ge(a, b, ...) expect_cmp(uintmax_t, a, b, >=, \
+ <, "ju", __VA_ARGS__)
+#define expect_ju_gt(a, b, ...) expect_cmp(uintmax_t, a, b, >, \
+ <=, "ju", __VA_ARGS__)
+
+#define expect_zd_eq(a, b, ...) expect_cmp(ssize_t, a, b, ==, \
+ !=, "zd", __VA_ARGS__)
+#define expect_zd_ne(a, b, ...) expect_cmp(ssize_t, a, b, !=, \
+ ==, "zd", __VA_ARGS__)
+#define expect_zd_lt(a, b, ...) expect_cmp(ssize_t, a, b, <, \
+ >=, "zd", __VA_ARGS__)
+#define expect_zd_le(a, b, ...) expect_cmp(ssize_t, a, b, <=, \
+ >, "zd", __VA_ARGS__)
+#define expect_zd_ge(a, b, ...) expect_cmp(ssize_t, a, b, >=, \
+ <, "zd", __VA_ARGS__)
+#define expect_zd_gt(a, b, ...) expect_cmp(ssize_t, a, b, >, \
+ <=, "zd", __VA_ARGS__)
+
+#define expect_zu_eq(a, b, ...) expect_cmp(size_t, a, b, ==, \
+ !=, "zu", __VA_ARGS__)
+#define expect_zu_ne(a, b, ...) expect_cmp(size_t, a, b, !=, \
+ ==, "zu", __VA_ARGS__)
+#define expect_zu_lt(a, b, ...) expect_cmp(size_t, a, b, <, \
+ >=, "zu", __VA_ARGS__)
+#define expect_zu_le(a, b, ...) expect_cmp(size_t, a, b, <=, \
+ >, "zu", __VA_ARGS__)
+#define expect_zu_ge(a, b, ...) expect_cmp(size_t, a, b, >=, \
+ <, "zu", __VA_ARGS__)
+#define expect_zu_gt(a, b, ...) expect_cmp(size_t, a, b, >, \
+ <=, "zu", __VA_ARGS__)
+
+#define expect_d32_eq(a, b, ...) expect_cmp(int32_t, a, b, ==, \
+ !=, FMTd32, __VA_ARGS__)
+#define expect_d32_ne(a, b, ...) expect_cmp(int32_t, a, b, !=, \
+ ==, FMTd32, __VA_ARGS__)
+#define expect_d32_lt(a, b, ...) expect_cmp(int32_t, a, b, <, \
+ >=, FMTd32, __VA_ARGS__)
+#define expect_d32_le(a, b, ...) expect_cmp(int32_t, a, b, <=, \
+ >, FMTd32, __VA_ARGS__)
+#define expect_d32_ge(a, b, ...) expect_cmp(int32_t, a, b, >=, \
+ <, FMTd32, __VA_ARGS__)
+#define expect_d32_gt(a, b, ...) expect_cmp(int32_t, a, b, >, \
+ <=, FMTd32, __VA_ARGS__)
+
+#define expect_u32_eq(a, b, ...) expect_cmp(uint32_t, a, b, ==, \
+ !=, FMTu32, __VA_ARGS__)
+#define expect_u32_ne(a, b, ...) expect_cmp(uint32_t, a, b, !=, \
+ ==, FMTu32, __VA_ARGS__)
+#define expect_u32_lt(a, b, ...) expect_cmp(uint32_t, a, b, <, \
+ >=, FMTu32, __VA_ARGS__)
+#define expect_u32_le(a, b, ...) expect_cmp(uint32_t, a, b, <=, \
+ >, FMTu32, __VA_ARGS__)
+#define expect_u32_ge(a, b, ...) expect_cmp(uint32_t, a, b, >=, \
+ <, FMTu32, __VA_ARGS__)
+#define expect_u32_gt(a, b, ...) expect_cmp(uint32_t, a, b, >, \
+ <=, FMTu32, __VA_ARGS__)
+
+#define expect_d64_eq(a, b, ...) expect_cmp(int64_t, a, b, ==, \
+ !=, FMTd64, __VA_ARGS__)
+#define expect_d64_ne(a, b, ...) expect_cmp(int64_t, a, b, !=, \
+ ==, FMTd64, __VA_ARGS__)
+#define expect_d64_lt(a, b, ...) expect_cmp(int64_t, a, b, <, \
+ >=, FMTd64, __VA_ARGS__)
+#define expect_d64_le(a, b, ...) expect_cmp(int64_t, a, b, <=, \
+ >, FMTd64, __VA_ARGS__)
+#define expect_d64_ge(a, b, ...) expect_cmp(int64_t, a, b, >=, \
+ <, FMTd64, __VA_ARGS__)
+#define expect_d64_gt(a, b, ...) expect_cmp(int64_t, a, b, >, \
+ <=, FMTd64, __VA_ARGS__)
+
+#define expect_u64_eq(a, b, ...) expect_cmp(uint64_t, a, b, ==, \
+ !=, FMTu64, __VA_ARGS__)
+#define expect_u64_ne(a, b, ...) expect_cmp(uint64_t, a, b, !=, \
+ ==, FMTu64, __VA_ARGS__)
+#define expect_u64_lt(a, b, ...) expect_cmp(uint64_t, a, b, <, \
+ >=, FMTu64, __VA_ARGS__)
+#define expect_u64_le(a, b, ...) expect_cmp(uint64_t, a, b, <=, \
+ >, FMTu64, __VA_ARGS__)
+#define expect_u64_ge(a, b, ...) expect_cmp(uint64_t, a, b, >=, \
+ <, FMTu64, __VA_ARGS__)
+#define expect_u64_gt(a, b, ...) expect_cmp(uint64_t, a, b, >, \
+ <=, FMTu64, __VA_ARGS__)
+
+#define verify_b_eq(may_abort, a, b, ...) do { \
+ bool a_ = (a); \
+ bool b_ = (b); \
+ if (!(a_ == b_)) { \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Failed assertion: " \
+ "(%s) == (%s) --> %s != %s: ", \
+ __func__, __FILE__, __LINE__, \
+ #a, #b, a_ ? "true" : "false", \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
+ p_test_fail(prefix, message); \
+ } \
+ } \
+} while (0)
+
+#define verify_b_ne(may_abort, a, b, ...) do { \
+ bool a_ = (a); \
+ bool b_ = (b); \
+ if (!(a_ != b_)) { \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Failed assertion: " \
+ "(%s) != (%s) --> %s == %s: ", \
+ __func__, __FILE__, __LINE__, \
+ #a, #b, a_ ? "true" : "false", \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
+ p_test_fail(prefix, message); \
+ } \
+ } \
+} while (0)
+
+#define expect_b_eq(a, b, ...) verify_b_eq(false, a, b, __VA_ARGS__)
+#define expect_b_ne(a, b, ...) verify_b_ne(false, a, b, __VA_ARGS__)
+
+#define expect_true(a, ...) expect_b_eq(a, true, __VA_ARGS__)
+#define expect_false(a, ...) expect_b_eq(a, false, __VA_ARGS__)
+
+#define verify_str_eq(may_abort, a, b, ...) do { \
+ if (strcmp((a), (b))) { \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Failed assertion: " \
+ "(%s) same as (%s) --> " \
+ "\"%s\" differs from \"%s\": ", \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
+ p_test_fail(prefix, message); \
+ } \
+ } \
+} while (0)
+
+#define verify_str_ne(may_abort, a, b, ...) do { \
+ if (!strcmp((a), (b))) { \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Failed assertion: " \
+ "(%s) differs from (%s) --> " \
+ "\"%s\" same as \"%s\": ", \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
+ p_test_fail(prefix, message); \
+ } \
+ } \
+} while (0)
+
+#define expect_str_eq(a, b, ...) verify_str_eq(false, a, b, __VA_ARGS__)
+#define expect_str_ne(a, b, ...) verify_str_ne(false, a, b, __VA_ARGS__)
+
+#define verify_not_reached(may_abort, ...) do { \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Unreachable code reached: ", \
+ __func__, __FILE__, __LINE__); \
+ malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
+ if (may_abort) { \
+ abort(); \
+ } else { \
p_test_fail(prefix, message); \
} \
} while (0)
+#define expect_not_reached(...) verify_not_reached(false, __VA_ARGS__)
+
+#define assert_cmp(t, a, b, cmp, neg_cmp, pri, ...) verify_cmp(true, \
+ t, a, b, cmp, neg_cmp, pri, __VA_ARGS__)
+
#define assert_ptr_eq(a, b, ...) assert_cmp(void *, a, b, ==, \
!=, "p", __VA_ARGS__)
#define assert_ptr_ne(a, b, ...) assert_cmp(void *, a, b, !=, \
@@ -210,77 +516,16 @@
#define assert_u64_gt(a, b, ...) assert_cmp(uint64_t, a, b, >, \
<=, FMTu64, __VA_ARGS__)
-#define assert_b_eq(a, b, ...) do { \
- bool a_ = (a); \
- bool b_ = (b); \
- if (!(a_ == b_)) { \
- char prefix[ASSERT_BUFSIZE]; \
- char message[ASSERT_BUFSIZE]; \
- malloc_snprintf(prefix, sizeof(prefix), \
- "%s:%s:%d: Failed assertion: " \
- "(%s) == (%s) --> %s != %s: ", \
- __func__, __FILE__, __LINE__, \
- #a, #b, a_ ? "true" : "false", \
- b_ ? "true" : "false"); \
- malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
- p_test_fail(prefix, message); \
- } \
-} while (0)
-#define assert_b_ne(a, b, ...) do { \
- bool a_ = (a); \
- bool b_ = (b); \
- if (!(a_ != b_)) { \
- char prefix[ASSERT_BUFSIZE]; \
- char message[ASSERT_BUFSIZE]; \
- malloc_snprintf(prefix, sizeof(prefix), \
- "%s:%s:%d: Failed assertion: " \
- "(%s) != (%s) --> %s == %s: ", \
- __func__, __FILE__, __LINE__, \
- #a, #b, a_ ? "true" : "false", \
- b_ ? "true" : "false"); \
- malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
- p_test_fail(prefix, message); \
- } \
-} while (0)
+#define assert_b_eq(a, b, ...) verify_b_eq(true, a, b, __VA_ARGS__)
+#define assert_b_ne(a, b, ...) verify_b_ne(true, a, b, __VA_ARGS__)
+
#define assert_true(a, ...) assert_b_eq(a, true, __VA_ARGS__)
#define assert_false(a, ...) assert_b_eq(a, false, __VA_ARGS__)
-#define assert_str_eq(a, b, ...) do { \
- if (strcmp((a), (b))) { \
- char prefix[ASSERT_BUFSIZE]; \
- char message[ASSERT_BUFSIZE]; \
- malloc_snprintf(prefix, sizeof(prefix), \
- "%s:%s:%d: Failed assertion: " \
- "(%s) same as (%s) --> " \
- "\"%s\" differs from \"%s\": ", \
- __func__, __FILE__, __LINE__, #a, #b, a, b); \
- malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
- p_test_fail(prefix, message); \
- } \
-} while (0)
-#define assert_str_ne(a, b, ...) do { \
- if (!strcmp((a), (b))) { \
- char prefix[ASSERT_BUFSIZE]; \
- char message[ASSERT_BUFSIZE]; \
- malloc_snprintf(prefix, sizeof(prefix), \
- "%s:%s:%d: Failed assertion: " \
- "(%s) differs from (%s) --> " \
- "\"%s\" same as \"%s\": ", \
- __func__, __FILE__, __LINE__, #a, #b, a, b); \
- malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
- p_test_fail(prefix, message); \
- } \
-} while (0)
+#define assert_str_eq(a, b, ...) verify_str_eq(true, a, b, __VA_ARGS__)
+#define assert_str_ne(a, b, ...) verify_str_ne(true, a, b, __VA_ARGS__)
-#define assert_not_reached(...) do { \
- char prefix[ASSERT_BUFSIZE]; \
- char message[ASSERT_BUFSIZE]; \
- malloc_snprintf(prefix, sizeof(prefix), \
- "%s:%s:%d: Unreachable code reached: ", \
- __func__, __FILE__, __LINE__); \
- malloc_snprintf(message, sizeof(message), __VA_ARGS__); \
- p_test_fail(prefix, message); \
-} while (0)
+#define assert_not_reached(...) verify_not_reached(true, __VA_ARGS__)
/*
* If this enum changes, corresponding changes in test/test.sh.in are also