summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-04-27 19:52:34 +0000
committerKostya Serebryany <kcc@google.com>2016-04-27 19:52:34 +0000
commit7018a1aaa49ea109b30a5440daac45e9dbbd4e0d (patch)
treebf399ab2d68b726744af6cac168654e2ae79440f /llvm/lib/Fuzzer/test
parent289bd5f6843ba3e7a7a1831ce59d25aedae75aae (diff)
downloadbcm5719-llvm-7018a1aaa49ea109b30a5440daac45e9dbbd4e0d.tar.gz
bcm5719-llvm-7018a1aaa49ea109b30a5440daac45e9dbbd4e0d.zip
[libFuzzer] disable leak detection if we have tried it for 1000 times w/o finding a leak
llvm-svn: 267770
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/AccumulateAllocationsTest.cpp17
-rw-r--r--llvm/lib/Fuzzer/test/CMakeLists.txt1
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/AccumulateAllocationsTest.cpp b/llvm/lib/Fuzzer/test/AccumulateAllocationsTest.cpp
new file mode 100644
index 00000000000..604d8fa299a
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/AccumulateAllocationsTest.cpp
@@ -0,0 +1,17 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Test with a more mallocs than frees, but no leak.
+#include <cstdint>
+#include <cstddef>
+
+const int kAllocatedPointersSize = 10000;
+int NumAllocatedPointers = 0;
+int *AllocatedPointers[kAllocatedPointersSize];
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (NumAllocatedPointers < kAllocatedPointersSize)
+ AllocatedPointers[NumAllocatedPointers++] = new int;
+ return 0;
+}
+
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt
index 3bda0a99baf..ff1a7349f1a 100644
--- a/llvm/lib/Fuzzer/test/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/CMakeLists.txt
@@ -13,6 +13,7 @@ set(DFSanTests
)
set(Tests
+ AccumulateAllocationsTest
BufferOverflowOnInput
CallerCalleeTest
CounterTest
OpenPOWER on IntegriCloud