summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/AFLDriverTest.cpp12
-rw-r--r--llvm/lib/Fuzzer/test/CMakeLists.txt13
-rw-r--r--llvm/lib/Fuzzer/test/afl-driver.test10
3 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/AFLDriverTest.cpp b/llvm/lib/Fuzzer/test/AFLDriverTest.cpp
new file mode 100644
index 00000000000..9ae18cb6cb9
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/AFLDriverTest.cpp
@@ -0,0 +1,12 @@
+#include <stdint.h>
+#include <stdlib.h>
+
+extern "C" void __afl_manual_init() {}
+
+extern "C" int __afl_persistent_loop(unsigned int) {
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ return 0;
+}
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt
index 9f95657b978..c5520b33909 100644
--- a/llvm/lib/Fuzzer/test/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/CMakeLists.txt
@@ -110,6 +110,19 @@ foreach(Test ${Tests})
endforeach()
###############################################################################
+# AFL Driver test
+###############################################################################
+
+add_executable(AFLDriverTest
+ AFLDriverTest.cpp ../afl/afl_driver.cpp)
+
+set_target_properties(AFLDriverTest
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY
+ "${CMAKE_BINARY_DIR}/lib/Fuzzer/test"
+ )
+set(TestBinaries ${TestBinaries} AFLDriverTest)
+
+###############################################################################
# Unit tests
###############################################################################
diff --git a/llvm/lib/Fuzzer/test/afl-driver.test b/llvm/lib/Fuzzer/test/afl-driver.test
new file mode 100644
index 00000000000..6cff8e34ec3
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/afl-driver.test
@@ -0,0 +1,10 @@
+; Test that not specifying a file isn't broken.
+RUN: unset AFL_DRIVER_STDERR_DUPLICATE_FILENAME
+RUN: AFLDriverTest
+
+; Test that specifying an invalid file causes a crash.
+RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%T" not --crash AFLDriverTest
+
+; Test that a file is created when specified as the duplicate stderr.
+RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t AFLDriverTest
+RUN: stat %t
OpenPOWER on IntegriCloud