mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 05:33:06 +00:00
Change assert_* to expect_* in tests
```
grep -Irl assert_ test/ | xargs sed -i \
's/witness_assert/witness_do_not_replace/g';
grep -Irl assert_ test/ | xargs sed -i \
's/malloc_mutex_assert_owner/malloc_mutex_do_not_replace_owner/g';
grep -Ir assert_ test/ | grep -o "[_a-zA-Z]*assert_[_a-zA-Z]*" | \
grep -v "^assert_"; # confirm no output
grep -Irl assert_ test/ | xargs sed -i 's/assert_/expect_/g';
grep -Irl witness_do_not_replace test/ | xargs sed -i \
's/witness_do_not_replace/witness_assert/g';
grep -Irl malloc_mutex_do_not_replace_owner test/ | xargs sed -i \
's/malloc_mutex_do_not_replace_owner/malloc_mutex_assert_owner/g';
```
This commit is contained in:
@@ -5,14 +5,14 @@ prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
assert_d_ne(fd, -1, "Unexpected open() failure");
|
||||
expect_d_ne(fd, -1, "Unexpected open() failure");
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void
|
||||
set_prof_active(bool active) {
|
||||
assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,
|
||||
expect_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,
|
||||
sizeof(active)), 0, "Unexpected mallctl failure");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ get_lg_prof_sample(void) {
|
||||
size_t lg_prof_sample;
|
||||
size_t sz = sizeof(size_t);
|
||||
|
||||
assert_d_eq(mallctl("prof.lg_sample", (void *)&lg_prof_sample, &sz,
|
||||
expect_d_eq(mallctl("prof.lg_sample", (void *)&lg_prof_sample, &sz,
|
||||
NULL, 0), 0,
|
||||
"Unexpected mallctl failure while reading profiling sample rate");
|
||||
return lg_prof_sample;
|
||||
@@ -29,10 +29,10 @@ get_lg_prof_sample(void) {
|
||||
|
||||
static void
|
||||
do_prof_reset(size_t lg_prof_sample) {
|
||||
assert_d_eq(mallctl("prof.reset", NULL, NULL,
|
||||
expect_d_eq(mallctl("prof.reset", NULL, NULL,
|
||||
(void *)&lg_prof_sample, sizeof(size_t)), 0,
|
||||
"Unexpected mallctl failure while resetting profile data");
|
||||
assert_zu_eq(lg_prof_sample, get_lg_prof_sample(),
|
||||
expect_zu_eq(lg_prof_sample, get_lg_prof_sample(),
|
||||
"Expected profile sample rate change");
|
||||
}
|
||||
|
||||
@@ -44,22 +44,22 @@ TEST_BEGIN(test_prof_reset_basic) {
|
||||
test_skip_if(!config_prof);
|
||||
|
||||
sz = sizeof(size_t);
|
||||
assert_d_eq(mallctl("opt.lg_prof_sample", (void *)&lg_prof_sample_orig,
|
||||
expect_d_eq(mallctl("opt.lg_prof_sample", (void *)&lg_prof_sample_orig,
|
||||
&sz, NULL, 0), 0,
|
||||
"Unexpected mallctl failure while reading profiling sample rate");
|
||||
assert_zu_eq(lg_prof_sample_orig, 0,
|
||||
expect_zu_eq(lg_prof_sample_orig, 0,
|
||||
"Unexpected profiling sample rate");
|
||||
lg_prof_sample = get_lg_prof_sample();
|
||||
assert_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
expect_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
"Unexpected disagreement between \"opt.lg_prof_sample\" and "
|
||||
"\"prof.lg_sample\"");
|
||||
|
||||
/* Test simple resets. */
|
||||
for (i = 0; i < 2; i++) {
|
||||
assert_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0), 0,
|
||||
expect_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0), 0,
|
||||
"Unexpected mallctl failure while resetting profile data");
|
||||
lg_prof_sample = get_lg_prof_sample();
|
||||
assert_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
expect_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
"Unexpected profile sample rate change");
|
||||
}
|
||||
|
||||
@@ -68,14 +68,14 @@ TEST_BEGIN(test_prof_reset_basic) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
do_prof_reset(lg_prof_sample_next);
|
||||
lg_prof_sample = get_lg_prof_sample();
|
||||
assert_zu_eq(lg_prof_sample, lg_prof_sample_next,
|
||||
expect_zu_eq(lg_prof_sample, lg_prof_sample_next,
|
||||
"Expected profile sample rate change");
|
||||
lg_prof_sample_next = lg_prof_sample_orig;
|
||||
}
|
||||
|
||||
/* Make sure the test code restored prof.lg_sample. */
|
||||
lg_prof_sample = get_lg_prof_sample();
|
||||
assert_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
expect_zu_eq(lg_prof_sample_orig, lg_prof_sample,
|
||||
"Unexpected disagreement between \"opt.lg_prof_sample\" and "
|
||||
"\"prof.lg_sample\"");
|
||||
}
|
||||
@@ -100,31 +100,31 @@ TEST_BEGIN(test_prof_reset_cleanup) {
|
||||
|
||||
set_prof_active(true);
|
||||
|
||||
assert_zu_eq(prof_bt_count(), 0, "Expected 0 backtraces");
|
||||
expect_zu_eq(prof_bt_count(), 0, "Expected 0 backtraces");
|
||||
p = mallocx(1, 0);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
assert_zu_eq(prof_bt_count(), 1, "Expected 1 backtrace");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
expect_zu_eq(prof_bt_count(), 1, "Expected 1 backtrace");
|
||||
|
||||
prof_dump_header_orig = prof_dump_header;
|
||||
prof_dump_header = prof_dump_header_intercept;
|
||||
assert_false(prof_dump_header_intercepted, "Unexpected intercept");
|
||||
expect_false(prof_dump_header_intercepted, "Unexpected intercept");
|
||||
|
||||
assert_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
0, "Unexpected error while dumping heap profile");
|
||||
assert_true(prof_dump_header_intercepted, "Expected intercept");
|
||||
assert_u64_eq(cnt_all_copy.curobjs, 1, "Expected 1 allocation");
|
||||
expect_true(prof_dump_header_intercepted, "Expected intercept");
|
||||
expect_u64_eq(cnt_all_copy.curobjs, 1, "Expected 1 allocation");
|
||||
|
||||
assert_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0), 0,
|
||||
expect_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0), 0,
|
||||
"Unexpected error while resetting heap profile data");
|
||||
assert_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
0, "Unexpected error while dumping heap profile");
|
||||
assert_u64_eq(cnt_all_copy.curobjs, 0, "Expected 0 allocations");
|
||||
assert_zu_eq(prof_bt_count(), 1, "Expected 1 backtrace");
|
||||
expect_u64_eq(cnt_all_copy.curobjs, 0, "Expected 0 allocations");
|
||||
expect_zu_eq(prof_bt_count(), 1, "Expected 1 backtrace");
|
||||
|
||||
prof_dump_header = prof_dump_header_orig;
|
||||
|
||||
dallocx(p, 0);
|
||||
assert_zu_eq(prof_bt_count(), 0, "Expected 0 backtraces");
|
||||
expect_zu_eq(prof_bt_count(), 0, "Expected 0 backtraces");
|
||||
|
||||
set_prof_active(false);
|
||||
}
|
||||
@@ -145,13 +145,13 @@ thd_start(void *varg) {
|
||||
|
||||
for (i = 0; i < NALLOCS_PER_THREAD; i++) {
|
||||
if (i % RESET_INTERVAL == 0) {
|
||||
assert_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctl("prof.reset", NULL, NULL, NULL, 0),
|
||||
0, "Unexpected error while resetting heap profile "
|
||||
"data");
|
||||
}
|
||||
|
||||
if (i % DUMP_INTERVAL == 0) {
|
||||
assert_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctl("prof.dump", NULL, NULL, NULL, 0),
|
||||
0, "Unexpected error while dumping heap profile");
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ thd_start(void *varg) {
|
||||
*pp = NULL;
|
||||
}
|
||||
*pp = btalloc(1, thd_ind*NALLOCS_PER_THREAD + i);
|
||||
assert_ptr_not_null(*pp,
|
||||
expect_ptr_not_null(*pp,
|
||||
"Unexpected btalloc() failure");
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ TEST_BEGIN(test_prof_reset) {
|
||||
test_skip_if(!config_prof);
|
||||
|
||||
bt_count = prof_bt_count();
|
||||
assert_zu_eq(bt_count, 0,
|
||||
expect_zu_eq(bt_count, 0,
|
||||
"Unexpected pre-existing tdata structures");
|
||||
tdata_count = prof_tdata_count();
|
||||
|
||||
@@ -206,9 +206,9 @@ TEST_BEGIN(test_prof_reset) {
|
||||
thd_join(thds[i], NULL);
|
||||
}
|
||||
|
||||
assert_zu_eq(prof_bt_count(), bt_count,
|
||||
expect_zu_eq(prof_bt_count(), bt_count,
|
||||
"Unexpected bactrace count change");
|
||||
assert_zu_eq(prof_tdata_count(), tdata_count,
|
||||
expect_zu_eq(prof_tdata_count(), tdata_count,
|
||||
"Unexpected remaining tdata structures");
|
||||
|
||||
set_prof_active(false);
|
||||
@@ -246,19 +246,19 @@ TEST_BEGIN(test_xallocx) {
|
||||
|
||||
/* Allocate small object (which will be promoted). */
|
||||
p = ptrs[i] = mallocx(1, 0);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
|
||||
/* Reset profiling. */
|
||||
do_prof_reset(0);
|
||||
|
||||
/* Perform successful xallocx(). */
|
||||
sz = sallocx(p, 0);
|
||||
assert_zu_eq(xallocx(p, sz, 0, 0), sz,
|
||||
expect_zu_eq(xallocx(p, sz, 0, 0), sz,
|
||||
"Unexpected xallocx() failure");
|
||||
|
||||
/* Perform unsuccessful xallocx(). */
|
||||
nsz = nallocx(sz+1, 0);
|
||||
assert_zu_eq(xallocx(p, nsz, 0, 0), sz,
|
||||
expect_zu_eq(xallocx(p, nsz, 0, 0), sz,
|
||||
"Unexpected xallocx() success");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user