aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Fuzzer/test/NthRunCrashTest.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-02-12 02:32:03 +0000
committerKostya Serebryany <kcc@google.com>2016-02-12 02:32:03 +0000
commit9d14e4bb1523f9d29ea1f26af7d0294013682cea (patch)
tree52b0cd362b8385ac0705ecc0a31886f17e2927e5 /llvm/lib/Fuzzer/test/NthRunCrashTest.cpp
parent39a84d0b9bd4865ea01e8c6d6c99d8f9d294da81 (diff)
downloadllvm-9d14e4bb1523f9d29ea1f26af7d0294013682cea.zip
llvm-9d14e4bb1523f9d29ea1f26af7d0294013682cea.tar.gz
llvm-9d14e4bb1523f9d29ea1f26af7d0294013682cea.tar.bz2
[libFuzzer] make -runs=N flag also affect the simple runner (will execute every input N times)
llvm-svn: 260649
Diffstat (limited to 'llvm/lib/Fuzzer/test/NthRunCrashTest.cpp')
-rw-r--r--llvm/lib/Fuzzer/test/NthRunCrashTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/NthRunCrashTest.cpp b/llvm/lib/Fuzzer/test/NthRunCrashTest.cpp
new file mode 100644
index 0000000..03d03d0
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/NthRunCrashTest.cpp
@@ -0,0 +1,15 @@
+// Crash on the N-th execution.
+#include <cstdint>
+#include <cstddef>
+#include <iostream>
+
+static int Counter;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Counter++ == 1000) {
+ std::cout << "BINGO; Found the target, exiting\n";
+ exit(1);
+ }
+ return 0;
+}
+