mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +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:
@@ -10,7 +10,7 @@ check_background_thread_enabled(void) {
|
||||
if (ret == ENOENT) {
|
||||
return false;
|
||||
}
|
||||
assert_d_eq(ret, 0, "Unexpected mallctl error");
|
||||
expect_d_eq(ret, 0, "Unexpected mallctl error");
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@@ -27,16 +27,16 @@ test_extent_body(unsigned arena_ind) {
|
||||
|
||||
/* Get large size classes. */
|
||||
sz = sizeof(size_t);
|
||||
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
|
||||
expect_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
|
||||
0), 0, "Unexpected arenas.lextent.0.size failure");
|
||||
assert_d_eq(mallctl("arenas.lextent.1.size", (void *)&large1, &sz, NULL,
|
||||
expect_d_eq(mallctl("arenas.lextent.1.size", (void *)&large1, &sz, NULL,
|
||||
0), 0, "Unexpected arenas.lextent.1.size failure");
|
||||
assert_d_eq(mallctl("arenas.lextent.2.size", (void *)&large2, &sz, NULL,
|
||||
expect_d_eq(mallctl("arenas.lextent.2.size", (void *)&large2, &sz, NULL,
|
||||
0), 0, "Unexpected arenas.lextent.2.size failure");
|
||||
|
||||
/* Test dalloc/decommit/purge cascade. */
|
||||
purge_miblen = sizeof(purge_mib)/sizeof(size_t);
|
||||
assert_d_eq(mallctlnametomib("arena.0.purge", purge_mib, &purge_miblen),
|
||||
expect_d_eq(mallctlnametomib("arena.0.purge", purge_mib, &purge_miblen),
|
||||
0, "Unexpected mallctlnametomib() failure");
|
||||
purge_mib[1] = (size_t)arena_ind;
|
||||
called_alloc = false;
|
||||
@@ -44,22 +44,22 @@ test_extent_body(unsigned arena_ind) {
|
||||
try_dalloc = false;
|
||||
try_decommit = false;
|
||||
p = mallocx(large0 * 2, flags);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
assert_true(called_alloc, "Expected alloc call");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_true(called_alloc, "Expected alloc call");
|
||||
called_dalloc = false;
|
||||
called_decommit = false;
|
||||
did_purge_lazy = false;
|
||||
did_purge_forced = false;
|
||||
called_split = false;
|
||||
xallocx_success_a = (xallocx(p, large0, 0, flags) == large0);
|
||||
assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
||||
0, "Unexpected arena.%u.purge error", arena_ind);
|
||||
if (xallocx_success_a) {
|
||||
assert_true(called_dalloc, "Expected dalloc call");
|
||||
assert_true(called_decommit, "Expected decommit call");
|
||||
assert_true(did_purge_lazy || did_purge_forced,
|
||||
expect_true(called_dalloc, "Expected dalloc call");
|
||||
expect_true(called_decommit, "Expected decommit call");
|
||||
expect_true(did_purge_lazy || did_purge_forced,
|
||||
"Expected purge");
|
||||
assert_true(called_split, "Expected split call");
|
||||
expect_true(called_split, "Expected split call");
|
||||
}
|
||||
dallocx(p, flags);
|
||||
try_dalloc = true;
|
||||
@@ -68,25 +68,25 @@ test_extent_body(unsigned arena_ind) {
|
||||
try_dalloc = false;
|
||||
try_decommit = true;
|
||||
p = mallocx(large0 * 2, flags);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
did_decommit = false;
|
||||
did_commit = false;
|
||||
called_split = false;
|
||||
did_split = false;
|
||||
did_merge = false;
|
||||
xallocx_success_b = (xallocx(p, large0, 0, flags) == large0);
|
||||
assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
||||
expect_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
||||
0, "Unexpected arena.%u.purge error", arena_ind);
|
||||
if (xallocx_success_b) {
|
||||
assert_true(did_split, "Expected split");
|
||||
expect_true(did_split, "Expected split");
|
||||
}
|
||||
xallocx_success_c = (xallocx(p, large0 * 2, 0, flags) == large0 * 2);
|
||||
if (did_split) {
|
||||
assert_b_eq(did_decommit, did_commit,
|
||||
expect_b_eq(did_decommit, did_commit,
|
||||
"Expected decommit/commit match");
|
||||
}
|
||||
if (xallocx_success_b && xallocx_success_c) {
|
||||
assert_true(did_merge, "Expected merge");
|
||||
expect_true(did_merge, "Expected merge");
|
||||
}
|
||||
dallocx(p, flags);
|
||||
try_dalloc = true;
|
||||
@@ -94,7 +94,7 @@ test_extent_body(unsigned arena_ind) {
|
||||
|
||||
/* Make sure non-large allocation succeeds. */
|
||||
p = mallocx(42, flags);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
dallocx(p, flags);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ test_manual_hook_auto_arena(void) {
|
||||
|
||||
sz = sizeof(unsigned);
|
||||
/* Get number of auto arenas. */
|
||||
assert_d_eq(mallctl("opt.narenas", (void *)&narenas, &sz, NULL, 0),
|
||||
expect_d_eq(mallctl("opt.narenas", (void *)&narenas, &sz, NULL, 0),
|
||||
0, "Unexpected mallctl() failure");
|
||||
if (narenas == 1) {
|
||||
return;
|
||||
@@ -118,18 +118,18 @@ test_manual_hook_auto_arena(void) {
|
||||
|
||||
/* Install custom extent hooks on arena 1 (might not be initialized). */
|
||||
hooks_miblen = sizeof(hooks_mib)/sizeof(size_t);
|
||||
assert_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
||||
expect_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
||||
&hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
|
||||
hooks_mib[1] = 1;
|
||||
old_size = sizeof(extent_hooks_t *);
|
||||
new_hooks = &hooks;
|
||||
new_size = sizeof(extent_hooks_t *);
|
||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
&old_size, (void *)&new_hooks, new_size), 0,
|
||||
"Unexpected extent_hooks error");
|
||||
static bool auto_arena_created = false;
|
||||
if (old_hooks != &hooks) {
|
||||
assert_b_eq(auto_arena_created, false,
|
||||
expect_b_eq(auto_arena_created, false,
|
||||
"Expected auto arena 1 created only once.");
|
||||
auto_arena_created = true;
|
||||
}
|
||||
@@ -146,35 +146,35 @@ test_manual_hook_body(void) {
|
||||
extent_hooks_prep();
|
||||
|
||||
sz = sizeof(unsigned);
|
||||
assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
|
||||
expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
|
||||
0, "Unexpected mallctl() failure");
|
||||
|
||||
/* Install custom extent hooks. */
|
||||
hooks_miblen = sizeof(hooks_mib)/sizeof(size_t);
|
||||
assert_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
||||
expect_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
||||
&hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
|
||||
hooks_mib[1] = (size_t)arena_ind;
|
||||
old_size = sizeof(extent_hooks_t *);
|
||||
new_hooks = &hooks;
|
||||
new_size = sizeof(extent_hooks_t *);
|
||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
&old_size, (void *)&new_hooks, new_size), 0,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->alloc, extent_alloc_hook,
|
||||
expect_ptr_ne(old_hooks->alloc, extent_alloc_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->dalloc, extent_dalloc_hook,
|
||||
expect_ptr_ne(old_hooks->dalloc, extent_dalloc_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->commit, extent_commit_hook,
|
||||
expect_ptr_ne(old_hooks->commit, extent_commit_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->decommit, extent_decommit_hook,
|
||||
expect_ptr_ne(old_hooks->decommit, extent_decommit_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->purge_lazy, extent_purge_lazy_hook,
|
||||
expect_ptr_ne(old_hooks->purge_lazy, extent_purge_lazy_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->purge_forced, extent_purge_forced_hook,
|
||||
expect_ptr_ne(old_hooks->purge_forced, extent_purge_forced_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->split, extent_split_hook,
|
||||
expect_ptr_ne(old_hooks->split, extent_split_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_ne(old_hooks->merge, extent_merge_hook,
|
||||
expect_ptr_ne(old_hooks->merge, extent_merge_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
|
||||
if (!check_background_thread_enabled()) {
|
||||
@@ -182,26 +182,26 @@ test_manual_hook_body(void) {
|
||||
}
|
||||
|
||||
/* Restore extent hooks. */
|
||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
|
||||
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
|
||||
(void *)&old_hooks, new_size), 0, "Unexpected extent_hooks error");
|
||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
||||
&old_size, NULL, 0), 0, "Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks, default_hooks, "Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->alloc, default_hooks->alloc,
|
||||
expect_ptr_eq(old_hooks, default_hooks, "Unexpected extent_hooks error");
|
||||
expect_ptr_eq(old_hooks->alloc, default_hooks->alloc,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->dalloc, default_hooks->dalloc,
|
||||
expect_ptr_eq(old_hooks->dalloc, default_hooks->dalloc,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->commit, default_hooks->commit,
|
||||
expect_ptr_eq(old_hooks->commit, default_hooks->commit,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->decommit, default_hooks->decommit,
|
||||
expect_ptr_eq(old_hooks->decommit, default_hooks->decommit,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->purge_lazy, default_hooks->purge_lazy,
|
||||
expect_ptr_eq(old_hooks->purge_lazy, default_hooks->purge_lazy,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->purge_forced, default_hooks->purge_forced,
|
||||
expect_ptr_eq(old_hooks->purge_forced, default_hooks->purge_forced,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->split, default_hooks->split,
|
||||
expect_ptr_eq(old_hooks->split, default_hooks->split,
|
||||
"Unexpected extent_hooks error");
|
||||
assert_ptr_eq(old_hooks->merge, default_hooks->merge,
|
||||
expect_ptr_eq(old_hooks->merge, default_hooks->merge,
|
||||
"Unexpected extent_hooks error");
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ TEST_BEGIN(test_extent_auto_hook) {
|
||||
sz = sizeof(unsigned);
|
||||
new_hooks = &hooks;
|
||||
new_size = sizeof(extent_hooks_t *);
|
||||
assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz,
|
||||
expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz,
|
||||
(void *)&new_hooks, new_size), 0, "Unexpected mallctl() failure");
|
||||
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
|
||||
Reference in New Issue
Block a user