[asan] Do not use lambda in sanitizer lit tests.
[blocksruntime.git] / test / asan / TestCases / mmap_limit_mb.cc
blob92c114127e0411c15036f0c1efc3f354f79f47b4
1 // Test the mmap_limit_mb flag.
2 //
3 // RUN: %clangxx_asan -std=c++11 -O2 %s -o %t
4 // RUN: %t 100 16
5 // RUN: %t 100 1000000
6 // RUN: ASAN_OPTIONS=mmap_limit_mb=500 %t 100 16
7 // RUN: ASAN_OPTIONS=mmap_limit_mb=500 %t 100 1000000
8 // RUN: ASAN_OPTIONS=mmap_limit_mb=500 not %t 500 16 2>&1 | FileCheck %s
9 // RUN: ASAN_OPTIONS=mmap_limit_mb=500 not %t 500 1000000 2>&1 | FileCheck %s
11 #include <assert.h>
12 #include <stdlib.h>
13 #include <stdio.h>
15 #include <algorithm>
16 #include <vector>
18 int main(int argc, char **argv) {
19 assert(argc == 3);
20 long total_mb = atoi(argv[1]);
21 long allocation_size = atoi(argv[2]);
22 std::vector<char *> v;
23 for (long total = total_mb << 20; total > 0; total -= allocation_size)
24 v.push_back(new char[allocation_size]);
25 for (auto p : v) delete[] p;
26 printf("PASS\n");
27 // CHECK: AddressSanitizer CHECK failed{{.*}}total_mmaped{{.*}}mmap_limit_mb
28 return 0;