[lib/Fuzzer] add a fuzzer test for memcmp (does not work yet)
authorKostya Serebryany <kcc@google.com>
Wed, 6 May 2015 22:36:00 +0000 (22:36 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 6 May 2015 22:36:00 +0000 (22:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236656 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/test/CMakeLists.txt
lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp [new file with mode: 0644]

index fb3bf20..1692734 100644 (file)
@@ -16,6 +16,7 @@ set(Tests
   )
 
 set(DFSanTests
+  DFSanMemcmpTest
   DFSanSimpleCmpTest
   )
 
diff --git a/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp b/lib/Fuzzer/test/dfsan/DFSanMemcmpTest.cpp
new file mode 100644 (file)
index 0000000..8f909fc
--- /dev/null
@@ -0,0 +1,8 @@
+// Simple test for a fuzzer. The fuzzer must find a particular string.
+#include <cstring>
+#include <cstdint>
+
+extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+  if (Size >= 10 && memcmp(Data, "0123456789", 10) == 0)
+    __builtin_trap();
+}