summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2014-02-26 00:46:31 (GMT)
committerJason Evans <jasone@canonware.com>2014-02-26 00:46:31 (GMT)
commit7709a64c59daf0b1f938be49472fcc499e1bd136 (patch)
treef7f00c6cde650d0a78ed37b18de2f9fa85feeb62 /test
parentcc47dde16203a6ae7eb685b53e1ae501f3869bc6 (diff)
parentb9ec5c9a004a9c2f63951c476a6ff9f4c27f7b6f (diff)
downloadjemalloc-7709a64c59daf0b1f938be49472fcc499e1bd136.zip
jemalloc-7709a64c59daf0b1f938be49472fcc499e1bd136.tar.gz
jemalloc-7709a64c59daf0b1f938be49472fcc499e1bd136.tar.bz2
Merge branch 'dev'3.5.1
Diffstat (limited to 'test')
-rw-r--r--test/integration/aligned_alloc.c4
-rw-r--r--test/integration/allocm.c23
-rw-r--r--test/integration/mallocx.c21
-rw-r--r--test/integration/posix_memalign.c4
-rw-r--r--test/unit/junk.c9
-rw-r--r--test/unit/prof_accum.c38
-rw-r--r--test/unit/prof_accum.h35
-rw-r--r--test/unit/prof_accum_a.c3
-rw-r--r--test/unit/prof_accum_b.c3
-rw-r--r--test/unit/stats.c23
10 files changed, 67 insertions, 96 deletions
diff --git a/test/integration/aligned_alloc.c b/test/integration/aligned_alloc.c
index 17c2151..6090014 100644
--- a/test/integration/aligned_alloc.c
+++ b/test/integration/aligned_alloc.c
@@ -47,10 +47,10 @@ TEST_BEGIN(test_oom_errors)
#if LG_SIZEOF_PTR == 3
alignment = UINT64_C(0x4000000000000000);
- size = UINT64_C(0x8400000000000001);
+ size = UINT64_C(0xc000000000000001);
#else
alignment = 0x40000000LU;
- size = 0x84000001LU;
+ size = 0xc0000001LU;
#endif
set_errno(0);
p = aligned_alloc(alignment, size);
diff --git a/test/integration/allocm.c b/test/integration/allocm.c
index bd7a3ca..66ecf86 100644
--- a/test/integration/allocm.c
+++ b/test/integration/allocm.c
@@ -39,28 +39,6 @@ TEST_BEGIN(test_basic)
}
TEST_END
-TEST_BEGIN(test_alignment_errors)
-{
- void *p;
- size_t nsz, rsz, sz, alignment;
-
-#if LG_SIZEOF_PTR == 3
- alignment = UINT64_C(0x4000000000000000);
- sz = UINT64_C(0x8400000000000001);
-#else
- alignment = 0x40000000LU;
- sz = 0x84000001LU;
-#endif
- nsz = 0;
- assert_d_eq(nallocm(&nsz, sz, ALLOCM_ALIGN(alignment)), ALLOCM_SUCCESS,
- "Unexpected nallocm() error");
- rsz = 0;
- assert_d_ne(allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment)),
- ALLOCM_SUCCESS, "Expected error for allocm(&p, %zu, %#x)",
- sz, ALLOCM_ALIGN(alignment));
-}
-TEST_END
-
TEST_BEGIN(test_alignment_and_size)
{
int r;
@@ -126,6 +104,5 @@ main(void)
return (test(
test_basic,
- test_alignment_errors,
test_alignment_and_size));
}
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index c26f6c5..f37a74b 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -34,26 +34,6 @@ TEST_BEGIN(test_basic)
}
TEST_END
-TEST_BEGIN(test_alignment_errors)
-{
- void *p;
- size_t nsz, sz, alignment;
-
-#if LG_SIZEOF_PTR == 3
- alignment = UINT64_C(0x4000000000000000);
- sz = UINT64_C(0x8400000000000001);
-#else
- alignment = 0x40000000LU;
- sz = 0x84000001LU;
-#endif
- nsz = nallocx(sz, MALLOCX_ALIGN(alignment));
- assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
- p = mallocx(sz, MALLOCX_ALIGN(alignment));
- assert_ptr_null(p, "Expected error for mallocx(%zu, %#x)", sz,
- MALLOCX_ALIGN(alignment));
-}
-TEST_END
-
TEST_BEGIN(test_alignment_and_size)
{
size_t nsz, rsz, sz, alignment, total;
@@ -114,6 +94,5 @@ main(void)
return (test(
test_basic,
- test_alignment_errors,
test_alignment_and_size));
}
diff --git a/test/integration/posix_memalign.c b/test/integration/posix_memalign.c
index c88a4dc..19741c6 100644
--- a/test/integration/posix_memalign.c
+++ b/test/integration/posix_memalign.c
@@ -43,10 +43,10 @@ TEST_BEGIN(test_oom_errors)
#if LG_SIZEOF_PTR == 3
alignment = UINT64_C(0x4000000000000000);
- size = UINT64_C(0x8400000000000001);
+ size = UINT64_C(0xc000000000000001);
#else
alignment = 0x40000000LU;
- size = 0x84000001LU;
+ size = 0xc0000001LU;
#endif
assert_d_ne(posix_memalign(&p, alignment, size), 0,
"Expected error for posix_memalign(&p, %zu, %zu)",
diff --git a/test/unit/junk.c b/test/unit/junk.c
index e27db2f..ef8f9c1 100644
--- a/test/unit/junk.c
+++ b/test/unit/junk.c
@@ -92,9 +92,12 @@ test_junk(size_t sz_min, size_t sz_max)
s = (char *)rallocx(s, sz+1, 0);
assert_ptr_not_null((void *)s,
"Unexpected rallocx() failure");
- assert_ptr_eq(most_recently_junked, junked,
- "Expected region of size %zu to be junk-filled",
- sz);
+ if (!config_mremap || sz+1 <= arena_maxclass) {
+ assert_ptr_eq(most_recently_junked, junked,
+ "Expected region of size %zu to be "
+ "junk-filled",
+ sz);
+ }
}
}
diff --git a/test/unit/prof_accum.c b/test/unit/prof_accum.c
index cf3f287..050a8a7 100644
--- a/test/unit/prof_accum.c
+++ b/test/unit/prof_accum.c
@@ -1,9 +1,4 @@
-#include "test/jemalloc_test.h"
-
-#define NTHREADS 4
-#define NALLOCS_PER_THREAD 50
-#define DUMP_INTERVAL 1
-#define BT_COUNT_CHECK_INTERVAL 5
+#include "prof_accum.h"
#ifdef JEMALLOC_PROF
const char *malloc_conf =
@@ -21,37 +16,6 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
return (fd);
}
-#define alloc_n_proto(n) \
-static void *alloc_##n(unsigned bits);
-
-#define alloc_n_gen(n) \
-static void * \
-alloc_##n(unsigned bits) \
-{ \
- void *p; \
- \
- if (bits == 0) \
- p = mallocx(1, 0); \
- else { \
- switch (bits & 0x1U) { \
- case 0: \
- p = alloc_0(bits >> 1); \
- break; \
- case 1: \
- p = alloc_1(bits >> 1); \
- break; \
- default: not_reached(); \
- } \
- } \
- /* Intentionally sabotage tail call optimization. */ \
- assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
- return (p); \
-}
-alloc_n_proto(0)
-alloc_n_proto(1)
-alloc_n_gen(0)
-alloc_n_gen(1)
-
static void *
alloc_from_permuted_backtrace(unsigned thd_ind, unsigned iteration)
{
diff --git a/test/unit/prof_accum.h b/test/unit/prof_accum.h
new file mode 100644
index 0000000..109d86b
--- /dev/null
+++ b/test/unit/prof_accum.h
@@ -0,0 +1,35 @@
+#include "test/jemalloc_test.h"
+
+#define NTHREADS 4
+#define NALLOCS_PER_THREAD 50
+#define DUMP_INTERVAL 1
+#define BT_COUNT_CHECK_INTERVAL 5
+
+#define alloc_n_proto(n) \
+void *alloc_##n(unsigned bits);
+alloc_n_proto(0)
+alloc_n_proto(1)
+
+#define alloc_n_gen(n) \
+void * \
+alloc_##n(unsigned bits) \
+{ \
+ void *p; \
+ \
+ if (bits == 0) \
+ p = mallocx(1, 0); \
+ else { \
+ switch (bits & 0x1U) { \
+ case 0: \
+ p = (alloc_0(bits >> 1)); \
+ break; \
+ case 1: \
+ p = (alloc_1(bits >> 1)); \
+ break; \
+ default: not_reached(); \
+ } \
+ } \
+ /* Intentionally sabotage tail call optimization. */ \
+ assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
+ return (p); \
+}
diff --git a/test/unit/prof_accum_a.c b/test/unit/prof_accum_a.c
new file mode 100644
index 0000000..42ad521
--- /dev/null
+++ b/test/unit/prof_accum_a.c
@@ -0,0 +1,3 @@
+#include "prof_accum.h"
+
+alloc_n_gen(0)
diff --git a/test/unit/prof_accum_b.c b/test/unit/prof_accum_b.c
new file mode 100644
index 0000000..60d9dab
--- /dev/null
+++ b/test/unit/prof_accum_b.c
@@ -0,0 +1,3 @@
+#include "prof_accum.h"
+
+alloc_n_gen(1)
diff --git a/test/unit/stats.c b/test/unit/stats.c
index 6cd9773..03a55c7 100644
--- a/test/unit/stats.c
+++ b/test/unit/stats.c
@@ -31,21 +31,25 @@ TEST_END
TEST_BEGIN(test_stats_chunks)
{
- size_t current, total, high;
- size_t sz = sizeof(size_t);
+ size_t current, high;
+ uint64_t total;
+ size_t sz;
int expected = config_stats ? 0 : ENOENT;
+ sz = sizeof(size_t);
assert_d_eq(mallctl("stats.chunks.current", &current, &sz, NULL, 0),
expected, "Unexpected mallctl() result");
+ sz = sizeof(uint64_t);
assert_d_eq(mallctl("stats.chunks.total", &total, &sz, NULL, 0),
expected, "Unexpected mallctl() result");
+ sz = sizeof(size_t);
assert_d_eq(mallctl("stats.chunks.high", &high, &sz, NULL, 0), expected,
"Unexpected mallctl() result");
if (config_stats) {
assert_zu_le(current, high,
"current should be no larger than high");
- assert_zu_le(high, total,
+ assert_u64_le((uint64_t)high, total,
"high should be no larger than total");
}
}
@@ -247,9 +251,9 @@ TEST_BEGIN(test_stats_arenas_bins)
{
unsigned arena;
void *p;
- size_t sz, allocated;
+ size_t sz, allocated, curruns;
uint64_t epoch, nmalloc, ndalloc, nrequests, nfills, nflushes;
- uint64_t nruns, nreruns, curruns;
+ uint64_t nruns, nreruns;
int expected = config_stats ? 0 : ENOENT;
arena = 0;
@@ -287,6 +291,7 @@ TEST_BEGIN(test_stats_arenas_bins)
NULL, 0), expected, "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.arenas.0.bins.0.nreruns", &nreruns, &sz,
NULL, 0), expected, "Unexpected mallctl() result");
+ sz = sizeof(size_t);
assert_d_eq(mallctl("stats.arenas.0.bins.0.curruns", &curruns, &sz,
NULL, 0), expected, "Unexpected mallctl() result");
@@ -307,7 +312,7 @@ TEST_BEGIN(test_stats_arenas_bins)
}
assert_u64_gt(nruns, 0,
"At least one run should have been allocated");
- assert_u64_gt(curruns, 0,
+ assert_zu_gt(curruns, 0,
"At least one run should be currently allocated");
}
@@ -319,8 +324,8 @@ TEST_BEGIN(test_stats_arenas_lruns)
{
unsigned arena;
void *p;
- uint64_t epoch, nmalloc, ndalloc, nrequests, curruns;
- size_t sz = sizeof(uint64_t);
+ uint64_t epoch, nmalloc, ndalloc, nrequests;
+ size_t curruns, sz;
int expected = config_stats ? 0 : ENOENT;
arena = 0;
@@ -333,12 +338,14 @@ TEST_BEGIN(test_stats_arenas_lruns)
assert_d_eq(mallctl("epoch", NULL, NULL, &epoch, sizeof(epoch)), 0,
"Unexpected mallctl() failure");
+ sz = sizeof(uint64_t);
assert_d_eq(mallctl("stats.arenas.0.lruns.0.nmalloc", &nmalloc, &sz,
NULL, 0), expected, "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.arenas.0.lruns.0.ndalloc", &ndalloc, &sz,
NULL, 0), expected, "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.arenas.0.lruns.0.nrequests", &nrequests, &sz,
NULL, 0), expected, "Unexpected mallctl() result");
+ sz = sizeof(size_t);
assert_d_eq(mallctl("stats.arenas.0.lruns.0.curruns", &curruns, &sz,
NULL, 0), expected, "Unexpected mallctl() result");