]> git.proxmox.com Git - rustc.git/blame - src/jemalloc/test/unit/prof_idump.c
New upstream version 1.22.1+dfsg1
[rustc.git] / src / jemalloc / test / unit / prof_idump.c
CommitLineData
1a4d82fc
JJ
1#include "test/jemalloc_test.h"
2
1a4d82fc
JJ
3static bool did_prof_dump_open;
4
5static int
6prof_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
18TEST_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}
38TEST_END
39
40int
41main(void)
42{
43
44 return (test(
45 test_idump));
46}