summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-03-17 01:33:16 +0000
committerKostya Serebryany <kcc@google.com>2017-03-17 01:33:16 +0000
commita52c8d0dafa436159de225b2d7c82f9b2d6ad650 (patch)
treeccc5b90f21521231960d13b5ddbd8663e0814e64 /llvm/lib
parenteecb0ec2ead8f8004d678539d79c9782ec0cbec8 (diff)
downloadbcm5719-llvm-a52c8d0dafa436159de225b2d7c82f9b2d6ad650.tar.gz
bcm5719-llvm-a52c8d0dafa436159de225b2d7c82f9b2d6ad650.zip
[libFuzzer] add a test with two different bugs
llvm-svn: 298030
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Fuzzer/test/CMakeLists.txt1
-rw-r--r--llvm/lib/Fuzzer/test/TwoDifferentBugsTest.cpp22
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt
index ab4ae92c1f4..2a31a801f9d 100644
--- a/llvm/lib/Fuzzer/test/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/CMakeLists.txt
@@ -128,6 +128,7 @@ set(Tests
TimeoutTest
TimeoutEmptyTest
TraceMallocTest
+ TwoDifferentBugsTest
)
if(APPLE OR MSVC)
diff --git a/llvm/lib/Fuzzer/test/TwoDifferentBugsTest.cpp b/llvm/lib/Fuzzer/test/TwoDifferentBugsTest.cpp
new file mode 100644
index 00000000000..42c0d192ba8
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/TwoDifferentBugsTest.cpp
@@ -0,0 +1,22 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Simple test for a fuzzer. This test may trigger two different bugs.
+#include <cstdint>
+#include <cstdlib>
+#include <cstddef>
+#include <iostream>
+
+static volatile int *Null = 0;
+
+void Foo() { Null[1] = 0; }
+void Bar() { Null[2] = 0; }
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size < 10 && Data[0] == 'H')
+ Foo();
+ if (Size >= 10 && Data[0] == 'H')
+ Bar();
+ return 0;
+}
+
OpenPOWER on IntegriCloud