Add more tests for extent hooks failure paths.
This commit is contained in:
parent
26a8f82c48
commit
6e841f618a
@ -988,9 +988,12 @@ extent_recycle_split(tsdn_t *tsdn, arena_t *arena,
|
|||||||
extent_deregister(tsdn, to_salvage);
|
extent_deregister(tsdn, to_salvage);
|
||||||
}
|
}
|
||||||
if (to_leak != NULL) {
|
if (to_leak != NULL) {
|
||||||
|
void *leak = extent_base_get(to_leak);
|
||||||
extent_deregister(tsdn, to_leak);
|
extent_deregister(tsdn, to_leak);
|
||||||
extents_leak(tsdn, arena, r_extent_hooks, extents,
|
extents_leak(tsdn, arena, r_extent_hooks, extents,
|
||||||
to_leak, growing_retained);
|
to_leak, growing_retained);
|
||||||
|
assert(extent_lock_from_addr(tsdn, rtree_ctx, leak)
|
||||||
|
== NULL);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -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");
|
"extent_hooks should be same as pointer used to set hooks");
|
||||||
assert_ptr_eq(extent_hooks->merge, extent_merge_hook,
|
assert_ptr_eq(extent_hooks->merge, extent_merge_hook,
|
||||||
"Wrong hook function");
|
"Wrong hook function");
|
||||||
|
assert_ptr_eq((void *)((uintptr_t)addr_a + size_a), addr_b,
|
||||||
|
"Extents not mergeable");
|
||||||
called_merge = true;
|
called_merge = true;
|
||||||
if (!try_merge) {
|
if (!try_merge) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -98,7 +98,8 @@ test_extent_body(unsigned arena_ind) {
|
|||||||
dallocx(p, flags);
|
dallocx(p, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_BEGIN(test_extent_manual_hook) {
|
static void
|
||||||
|
test_manual_hook_body(void) {
|
||||||
unsigned arena_ind;
|
unsigned arena_ind;
|
||||||
size_t old_size, new_size, sz;
|
size_t old_size, new_size, sz;
|
||||||
size_t hooks_mib[3];
|
size_t hooks_mib[3];
|
||||||
@ -139,8 +140,9 @@ TEST_BEGIN(test_extent_manual_hook) {
|
|||||||
assert_ptr_ne(old_hooks->merge, extent_merge_hook,
|
assert_ptr_ne(old_hooks->merge, extent_merge_hook,
|
||||||
"Unexpected extent_hooks error");
|
"Unexpected extent_hooks error");
|
||||||
|
|
||||||
test_skip_if(check_background_thread_enabled());
|
if (check_background_thread_enabled()) {
|
||||||
test_extent_body(arena_ind);
|
test_extent_body(arena_ind);
|
||||||
|
}
|
||||||
|
|
||||||
/* Restore extent hooks. */
|
/* Restore extent hooks. */
|
||||||
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
|
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,
|
assert_ptr_eq(old_hooks->merge, default_hooks->merge,
|
||||||
"Unexpected extent_hooks error");
|
"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_END
|
||||||
|
|
||||||
TEST_BEGIN(test_extent_auto_hook) {
|
TEST_BEGIN(test_extent_auto_hook) {
|
||||||
|
Loading…
Reference in New Issue
Block a user