Make mallocx() OOM test more robust.
Make mallocx() OOM testing work correctly even on systems that can allocate the majority of virtual address space in a single contiguous region.
This commit is contained in:
parent
d260f442ce
commit
03eb37e8fd
@ -52,9 +52,20 @@ TEST_BEGIN(test_oom)
|
||||
|
||||
hugemax = get_huge_size(get_nhuge()-1);
|
||||
|
||||
/* In practice hugemax is too large to be allocated. */
|
||||
assert_ptr_null(mallocx(hugemax, 0),
|
||||
"Expected OOM for mallocx(size=%#zx, 0)", hugemax);
|
||||
/*
|
||||
* It should be impossible to allocate two objects that each consume
|
||||
* more than half the virtual address space.
|
||||
*/
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = mallocx(hugemax, 0);
|
||||
if (p != NULL) {
|
||||
assert_ptr_null(mallocx(hugemax, 0),
|
||||
"Expected OOM for mallocx(size=%#zx, 0)", hugemax);
|
||||
dallocx(p, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if LG_SIZEOF_PTR == 3
|
||||
size = ZU(0x8000000000000000);
|
||||
|
Loading…
Reference in New Issue
Block a user