1570af302Sopenharmony_ci#include <stdlib.h> 2570af302Sopenharmony_ci#include <string.h> 3570af302Sopenharmony_ci#include <errno.h> 4570af302Sopenharmony_ci#include <sys/resource.h> 5570af302Sopenharmony_ci#include "test.h" 6570af302Sopenharmony_ci 7570af302Sopenharmony_ciint t_memfill() 8570af302Sopenharmony_ci{ 9570af302Sopenharmony_ci int r = 0; 10570af302Sopenharmony_ci /* alloc mmap space with PROT_NONE */ 11570af302Sopenharmony_ci if (t_vmfill(0,0,0) < 0) { 12570af302Sopenharmony_ci t_error("vmfill failed: %s\n", strerror(errno)); 13570af302Sopenharmony_ci r = -1; 14570af302Sopenharmony_ci } 15570af302Sopenharmony_ci /* limit brk space */ 16570af302Sopenharmony_ci if (t_setrlim(RLIMIT_DATA, 0) < 0) 17570af302Sopenharmony_ci r = -1; 18570af302Sopenharmony_ci if (!r) 19570af302Sopenharmony_ci /* use up libc reserves if any */ 20570af302Sopenharmony_ci while (malloc(1)); 21570af302Sopenharmony_ci return r; 22570af302Sopenharmony_ci} 23