aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c
blob: 9dbbc85f4f30b5ccbf4bd7bb83a73001de1786c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Check that we properly report mmap failure. */

/* { dg-do run { target setrlimit } } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
/* { dg-require-effective-target hw } */
/* { dg-shouldfail "asan" } */

#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
#include <sys/resource.h>

static volatile void *x;

int main(int argc, char **argv) {
  struct rlimit mmap_resource_limit = { 0, 0 };
  if (setrlimit(RLIMIT_AS, &mmap_resource_limit)) return 1;
  x = malloc(10000000);
  return 0;
}

/* { dg-output "ERROR: Failed to mmap" } */