summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-05-07 00:11:33 +0000
committerKostya Serebryany <kcc@google.com>2015-05-07 00:11:33 +0000
commita407ddef279b2ed5cedf305fbda3b9134b7a9559 (patch)
tree8d58070951f9feb5875bfed0a1630dd8a82df188 /llvm/lib/Fuzzer/test
parentfb8cf4087d21a56186426fe8339bf25e47a4001b (diff)
downloadbcm5719-llvm-a407ddef279b2ed5cedf305fbda3b9134b7a9559.tar.gz
bcm5719-llvm-a407ddef279b2ed5cedf305fbda3b9134b7a9559.zip
[lib/Fuzzer] add dfsan_weak_hook_memcmp, enable the test that uses it, simplify the test runner
llvm-svn: 236683
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/CxxTokensTest.cpp2
-rw-r--r--llvm/lib/Fuzzer/test/SimpleTest.cpp2
-rw-r--r--llvm/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp8
-rw-r--r--llvm/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp2
-rw-r--r--llvm/lib/Fuzzer/test/fuzzer.test23
5 files changed, 20 insertions, 17 deletions
diff --git a/llvm/lib/Fuzzer/test/CxxTokensTest.cpp b/llvm/lib/Fuzzer/test/CxxTokensTest.cpp
index 682ceb4f978..77d08b3d105 100644
--- a/llvm/lib/Fuzzer/test/CxxTokensTest.cpp
+++ b/llvm/lib/Fuzzer/test/CxxTokensTest.cpp
@@ -6,7 +6,7 @@
#include <iostream>
static void Found() {
- std::cout << "Found the target, exiting\n";
+ std::cout << "BINGO; Found the target, exiting\n";
exit(1);
}
diff --git a/llvm/lib/Fuzzer/test/SimpleTest.cpp b/llvm/lib/Fuzzer/test/SimpleTest.cpp
index 4e3501882d0..a891635a7f1 100644
--- a/llvm/lib/Fuzzer/test/SimpleTest.cpp
+++ b/llvm/lib/Fuzzer/test/SimpleTest.cpp
@@ -12,7 +12,7 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size > 1 && Data[1] == 'i') {
Sink = 2;
if (Size > 2 && Data[2] == '!') {
- std::cout << "Found the target, exiting\n";
+ std::cout << "BINGO; Found the target, exiting\n";
exit(0);
}
}
diff --git a/llvm/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp b/llvm/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp
index 8f909fcdba2..510a2439800 100644
--- a/llvm/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp
+++ b/llvm/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp
@@ -1,8 +1,12 @@
// Simple test for a fuzzer. The fuzzer must find a particular string.
#include <cstring>
#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- if (Size >= 10 && memcmp(Data, "0123456789", 10) == 0)
- __builtin_trap();
+ if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) {
+ fprintf(stderr, "BINGO\n");
+ exit(1);
+ }
}
diff --git a/llvm/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp b/llvm/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp
index d94d1defa00..ee378146dae 100644
--- a/llvm/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp
+++ b/llvm/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp
@@ -23,7 +23,7 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
z >= -10005 &&
z != -10003 &&
a == 4242) {
- fprintf(stderr, "Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n",
+ fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n",
Size, x, y, z, a);
exit(1);
}
diff --git a/llvm/lib/Fuzzer/test/fuzzer.test b/llvm/lib/Fuzzer/test/fuzzer.test
index 2a0e95fbea2..5249110b9a6 100644
--- a/llvm/lib/Fuzzer/test/fuzzer.test
+++ b/llvm/lib/Fuzzer/test/fuzzer.test
@@ -1,5 +1,6 @@
-RUN: ./LLVMFuzzer-SimpleTest 2>&1 | FileCheck %s --check-prefix=SimpleTest
-SimpleTest: Found the target, exiting
+CHECK: BINGO
+
+RUN: ./LLVMFuzzer-SimpleTest 2>&1 | FileCheck %s
RUN: not ./LLVMFuzzer-InfiniteTest -timeout=2 2>&1 | FileCheck %s --check-prefix=InfiniteTest
InfiniteTest: ALARM: working on the last Unit for
@@ -12,17 +13,15 @@ TimeoutTest: CRASHED; file written to timeout
RUN: not ./LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest
NullDerefTest: CRASHED; file written to crash-
-RUN: not ./LLVMFuzzer-FullCoverageSetTest -timeout=15 -seed=1 -mutate_depth=2 -use_full_coverage_set=1 2>&1 | FileCheck %s --check-prefix=FullCoverageSetTest
-FullCoverageSetTest: BINGO
+RUN: not ./LLVMFuzzer-FullCoverageSetTest -timeout=15 -seed=1 -mutate_depth=2 -use_full_coverage_set=1 2>&1 | FileCheck %s
+
+RUN: not ./LLVMFuzzer-FourIndependentBranchesTest -timeout=15 -seed=1 -use_coverage_pairs=1 2>&1 | FileCheck %s
+
+RUN: not ./LLVMFuzzer-CounterTest -use_counters=1 -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-FourIndependentBranchesTest -timeout=15 -seed=1 -use_coverage_pairs=1 2>&1 | FileCheck %s --check-prefix=FourIndependentBranchesTest
-FourIndependentBranchesTest: BINGO
+RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest -seed=1 -timeout=15 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-CounterTest -use_counters=1 -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s --check-prefix=CounterTest
-CounterTest: BINGO
+RUN: not ./LLVMFuzzer-DFSanMemcmpTest -seed=1 -timeout=15 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest -seed=1 -timeout=15 2>&1 | FileCheck %s --check-prefix=DFSanSimpleCmpTest
-DFSanSimpleCmpTest: Found the target:
+RUN: not ./LLVMFuzzer-CxxTokensTest -seed=1 -timeout=15 -tokens=%S/../cxx_fuzzer_tokens.txt 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-CxxTokensTest -seed=1 -timeout=15 -tokens=%S/../cxx_fuzzer_tokens.txt 2>&1 | FileCheck %s --check-prefix=CxxTokensTest
-CxxTokensTest: Found the target, exiting
OpenPOWER on IntegriCloud