aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-10-28 11:23:24 -0700
committerJason Evans <jasone@canonware.com>2016-10-28 11:56:16 -0700
commitb99c72f3d29e3590ae81959922d0032a29dbace9 (patch)
treee6f7f26708a1ed7cd80f2d3097e02f62ca6369f6 /test
parenteaecaad8ea9fd9cd8b57e49834b5e3332f911c40 (diff)
downloadjemalloc-b99c72f3d29e3590ae81959922d0032a29dbace9.tar.gz
Reduce memory requirements for regression tests.
This is intended to drop memory usage to a level that AppVeyor test instances can handle. This resolves #393.
Diffstat (limited to 'test')
-rw-r--r--test/integration/aligned_alloc.c23
-rw-r--r--test/integration/mallocx.c44
-rw-r--r--test/integration/posix_memalign.c23
3 files changed, 55 insertions, 35 deletions
diff --git a/test/integration/aligned_alloc.c b/test/integration/aligned_alloc.c
index 80bb38f..5843842 100644
--- a/test/integration/aligned_alloc.c
+++ b/test/integration/aligned_alloc.c
@@ -1,7 +1,20 @@
#include "test/jemalloc_test.h"
#define CHUNK 0x400000
-#define MAXALIGN (((size_t)1) << 25)
+#define MAXALIGN (((size_t)1) << 23)
+
+/*
+ * On systems which can't merge extents, tests that call this function generate
+ * a lot of dirty memory very quickly. Purging between cycles mitigates
+ * potential OOM on e.g. 32-bit Windows.
+ */
+static void
+purge(void)
+{
+
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctl error");
+}
TEST_BEGIN(test_alignment_errors)
{
@@ -109,13 +122,7 @@ TEST_BEGIN(test_alignment_and_size)
}
}
}
- /*
- * On systems which can't merge extents, this test generates a
- * lot of dirty memory very quickly. Purge between cycles to
- * avoid potential OOM on e.g. 32-bit Windows.
- */
- assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
- "Unexpected mallctl error");
+ purge();
}
#undef NITER
}
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index 79ab494..43b76eb 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -50,6 +50,19 @@ get_huge_size(size_t ind)
return (get_size_impl("arenas.hchunk.0.size", ind));
}
+/*
+ * On systems which can't merge extents, tests that call this function generate
+ * a lot of dirty memory very quickly. Purging between cycles mitigates
+ * potential OOM on e.g. 32-bit Windows.
+ */
+static void
+purge(void)
+{
+
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctl error");
+}
+
TEST_BEGIN(test_overflow)
{
size_t hugemax;
@@ -96,6 +109,7 @@ TEST_BEGIN(test_oom)
if (ptrs[i] != NULL)
dallocx(ptrs[i], 0);
}
+ purge();
#if LG_SIZEOF_PTR == 3
assert_ptr_null(mallocx(0x8000000000000000ULL,
@@ -113,7 +127,7 @@ TEST_END
TEST_BEGIN(test_basic)
{
-#define MAXSZ (((size_t)1) << 26)
+#define MAXSZ (((size_t)1) << 23)
size_t sz;
for (sz = 1; sz < MAXSZ; sz = nallocx(sz, 0) + 1) {
@@ -122,30 +136,28 @@ TEST_BEGIN(test_basic)
nsz = nallocx(sz, 0);
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
p = mallocx(sz, 0);
- assert_ptr_not_null(p, "Unexpected mallocx() error");
+ assert_ptr_not_null(p,
+ "Unexpected mallocx(size=%zx, flags=0) error", sz);
rsz = sallocx(p, 0);
assert_zu_ge(rsz, sz, "Real size smaller than expected");
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
dallocx(p, 0);
p = mallocx(sz, 0);
- assert_ptr_not_null(p, "Unexpected mallocx() error");
+ assert_ptr_not_null(p,
+ "Unexpected mallocx(size=%zx, flags=0) error", sz);
dallocx(p, 0);
nsz = nallocx(sz, MALLOCX_ZERO);
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
p = mallocx(sz, MALLOCX_ZERO);
- assert_ptr_not_null(p, "Unexpected mallocx() error");
+ assert_ptr_not_null(p,
+ "Unexpected mallocx(size=%zx, flags=MALLOCX_ZERO) error",
+ nsz);
rsz = sallocx(p, 0);
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
dallocx(p, 0);
- /*
- * On systems which can't merge extents, this test generates a
- * lot of dirty memory very quickly. Purge between cycles to
- * avoid potential OOM on e.g. 32-bit Windows.
- */
- assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
- "Unexpected mallctl error");
+ purge();
}
#undef MAXSZ
}
@@ -153,7 +165,7 @@ TEST_END
TEST_BEGIN(test_alignment_and_size)
{
-#define MAXALIGN (((size_t)1) << 25)
+#define MAXALIGN (((size_t)1) << 23)
#define NITER 4
size_t nsz, rsz, sz, alignment, total;
unsigned i;
@@ -203,13 +215,7 @@ TEST_BEGIN(test_alignment_and_size)
}
}
}
- /*
- * On systems which can't merge extents, this test generates a
- * lot of dirty memory very quickly. Purge between cycles to
- * avoid potential OOM on e.g. 32-bit Windows.
- */
- assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
- "Unexpected mallctl error");
+ purge();
}
#undef MAXALIGN
#undef NITER
diff --git a/test/integration/posix_memalign.c b/test/integration/posix_memalign.c
index 171bcea..e22e102 100644
--- a/test/integration/posix_memalign.c
+++ b/test/integration/posix_memalign.c
@@ -1,7 +1,20 @@
#include "test/jemalloc_test.h"
#define CHUNK 0x400000
-#define MAXALIGN (((size_t)1) << 25)
+#define MAXALIGN (((size_t)1) << 23)
+
+/*
+ * On systems which can't merge extents, tests that call this function generate
+ * a lot of dirty memory very quickly. Purging between cycles mitigates
+ * potential OOM on e.g. 32-bit Windows.
+ */
+static void
+purge(void)
+{
+
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected mallctl error");
+}
TEST_BEGIN(test_alignment_errors)
{
@@ -103,13 +116,7 @@ TEST_BEGIN(test_alignment_and_size)
}
}
}
- /*
- * On systems which can't merge extents, this test generates a
- * lot of dirty memory very quickly. Purge between cycles to
- * avoid potential OOM on e.g. 32-bit Windows.
- */
- assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
- "Unexpected mallctl error");
+ purge();
}
#undef NITER
}