summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2015-01-26 05:16:57 (GMT)
committerJason Evans <jasone@canonware.com>2015-01-26 05:21:35 (GMT)
commit5b8ed5b7c91939f64f14fc48be84ed20e3f023f4 (patch)
tree27e35ebb42a1fa6e5dbe7f234624ed7c5362a349 /test/unit
parent41f2e692f664da683ae694b17630f5e186aa454c (diff)
downloadjemalloc-5b8ed5b7c91939f64f14fc48be84ed20e3f023f4.zip
jemalloc-5b8ed5b7c91939f64f14fc48be84ed20e3f023f4.tar.gz
jemalloc-5b8ed5b7c91939f64f14fc48be84ed20e3f023f4.tar.bz2
Implement the prof.gdump mallctl.
This feature makes it possible to toggle the gdump feature on/off during program execution, whereas the the opt.prof_dump mallctl value can only be set during program startup. This resolves #72.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/prof_gdump.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/unit/prof_gdump.c b/test/unit/prof_gdump.c
index a00b105..a0e6ee9 100644
--- a/test/unit/prof_gdump.c
+++ b/test/unit/prof_gdump.c
@@ -21,8 +21,9 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
TEST_BEGIN(test_gdump)
{
- bool active;
- void *p, *q;
+ bool active, gdump, gdump_old;
+ void *p, *q, *r, *s;
+ size_t sz;
test_skip_if(!config_prof);
@@ -42,8 +43,32 @@ TEST_BEGIN(test_gdump)
assert_ptr_not_null(q, "Unexpected mallocx() failure");
assert_true(did_prof_dump_open, "Expected a profile dump");
+ gdump = false;
+ sz = sizeof(gdump_old);
+ assert_d_eq(mallctl("prof.gdump", &gdump_old, &sz, &gdump,
+ sizeof(gdump)), 0,
+ "Unexpected mallctl failure while disabling prof.gdump");
+ assert(gdump_old);
+ did_prof_dump_open = false;
+ r = mallocx(chunksize, 0);
+ assert_ptr_not_null(q, "Unexpected mallocx() failure");
+ assert_false(did_prof_dump_open, "Unexpected profile dump");
+
+ gdump = true;
+ sz = sizeof(gdump_old);
+ assert_d_eq(mallctl("prof.gdump", &gdump_old, &sz, &gdump,
+ sizeof(gdump)), 0,
+ "Unexpected mallctl failure while enabling prof.gdump");
+ assert(!gdump_old);
+ did_prof_dump_open = false;
+ s = mallocx(chunksize, 0);
+ assert_ptr_not_null(q, "Unexpected mallocx() failure");
+ assert_true(did_prof_dump_open, "Expected a profile dump");
+
dallocx(p, 0);
dallocx(q, 0);
+ dallocx(r, 0);
+ dallocx(s, 0);
}
TEST_END