Work around legitimate xallocx() failures during testing.

With the removal of subchunk size class infrastructure, there are no
large size classes that are guaranteed to be re-expandable in place
unless munmap() is disabled.  Work around these legitimate failures with
rallocx() fallback calls.  If there were no test configuration for which
the xallocx() calls succeeded, it would be important to override the
extent hooks for testing purposes, but by default these tests don't use
the rallocx() fallbacks on Linux, so test coverage is still sufficient.
This commit is contained in:
Jason Evans 2016-06-05 14:01:32 -07:00
parent 04942c3d90
commit 42faa9e3e0

View File

@ -249,8 +249,10 @@ TEST_BEGIN(test_extra_large)
assert_zu_ge(xallocx(p, smallmax, 0, flags), large1, assert_zu_ge(xallocx(p, smallmax, 0, flags), large1,
"Unexpected xallocx() behavior"); "Unexpected xallocx() behavior");
assert_zu_eq(xallocx(p, large3, 0, flags), large3, if (xallocx(p, large3, 0, flags) != large3) {
"Unexpected xallocx() behavior"); p = rallocx(p, large3, flags);
assert_ptr_not_null(p, "Unexpected rallocx() failure");
}
/* Test size decrease with non-zero extra. */ /* Test size decrease with non-zero extra. */
assert_zu_eq(xallocx(p, large1, large3 - large1, flags), large3, assert_zu_eq(xallocx(p, large1, large3 - large1, flags), large3,
"Unexpected xallocx() behavior"); "Unexpected xallocx() behavior");
@ -281,8 +283,10 @@ TEST_BEGIN(test_extra_large)
assert_zu_le(xallocx(p, large1, large3 - large1, flags), large3, assert_zu_le(xallocx(p, large1, large3 - large1, flags), large3,
"Unexpected xallocx() behavior"); "Unexpected xallocx() behavior");
assert_zu_eq(xallocx(p, large3, 0, flags), large3, if (xallocx(p, large3, 0, flags) != large3) {
"Unexpected xallocx() behavior"); p = rallocx(p, large3, flags);
assert_ptr_not_null(p, "Unexpected rallocx() failure");
}
/* Test size+extra overflow. */ /* Test size+extra overflow. */
assert_zu_le(xallocx(p, large3, largemax - large3 + 1, flags), largemax, assert_zu_le(xallocx(p, large3, largemax - large3 + 1, flags), largemax,
"Unexpected xallocx() behavior"); "Unexpected xallocx() behavior");
@ -360,8 +364,10 @@ test_zero(size_t szmin, size_t szmax)
for (sz = szmin; sz < szmax; sz = nsz) { for (sz = szmin; sz < szmax; sz = nsz) {
nsz = nallocx(sz+1, flags); nsz = nallocx(sz+1, flags);
assert_zu_eq(xallocx(p, sz+1, 0, flags), nsz, if (xallocx(p, sz+1, 0, flags) != nsz) {
"Unexpected xallocx() failure"); p = rallocx(p, sz+1, flags);
assert_ptr_not_null(p, "Unexpected rallocx() failure");
}
assert_false(validate_fill(p, FILL_BYTE, 0, sz), assert_false(validate_fill(p, FILL_BYTE, 0, sz),
"Memory not filled: sz=%zu", sz); "Memory not filled: sz=%zu", sz);
assert_false(validate_fill(p, 0x00, sz, nsz-sz), assert_false(validate_fill(p, 0x00, sz, nsz-sz),