summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-07-16 23:22:54 +0000
committerMatt Morehouse <mascasa@google.com>2018-07-16 23:22:54 +0000
commit2dad1b7d1d75e6cf0d337744c6c133c821d3dcff (patch)
treeb68d67c16dc7fceb8a5788e19a705ad59b28c3b2 /test
parent37f6de13ac15a9a138a9ee0c64b1fc63b9f52029 (diff)
[libFuzzer] Avoid STL in MSan test.
Summary: STL can cause MSan false positives if lib[std]c++ isn't instrumented with MSan. Reviewers: kcc Reviewed By: kcc Subscribers: Dor1s, llvm-commits Differential Revision: https://reviews.llvm.org/D49404 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/fuzzer/SimpleTestStdio.cpp26
-rw-r--r--test/fuzzer/msan.test2
2 files changed, 27 insertions, 1 deletions
diff --git a/test/fuzzer/SimpleTestStdio.cpp b/test/fuzzer/SimpleTestStdio.cpp
new file mode 100644
index 000000000..ed7fe1cb3
--- /dev/null
+++ b/test/fuzzer/SimpleTestStdio.cpp
@@ -0,0 +1,26 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Simple test for a fuzzer. The fuzzer must find the string "Hi!".
+#include <assert.h>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+
+static volatile int Sink;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ assert(Data);
+ if (Size > 0 && Data[0] == 'H') {
+ Sink = 1;
+ if (Size > 1 && Data[1] == 'i') {
+ Sink = 2;
+ if (Size > 2 && Data[2] == '!') {
+ fprintf(stderr, "BINGO; Found the target, exiting\n");
+ exit(0);
+ }
+ }
+ }
+ return 0;
+}
+
diff --git a/test/fuzzer/msan.test b/test/fuzzer/msan.test
index d16a2514c..2e0339bb8 100644
--- a/test/fuzzer/msan.test
+++ b/test/fuzzer/msan.test
@@ -1,5 +1,5 @@
REQUIRES: msan
-RUN: %msan_compiler %S/SimpleTest.cpp -o %t
+RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
RUN: not %run %t -seed=1 -runs=10000000 2>&1 | FileCheck %s --check-prefix=NO-REPORT
RUN: %msan_compiler %S/SimpleCmpTest.cpp -o %t