]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/unit/prof_gdump.c
1 #include "test/jemalloc_test.h"
4 const char *malloc_conf
= "prof:true,prof_active:false,prof_gdump:true";
7 static bool did_prof_dump_open
;
10 prof_dump_open_intercept(bool propagate_err
, const char *filename
)
14 did_prof_dump_open
= true;
16 fd
= open("/dev/null", O_WRONLY
);
17 assert_d_ne(fd
, -1, "Unexpected open() failure");
22 TEST_BEGIN(test_gdump
)
24 bool active
, gdump
, gdump_old
;
28 test_skip_if(!config_prof
);
31 assert_d_eq(mallctl("prof.active", NULL
, NULL
, &active
, sizeof(active
)),
32 0, "Unexpected mallctl failure while activating profiling");
34 prof_dump_open
= prof_dump_open_intercept
;
36 did_prof_dump_open
= false;
37 p
= mallocx(chunksize
, 0);
38 assert_ptr_not_null(p
, "Unexpected mallocx() failure");
39 assert_true(did_prof_dump_open
, "Expected a profile dump");
41 did_prof_dump_open
= false;
42 q
= mallocx(chunksize
, 0);
43 assert_ptr_not_null(q
, "Unexpected mallocx() failure");
44 assert_true(did_prof_dump_open
, "Expected a profile dump");
47 sz
= sizeof(gdump_old
);
48 assert_d_eq(mallctl("prof.gdump", &gdump_old
, &sz
, &gdump
,
50 "Unexpected mallctl failure while disabling prof.gdump");
52 did_prof_dump_open
= false;
53 r
= mallocx(chunksize
, 0);
54 assert_ptr_not_null(q
, "Unexpected mallocx() failure");
55 assert_false(did_prof_dump_open
, "Unexpected profile dump");
58 sz
= sizeof(gdump_old
);
59 assert_d_eq(mallctl("prof.gdump", &gdump_old
, &sz
, &gdump
,
61 "Unexpected mallctl failure while enabling prof.gdump");
63 did_prof_dump_open
= false;
64 s
= mallocx(chunksize
, 0);
65 assert_ptr_not_null(q
, "Unexpected mallocx() failure");
66 assert_true(did_prof_dump_open
, "Expected a profile dump");