aboutsummaryrefslogtreecommitdiff
path: root/test/integration/mallocx.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/mallocx.c')
-rw-r--r--test/integration/mallocx.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index d82bf42..578c229 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -69,19 +69,28 @@ TEST_END
TEST_BEGIN(test_oom)
{
+ size_t hugemax;
+ bool oom;
+ void *ptrs[3];
+ unsigned i;
/*
- * It should be impossible to allocate two objects that each consume
- * more than half the virtual address space.
+ * It should be impossible to allocate three objects that each consume
+ * nearly half the virtual address space.
*/
- {
- size_t hugemax = get_huge_size(get_nhuge()-1);
- void *p = mallocx(hugemax, 0);
- if (p != NULL) {
- assert_ptr_null(mallocx(hugemax, 0),
- "Expected OOM for mallocx(size=%#zx, 0)", hugemax);
- dallocx(p, 0);
- }
+ hugemax = get_huge_size(get_nhuge()-1);
+ oom = false;
+ for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) {
+ ptrs[i] = mallocx(hugemax, 0);
+ if (ptrs[i] == NULL)
+ oom = true;
+ }
+ assert_true(oom,
+ "Expected OOM during series of calls to mallocx(size=%zu, 0)",
+ hugemax);
+ for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) {
+ if (ptrs[i] != NULL)
+ dallocx(ptrs[i], 0);
}
#if LG_SIZEOF_PTR == 3