diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:07:37 +0000 |
commit | b485aab7e71c1625cfc27e0f92c9509f42378458 (patch) | |
tree | ae9abe108601079d1679194de237c9a435ae5b55 /src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.tar.xz netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.zip |
Adding upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c')
-rw-r--r-- | src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c b/src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c new file mode 100644 index 000000000..455ac5297 --- /dev/null +++ b/src/fluent-bit/lib/jemalloc-5.3.0/test/unit/prof_idump.c @@ -0,0 +1,57 @@ +#include "test/jemalloc_test.h" + +#include "jemalloc/internal/prof_sys.h" + +#define TEST_PREFIX "test_prefix" + +static bool did_prof_dump_open; + +static int +prof_dump_open_file_intercept(const char *filename, int mode) { + 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); + assert_d_ne(fd, -1, "Unexpected open() failure"); + + return fd; +} + +TEST_BEGIN(test_idump) { + bool active; + void *p; + + const char *test_prefix = TEST_PREFIX; + + test_skip_if(!config_prof); + + active = true; + + expect_d_eq(mallctl("prof.prefix", NULL, NULL, (void *)&test_prefix, + sizeof(test_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_file = prof_dump_open_file_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); +} |