21dfa4300d
``` grep -Irl assert_ test/ | xargs sed -i \ 's/witness_assert/witness_do_not_replace/g'; grep -Irl assert_ test/ | xargs sed -i \ 's/malloc_mutex_assert_owner/malloc_mutex_do_not_replace_owner/g'; grep -Ir assert_ test/ | grep -o "[_a-zA-Z]*assert_[_a-zA-Z]*" | \ grep -v "^assert_"; # confirm no output grep -Irl assert_ test/ | xargs sed -i 's/assert_/expect_/g'; grep -Irl witness_do_not_replace test/ | xargs sed -i \ 's/witness_do_not_replace/witness_assert/g'; grep -Irl malloc_mutex_do_not_replace_owner test/ | xargs sed -i \ 's/malloc_mutex_do_not_replace_owner/malloc_mutex_assert_owner/g'; ```
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
#include "test/jemalloc_test.h"
|
|
|
|
#define TEST_PREFIX "test_prefix"
|
|
|
|
static bool did_prof_dump_open;
|
|
|
|
static int
|
|
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
|
int fd;
|
|
|
|
did_prof_dump_open = true;
|
|
|
|
const char filename_prefix[] = TEST_PREFIX ".";
|
|
expect_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);
|
|
expect_d_ne(fd, -1, "Unexpected open() failure");
|
|
|
|
return fd;
|
|
}
|
|
|
|
TEST_BEGIN(test_idump) {
|
|
bool active;
|
|
void *p;
|
|
|
|
const char *dump_prefix = TEST_PREFIX;
|
|
|
|
test_skip_if(!config_prof);
|
|
|
|
active = true;
|
|
|
|
expect_d_eq(mallctl("prof.dump_prefix", NULL, NULL,
|
|
(void *)&dump_prefix, sizeof(dump_prefix)), 0,
|
|
"Unexpected mallctl failure while overwriting dump prefix");
|
|
|
|
expect_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,
|
|
sizeof(active)), 0,
|
|
"Unexpected mallctl failure while activating profiling");
|
|
|
|
prof_dump_open = prof_dump_open_intercept;
|
|
|
|
did_prof_dump_open = false;
|
|
p = mallocx(1, 0);
|
|
expect_ptr_not_null(p, "Unexpected mallocx() failure");
|
|
dallocx(p, 0);
|
|
expect_true(did_prof_dump_open, "Expected a profile dump");
|
|
}
|
|
TEST_END
|
|
|
|
int
|
|
main(void) {
|
|
return test(
|
|
test_idump);
|
|
}
|