Add more tests for extent hooks failure paths.
This commit is contained in:
@@ -266,6 +266,8 @@ extent_merge_hook(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
|
||||
"extent_hooks should be same as pointer used to set hooks");
|
||||
assert_ptr_eq(extent_hooks->merge, extent_merge_hook,
|
||||
"Wrong hook function");
|
||||
assert_ptr_eq((void *)((uintptr_t)addr_a + size_a), addr_b,
|
||||
"Extents not mergeable");
|
||||
called_merge = true;
|
||||
if (!try_merge) {
|
||||
return true;
|
||||
|
@@ -98,7 +98,8 @@ test_extent_body(unsigned arena_ind) {
|
||||
dallocx(p, flags);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_extent_manual_hook) {
|
||||
static void
|
||||
test_manual_hook_body(void) {
|
||||
unsigned arena_ind;
|
||||
size_t old_size, new_size, sz;
|
||||
size_t hooks_mib[3];
|
||||
@@ -139,8 +140,9 @@ TEST_BEGIN(test_extent_manual_hook) {
|
||||
assert_ptr_ne(old_hooks->merge, extent_merge_hook,
|
||||
"Unexpected extent_hooks error");
|
||||
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
test_extent_body(arena_ind);
|
||||
if (check_background_thread_enabled()) {
|
||||
test_extent_body(arena_ind);
|
||||
}
|
||||
|
||||
/* Restore extent hooks. */
|
||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
|
||||
@@ -165,6 +167,21 @@ TEST_BEGIN(test_extent_manual_hook) {
|
||||
assert_ptr_eq(old_hooks->merge, default_hooks->merge,
|
||||
"Unexpected extent_hooks error");
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_extent_manual_hook) {
|
||||
test_manual_hook_body();
|
||||
|
||||
/* Test failure paths. */
|
||||
try_split = false;
|
||||
test_manual_hook_body();
|
||||
try_merge = false;
|
||||
test_manual_hook_body();
|
||||
try_purge_lazy = false;
|
||||
try_purge_forced = false;
|
||||
test_manual_hook_body();
|
||||
|
||||
try_split = try_merge = try_purge_lazy = try_purge_forced = true;
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_extent_auto_hook) {
|
||||
|
Reference in New Issue
Block a user