summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/include/test/SFMT-alti.h2
-rw-r--r--test/include/test/test.h53
-rw-r--r--test/integration/MALLOCX_ARENA.c (renamed from test/integration/ALLOCM_ARENA.c)8
-rw-r--r--test/integration/allocm.c3
-rw-r--r--test/integration/mallocx.c3
-rw-r--r--test/integration/rallocx.c4
-rw-r--r--test/src/SFMT.c3
-rw-r--r--test/src/test.c10
-rw-r--r--test/unit/SFMT.c2
-rw-r--r--test/unit/ckh.c12
-rw-r--r--test/unit/hash.c6
-rw-r--r--test/unit/junk.c2
-rw-r--r--test/unit/quarantine.c2
-rw-r--r--test/unit/rtree.c5
-rw-r--r--test/unit/zero.c2
15 files changed, 73 insertions, 44 deletions
diff --git a/test/include/test/SFMT-alti.h b/test/include/test/SFMT-alti.h
index 2f86f67..0005df6 100644
--- a/test/include/test/SFMT-alti.h
+++ b/test/include/test/SFMT-alti.h
@@ -61,7 +61,7 @@
* @return output
*/
JEMALLOC_ALWAYS_INLINE
-static vector unsigned int vec_recursion(vector unsigned int a,
+vector unsigned int vec_recursion(vector unsigned int a,
vector unsigned int b,
vector unsigned int c,
vector unsigned int d) {
diff --git a/test/include/test/test.h b/test/include/test/test.h
index 8cc97af..a32ec07 100644
--- a/test/include/test/test.h
+++ b/test/include/test/test.h
@@ -1,13 +1,19 @@
+#define ASSERT_BUFSIZE 256
+
#define assert_cmp(t, a, b, cmp, neg_cmp, pri, fmt...) do { \
t a_ = (a); \
t b_ = (b); \
if (!(a_ cmp b_)) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) "#cmp" (%s) --> " \
"%"pri" "#neg_cmp" %"pri": ", \
__func__, __FILE__, __LINE__, \
- #a, #b, a_, b_, fmt); \
+ #a, #b, a_, b_); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
@@ -208,24 +214,32 @@
bool a_ = (a); \
bool b_ = (b); \
if (!(a_ == b_)) { \
- p_test_fail( \
+ 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", fmt); \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_b_ne(a, b, fmt...) do { \
bool a_ = (a); \
bool b_ = (b); \
if (!(a_ != b_)) { \
- p_test_fail( \
+ 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", fmt); \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_true(a, fmt...) assert_b_eq(a, true, fmt)
@@ -233,26 +247,39 @@
#define assert_str_eq(a, b, fmt...) do { \
if (strcmp((a), (b))) { \
- p_test_fail( \
+ 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, fmt); \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_str_ne(a, b, fmt...) do { \
if (!strcmp((a), (b))) { \
- p_test_fail( \
+ 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, fmt); \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_not_reached(fmt...) do { \
- p_test_fail("%s:%s:%d: Unreachable code reached: ", \
- __func__, __FILE__, __LINE__, fmt); \
+ 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), fmt); \
+ p_test_fail(prefix, message); \
} while (0)
/*
@@ -299,4 +326,4 @@ void test_fail(const char *format, ...) JEMALLOC_ATTR(format(printf, 1, 2));
test_status_t p_test(test_t* t, ...);
void p_test_init(const char *name);
void p_test_fini(void);
-void p_test_fail(const char *format, ...);
+void p_test_fail(const char *prefix, const char *message);
diff --git a/test/integration/ALLOCM_ARENA.c b/test/integration/MALLOCX_ARENA.c
index 5bf3c4a..71cf6f2 100644
--- a/test/integration/ALLOCM_ARENA.c
+++ b/test/integration/MALLOCX_ARENA.c
@@ -8,7 +8,7 @@ thd_start(void *arg)
unsigned thread_ind = (unsigned)(uintptr_t)arg;
unsigned arena_ind;
void *p;
- size_t rsz, sz;
+ size_t sz;
sz = sizeof(arena_ind);
assert_d_eq(mallctl("arenas.extend", &arena_ind, &sz, NULL, 0), 0,
@@ -27,9 +27,9 @@ thd_start(void *arg)
sizeof(const char *)), 0, "Error in mallctlbymib()");
}
- assert_d_eq(allocm(&p, &rsz, 1, ALLOCM_ARENA(arena_ind)),
- ALLOCM_SUCCESS, "Unexpected allocm() error");
- dallocm(p, 0);
+ p = mallocx(1, MALLOCX_ARENA(arena_ind));
+ assert_ptr_not_null(p, "Unexpected mallocx() error");
+ dallocx(p, 0);
return (NULL);
}
diff --git a/test/integration/allocm.c b/test/integration/allocm.c
index 66ecf86..7b4ea0c 100644
--- a/test/integration/allocm.c
+++ b/test/integration/allocm.c
@@ -1,8 +1,7 @@
#include "test/jemalloc_test.h"
#define CHUNK 0x400000
-/* #define MAXALIGN ((size_t)UINT64_C(0x80000000000)) */
-#define MAXALIGN ((size_t)0x2000000LU)
+#define MAXALIGN (((size_t)1) << 25)
#define NITER 4
TEST_BEGIN(test_basic)
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index f37a74b..123e041 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -1,8 +1,7 @@
#include "test/jemalloc_test.h"
#define CHUNK 0x400000
-/* #define MAXALIGN ((size_t)UINT64_C(0x80000000000)) */
-#define MAXALIGN ((size_t)0x2000000LU)
+#define MAXALIGN (((size_t)1) << 25)
#define NITER 4
TEST_BEGIN(test_basic)
diff --git a/test/integration/rallocx.c b/test/integration/rallocx.c
index b4b6780..ee21aed 100644
--- a/test/integration/rallocx.c
+++ b/test/integration/rallocx.c
@@ -112,7 +112,7 @@ TEST_BEGIN(test_align)
{
void *p, *q;
size_t align;
-#define MAX_ALIGN (ZU(1) << 29)
+#define MAX_ALIGN (ZU(1) << 25)
align = ZU(1);
p = mallocx(1, MALLOCX_ALIGN(align));
@@ -137,7 +137,7 @@ TEST_BEGIN(test_lg_align_and_zero)
{
void *p, *q;
size_t lg_align, sz;
-#define MAX_LG_ALIGN 29
+#define MAX_LG_ALIGN 25
#define MAX_VALIDATE (ZU(1) << 22)
lg_align = ZU(0);
diff --git a/test/src/SFMT.c b/test/src/SFMT.c
index 433d7f6..e6f8dee 100644
--- a/test/src/SFMT.c
+++ b/test/src/SFMT.c
@@ -49,6 +49,9 @@
#include "test/jemalloc_test.h"
#include "test/SFMT-params.h"
+#if defined(JEMALLOC_BIG_ENDIAN) && !defined(BIG_ENDIAN64)
+#define BIG_ENDIAN64 1
+#endif
#if defined(__BIG_ENDIAN__) && !defined(__amd64) && !defined(BIG_ENDIAN64)
#define BIG_ENDIAN64 1
#endif
diff --git a/test/src/test.c b/test/src/test.c
index 6552e37..528d858 100644
--- a/test/src/test.c
+++ b/test/src/test.c
@@ -86,15 +86,9 @@ p_test(test_t* t, ...)
}
void
-p_test_fail(const char *format, ...)
+p_test_fail(const char *prefix, const char *message)
{
- va_list ap;
- va_start(ap, format);
- malloc_vcprintf(NULL, NULL, format, ap);
- format = va_arg(ap, const char *);
- malloc_vcprintf(NULL, NULL, format, ap);
- va_end(ap);
- malloc_printf("\n");
+ malloc_cprintf(NULL, NULL, "%s%s\n", prefix, message);
test_status = test_status_fail;
}
diff --git a/test/unit/SFMT.c b/test/unit/SFMT.c
index 4805f8e..c57bd68 100644
--- a/test/unit/SFMT.c
+++ b/test/unit/SFMT.c
@@ -1576,7 +1576,7 @@ TEST_BEGIN(test_by_array_64)
for (i = 0; i < BLOCK_SIZE64; i++) {
if (i < COUNT_1) {
assert_u64_eq(array64[i], init_by_array_64_expected[i],
- "Output mismatch for i=%d");
+ "Output mismatch for i=%d", i);
}
r = gen_rand64(ctx);
assert_u64_eq(r, array64[i],
diff --git a/test/unit/ckh.c b/test/unit/ckh.c
index 69fd7f5..b214c27 100644
--- a/test/unit/ckh.c
+++ b/test/unit/ckh.c
@@ -29,7 +29,7 @@ TEST_BEGIN(test_count_insert_search_remove)
assert_false(ckh_new(&ckh, 2, ckh_string_hash, ckh_string_keycomp),
"Unexpected ckh_new() error");
assert_zu_eq(ckh_count(&ckh), 0,
- "ckh_count() should return %zu, but it returned %zu", 0,
+ "ckh_count() should return %zu, but it returned %zu", ZU(0),
ckh_count(&ckh));
/* Insert. */
@@ -101,11 +101,11 @@ TEST_END
TEST_BEGIN(test_insert_iter_remove)
{
-#define NITEMS 1000
+#define NITEMS ZU(1000)
ckh_t ckh;
void **p[NITEMS];
void *q, *r;
- unsigned i;
+ size_t i;
assert_false(ckh_new(&ckh, 2, ckh_pointer_hash, ckh_pointer_keycomp),
"Unexpected ckh_new() error");
@@ -116,7 +116,7 @@ TEST_BEGIN(test_insert_iter_remove)
}
for (i = 0; i < NITEMS; i++) {
- unsigned j;
+ size_t j;
for (j = i; j < NITEMS; j++) {
assert_false(ckh_insert(&ckh, p[j], p[j]),
@@ -152,7 +152,7 @@ TEST_BEGIN(test_insert_iter_remove)
for (tabind = 0; ckh_iter(&ckh, &tabind, &q, &r) ==
false;) {
- unsigned k;
+ size_t k;
assert_ptr_eq(q, r, "Key and val not equal");
@@ -188,7 +188,7 @@ TEST_BEGIN(test_insert_iter_remove)
}
assert_zu_eq(ckh_count(&ckh), 0,
- "ckh_count() should return %zu, but it returned %zu", 0,
+ "ckh_count() should return %zu, but it returned %zu", ZU(0),
ckh_count(&ckh));
ckh_delete(&ckh);
#undef NITEMS
diff --git a/test/unit/hash.c b/test/unit/hash.c
index 0446e52..abb394a 100644
--- a/test/unit/hash.c
+++ b/test/unit/hash.c
@@ -122,9 +122,15 @@ hash_variant_verify(hash_variant_t variant)
(final[3] << 24);
switch (variant) {
+#ifdef JEMALLOC_BIG_ENDIAN
+ case hash_variant_x86_32: expected = 0x6213303eU; break;
+ case hash_variant_x86_128: expected = 0x266820caU; break;
+ case hash_variant_x64_128: expected = 0xcc622b6fU; break;
+#else
case hash_variant_x86_32: expected = 0xb0f57ee3U; break;
case hash_variant_x86_128: expected = 0xb3ece62aU; break;
case hash_variant_x64_128: expected = 0x6384ba69U; break;
+#endif
default: not_reached();
}
diff --git a/test/unit/junk.c b/test/unit/junk.c
index ef8f9c1..85bbf9e 100644
--- a/test/unit/junk.c
+++ b/test/unit/junk.c
@@ -73,7 +73,7 @@ test_junk(size_t sz_min, size_t sz_max)
if (sz_prev > 0) {
assert_c_eq(s[0], 'a',
"Previously allocated byte %zu/%zu is corrupted",
- 0, sz_prev);
+ ZU(0), sz_prev);
assert_c_eq(s[sz_prev-1], 'a',
"Previously allocated byte %zu/%zu is corrupted",
sz_prev-1, sz_prev);
diff --git a/test/unit/quarantine.c b/test/unit/quarantine.c
index 4534923..bbd48a5 100644
--- a/test/unit/quarantine.c
+++ b/test/unit/quarantine.c
@@ -21,7 +21,7 @@ quarantine_clear(void)
TEST_BEGIN(test_quarantine)
{
-#define SZ 256
+#define SZ ZU(256)
#define NQUARANTINED (QUARANTINE_SIZE/SZ)
void *quarantined[NQUARANTINED+1];
size_t i, j;
diff --git a/test/unit/rtree.c b/test/unit/rtree.c
index 5e7a411..5463055 100644
--- a/test/unit/rtree.c
+++ b/test/unit/rtree.c
@@ -48,8 +48,9 @@ TEST_BEGIN(test_rtree_bits)
assert_u_eq(rtree_get(rtree, keys[k]), 1,
"rtree_get() should return previously set "
"value and ignore insignificant key bits; "
- "i=%u, j=%u, k=%u, set key=%#x, "
- "get key=%#x", i, j, k, keys[j], keys[k]);
+ "i=%u, j=%u, k=%u, set key=%#"PRIxPTR", "
+ "get key=%#"PRIxPTR, i, j, k, keys[j],
+ keys[k]);
}
assert_u_eq(rtree_get(rtree,
(((uintptr_t)1) << (sizeof(uintptr_t)*8-i))), 0,
diff --git a/test/unit/zero.c b/test/unit/zero.c
index 2fdae2f..65a8f0c 100644
--- a/test/unit/zero.c
+++ b/test/unit/zero.c
@@ -20,7 +20,7 @@ test_zero(size_t sz_min, size_t sz_max)
if (sz_prev > 0) {
assert_c_eq(s[0], 'a',
"Previously allocated byte %zu/%zu is corrupted",
- 0, sz_prev);
+ ZU(0), sz_prev);
assert_c_eq(s[sz_prev-1], 'a',
"Previously allocated byte %zu/%zu is corrupted",
sz_prev-1, sz_prev);