view gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* 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" } */