Add "prof.dump_prefix" to override filename prefixes for dumps.

This commit is contained in:
zhxchen17
2019-09-09 20:18:41 -07:00
committed by Qi Wang
parent 242af439b8
commit 4b76c684bb
8 changed files with 166 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
#include "test/jemalloc_test.h"
#define TEST_PREFIX "test_prefix"
static bool did_prof_dump_open;
static int
@@ -8,6 +10,10 @@ prof_dump_open_intercept(bool propagate_err, const char *filename) {
did_prof_dump_open = true;
const char filename_prefix[] = TEST_PREFIX ".";
assert_d_eq(strncmp(filename_prefix, filename, sizeof(filename_prefix)
- 1), 0, "Dump file name should start with \"" TEST_PREFIX ".\"");
fd = open("/dev/null", O_WRONLY);
assert_d_ne(fd, -1, "Unexpected open() failure");
@@ -18,9 +24,16 @@ TEST_BEGIN(test_idump) {
bool active;
void *p;
const char *dump_prefix = TEST_PREFIX;
test_skip_if(!config_prof);
active = true;
assert_d_eq(mallctl("prof.dump_prefix", NULL, NULL,
(void *)&dump_prefix, sizeof(dump_prefix)), 0,
"Unexpected mallctl failure while overwriting dump prefix");
assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,
sizeof(active)), 0,
"Unexpected mallctl failure while activating profiling");