Only replace the dump file opening function in test
This commit is contained in:
parent
d8cea87562
commit
f307b25804
@ -94,8 +94,8 @@ typedef int (prof_sys_thread_name_read_t)(char *buf, size_t limit);
|
||||
extern prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read;
|
||||
size_t prof_tdata_count(void);
|
||||
size_t prof_bt_count(void);
|
||||
typedef int (prof_dump_open_t)(bool, const char *);
|
||||
extern prof_dump_open_t *JET_MUTABLE prof_dump_open;
|
||||
typedef int (prof_dump_open_file_t)(const char *, int);
|
||||
extern prof_dump_open_file_t *JET_MUTABLE prof_dump_open_file;
|
||||
typedef bool (prof_dump_header_t)(tsdn_t *, bool, const prof_cnt_t *);
|
||||
extern prof_dump_header_t *JET_MUTABLE prof_dump_header;
|
||||
void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
|
||||
|
@ -467,13 +467,19 @@ prof_bt_count(void) {
|
||||
}
|
||||
|
||||
static int
|
||||
prof_dump_open_impl(bool propagate_err, const char *filename) {
|
||||
prof_dump_open_file_impl(const char *filename, int mode) {
|
||||
return creat(filename, mode);
|
||||
}
|
||||
prof_dump_open_file_t *JET_MUTABLE prof_dump_open_file =
|
||||
prof_dump_open_file_impl;
|
||||
|
||||
static int
|
||||
prof_dump_open(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
fd = creat(filename, 0644);
|
||||
fd = prof_dump_open_file(filename, 0644);
|
||||
if (fd == -1 && !propagate_err) {
|
||||
malloc_printf("<jemalloc>: creat(\"%s\"), 0644) failed\n",
|
||||
filename);
|
||||
malloc_printf("<jemalloc>: failed to open \"%s\"\n", filename);
|
||||
if (opt_abort) {
|
||||
abort();
|
||||
}
|
||||
@ -481,7 +487,6 @@ prof_dump_open_impl(bool propagate_err, const char *filename) {
|
||||
|
||||
return fd;
|
||||
}
|
||||
prof_dump_open_t *JET_MUTABLE prof_dump_open = prof_dump_open_impl;
|
||||
|
||||
static bool
|
||||
prof_dump_flush(bool propagate_err) {
|
||||
|
@ -6,11 +6,11 @@
|
||||
#define BT_COUNT_CHECK_INTERVAL 5
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
prof_dump_open_file_intercept(const char *filename, int mode) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
expect_d_ne(fd, -1, "Unexpected open() failure");
|
||||
assert_d_ne(fd, -1, "Unexpected open() failure");
|
||||
|
||||
return fd;
|
||||
}
|
||||
@ -62,7 +62,7 @@ TEST_BEGIN(test_idump) {
|
||||
sizeof(active)), 0,
|
||||
"Unexpected mallctl failure while activating profiling");
|
||||
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
prof_dump_open_file = prof_dump_open_file_intercept;
|
||||
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_args[i] = i;
|
||||
|
@ -3,13 +3,13 @@
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
prof_dump_open_file_intercept(const char *filename, int mode) {
|
||||
int fd;
|
||||
|
||||
did_prof_dump_open = true;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
expect_d_ne(fd, -1, "Unexpected open() failure");
|
||||
assert_d_ne(fd, -1, "Unexpected open() failure");
|
||||
|
||||
return fd;
|
||||
}
|
||||
@ -26,7 +26,7 @@ TEST_BEGIN(test_gdump) {
|
||||
sizeof(active)), 0,
|
||||
"Unexpected mallctl failure while activating profiling");
|
||||
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
prof_dump_open_file = prof_dump_open_file_intercept;
|
||||
|
||||
did_prof_dump_open = false;
|
||||
p = mallocx((1U << SC_LG_LARGE_MINCLASS), 0);
|
||||
|
@ -5,7 +5,7 @@
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
prof_dump_open_file_intercept(const char *filename, int mode) {
|
||||
int fd;
|
||||
|
||||
did_prof_dump_open = true;
|
||||
@ -15,7 +15,7 @@ prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
- 1), 0, "Dump file name should start with \"" TEST_PREFIX ".\"");
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
expect_d_ne(fd, -1, "Unexpected open() failure");
|
||||
assert_d_ne(fd, -1, "Unexpected open() failure");
|
||||
|
||||
return fd;
|
||||
}
|
||||
@ -38,7 +38,7 @@ TEST_BEGIN(test_idump) {
|
||||
sizeof(active)), 0,
|
||||
"Unexpected mallctl failure while activating profiling");
|
||||
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
prof_dump_open_file = prof_dump_open_file_intercept;
|
||||
|
||||
did_prof_dump_open = false;
|
||||
p = mallocx(1, 0);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
prof_dump_open_file_intercept(const char *filename, int mode) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
expect_d_ne(fd, -1, "Unexpected open() failure");
|
||||
assert_d_ne(fd, -1, "Unexpected open() failure");
|
||||
|
||||
return fd;
|
||||
}
|
||||
@ -276,7 +276,7 @@ TEST_END
|
||||
int
|
||||
main(void) {
|
||||
/* Intercept dumping prior to running any tests. */
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
prof_dump_open_file = prof_dump_open_file_intercept;
|
||||
|
||||
return test_no_reentrancy(
|
||||
test_prof_reset_basic,
|
||||
|
Loading…
Reference in New Issue
Block a user