1 // malloc should not fail if brk fails but mmap can still allocate
6 #include <sys/resource.h>
9 #define T(f) ((f)==0 || (t_error(#f " failed: %s\n", strerror(errno)), 0))
18 // fill memory, largest mmaped area is [p,p+n)
19 if (t_vmfill(&p, &n, 1) < 1 || n < 2*65536) {
20 t_error("vmfill failed\n");
24 T(t_setrlim(RLIMIT_DATA, 0));
26 // malloc should fail here
30 t_error("malloc(10000) succeeded after memory is filled\n");
31 else if (errno != ENOMEM)
32 t_error("malloc did not fail with ENOMEM, got %s\n", strerror(errno));
34 // make some space available for mmap
35 T(munmap(p+65536, 65536));
37 // malloc should succeed now
40 t_error("malloc(10000) failed (eventhough 64k is available to mmap): %s\n", strerror(errno));