]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | #include "test/jemalloc_test.h" |
2 | ||
1a4d82fc JJ |
3 | static bool did_prof_dump_open; |
4 | ||
5 | static int | |
6 | prof_dump_open_intercept(bool propagate_err, const char *filename) | |
7 | { | |
8 | int fd; | |
9 | ||
10 | did_prof_dump_open = true; | |
11 | ||
12 | fd = open("/dev/null", O_WRONLY); | |
13 | assert_d_ne(fd, -1, "Unexpected open() failure"); | |
14 | ||
15 | return (fd); | |
16 | } | |
17 | ||
18 | TEST_BEGIN(test_idump) | |
19 | { | |
20 | bool active; | |
21 | void *p; | |
22 | ||
23 | test_skip_if(!config_prof); | |
24 | ||
25 | active = true; | |
3b2f2976 XL |
26 | assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active, |
27 | sizeof(active)), 0, | |
28 | "Unexpected mallctl failure while activating profiling"); | |
1a4d82fc JJ |
29 | |
30 | prof_dump_open = prof_dump_open_intercept; | |
31 | ||
32 | did_prof_dump_open = false; | |
33 | p = mallocx(1, 0); | |
34 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); | |
35 | dallocx(p, 0); | |
36 | assert_true(did_prof_dump_open, "Expected a profile dump"); | |
37 | } | |
38 | TEST_END | |
39 | ||
40 | int | |
41 | main(void) | |
42 | { | |
43 | ||
44 | return (test( | |
45 | test_idump)); | |
46 | } |