diff options
author | Kostya Serebryany <kcc@google.com> | 2014-04-14 14:51:01 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2014-04-14 14:51:01 +0000 |
commit | 36e713091c3aa1e27c0743663e4ca2ebf8e87066 (patch) | |
tree | f6bdfa5ec361aec9c1737fd342022febdf1164a9 /test | |
parent | 2c3f6b772a8da6795c49d838cfa7389b402281e8 (diff) | |
download | compiler-rt-36e713091c3aa1e27c0743663e4ca2ebf8e87066.tar.gz |
[asan] added internal flag mmap_limit_mb
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206178 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/asan/TestCases/mmap_limit_mb.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/asan/TestCases/mmap_limit_mb.cc b/test/asan/TestCases/mmap_limit_mb.cc new file mode 100644 index 000000000..cd8783b50 --- /dev/null +++ b/test/asan/TestCases/mmap_limit_mb.cc @@ -0,0 +1,30 @@ +// Test the mmap_limit_mb flag. +// +// RUN: %clangxx_asan -std=c++11 -O2 %s -o %t +// RUN: %t 100 16 +// RUN: %t 100 1000000 +// RUN: ASAN_OPTIONS=mmap_limit_mb=500 %t 100 16 +// RUN: ASAN_OPTIONS=mmap_limit_mb=500 %t 100 1000000 +// RUN: ASAN_OPTIONS=mmap_limit_mb=500 not %t 500 16 2>&1 | FileCheck %s +// RUN: ASAN_OPTIONS=mmap_limit_mb=500 not %t 500 1000000 2>&1 | FileCheck %s + +#include <assert.h> +#include <stdlib.h> +#include <stdio.h> + +#include <algorithm> +#include <vector> + +int main(int argc, char **argv) { + assert(argc == 3); + long total_mb = atoi(argv[1]); + long allocation_size = atoi(argv[2]); + std::vector<char *> v; + for (long total = total_mb << 20; total > 0; total -= allocation_size) + v.push_back(new char[allocation_size]); + std::for_each(v.begin(), v.end(), + [](std::vector<char *>::reference ref) { delete[] ref; }); + printf("PASS\n"); + // CHECK: AddressSanitizer CHECK failed{{.*}}total_mmaped{{.*}}mmap_limit_mb + return 0; +} |