summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-04-17 20:58:21 +0000
committerKostya Serebryany <kcc@google.com>2017-04-17 20:58:21 +0000
commitac7a9eae0bff0067f7e89f31c6d9be85bbbae828 (patch)
treeede5b08f193d3d6f419aff6c49551126ead11f99 /llvm/lib/Fuzzer/test
parentdcb52b167ae374b23d3f0e37cac6249257927c9d (diff)
downloadbcm5719-llvm-ac7a9eae0bff0067f7e89f31c6d9be85bbbae828.tar.gz
bcm5719-llvm-ac7a9eae0bff0067f7e89f31c6d9be85bbbae828.zip
[libFuzzer] experimental option -cleanse_crash: tries to replace all bytes in a crash reproducer with garbage, while still preserving the crash
llvm-svn: 300498
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/CMakeLists.txt1
-rw-r--r--llvm/lib/Fuzzer/test/CleanseTest.cpp16
-rw-r--r--llvm/lib/Fuzzer/test/cleanse.test3
3 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt
index f72bc3909a3..cd049d3f03d 100644
--- a/llvm/lib/Fuzzer/test/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/CMakeLists.txt
@@ -80,6 +80,7 @@ set(Tests
BogusInitializeTest
BufferOverflowOnInput
CallerCalleeTest
+ CleanseTest
CounterTest
CustomCrossOverAndMutateTest
CustomCrossOverTest
diff --git a/llvm/lib/Fuzzer/test/CleanseTest.cpp b/llvm/lib/Fuzzer/test/CleanseTest.cpp
new file mode 100644
index 00000000000..faea8dcb3c3
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/CleanseTest.cpp
@@ -0,0 +1,16 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Test the the fuzzer is able to 'cleanse' the reproducer
+// by replacing all irrelevant bytes with garbage.
+#include <cstdint>
+#include <cstdlib>
+#include <cstddef>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size >= 20 && Data[1] == '1' && Data[5] == '5' && Data[10] == 'A' &&
+ Data[19] == 'Z')
+ abort();
+ return 0;
+}
+
diff --git a/llvm/lib/Fuzzer/test/cleanse.test b/llvm/lib/Fuzzer/test/cleanse.test
new file mode 100644
index 00000000000..ad08591d2fa
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/cleanse.test
@@ -0,0 +1,3 @@
+RUN: echo -n 0123456789ABCDEFGHIZ > %t-in
+RUN: LLVMFuzzer-CleanseTest -cleanse_crash=1 %t-in -exact_artifact_path=%t-out
+RUN: echo -n ' 1 5 A Z' | diff - %t-out
OpenPOWER on IntegriCloud