| 70 | ZU(PTRDIFF_MAX)+1); |
| 71 | } |
| 72 | TEST_END |
| 73 | |
| 74 | TEST_BEGIN(test_oom) { |
| 75 | size_t largemax; |
| 76 | bool oom; |
| 77 | void *ptrs[3]; |
| 78 | unsigned i; |
| 79 | |
| 80 | /* |
| 81 | * It should be impossible to allocate three objects that each consume |
| 82 | * nearly half the virtual address space. |
| 83 | */ |
| 84 | largemax = get_large_size(get_nlarge()-1); |
| 85 | oom = false; |
| 86 | for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) { |
| 87 | ptrs[i] = mallocx(largemax, 0); |
| 88 | if (ptrs[i] == NULL) { |
| 89 | oom = true; |
| 90 | } |
| 91 | } |
| 92 | assert_true(oom, |
| 93 | "Expected OOM during series of calls to mallocx(size=%zu, 0)", |
| 94 | largemax); |
| 95 | for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) { |
| 96 | if (ptrs[i] != NULL) { |
| 97 | dallocx(ptrs[i], 0); |
| 98 | } |
| 99 | } |
| 100 | purge(); |
| 101 | |
| 102 | #if LG_SIZEOF_PTR == 3 |
| 103 | assert_ptr_null(mallocx(0x8000000000000000ULL, |
| 104 | MALLOCX_ALIGN(0x8000000000000000ULL)), |
| 105 | "Expected OOM for mallocx()"); |
| 106 | assert_ptr_null(mallocx(0x8000000000000000ULL, |
| 107 | MALLOCX_ALIGN(0x80000000)), |
| 108 | "Expected OOM for mallocx()"); |
| 109 | #else |
| 110 | assert_ptr_null(mallocx(0x80000000UL, MALLOCX_ALIGN(0x80000000UL)), |
| 111 | "Expected OOM for mallocx()"); |
| 112 | #endif |
| 113 | } |
| 114 | TEST_END |
| 115 | |
| 116 | TEST_BEGIN(test_basic) { |
nothing calls this directly
no test coverage detected