MCPcopy Create free account
hub / github.com/F-Stack/f-stack / TEST_BEGIN

Function TEST_BEGIN

app/redis-6.2.6/deps/jemalloc/test/integration/mallocx.c:72–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 ZU(PTRDIFF_MAX)+1);
71}
72TEST_END
73
74TEST_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}
114TEST_END
115
116TEST_BEGIN(test_basic) {

Callers

nothing calls this directly

Calls 5

strcmpFunction · 0.85
test_skipFunction · 0.85
get_large_sizeFunction · 0.70
get_nlargeFunction · 0.70
purgeFunction · 0.70

Tested by

no test coverage detected