annotate projects/compiler-rt/test/fuzzer/CxxStringEqTest.cpp @ 131:f476a9ba4795

http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
author mir3636
date Fri, 16 Feb 2018 21:02:11 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
1 // This file is distributed under the University of Illinois Open Source
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
2 // License. See LICENSE.TXT for details.
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
3
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
4 // Simple test for a fuzzer. Must find a specific string
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
5 // used in std::string operator ==.
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
6 #include <cstddef>
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
7 #include <cstdint>
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
8 #include <cstdlib>
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
9 #include <iostream>
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
10 #include <string>
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
11
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
12 static volatile int Sink;
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
13
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
14 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
15 std::string Str((const char*)Data, Size);
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
16 bool Eq = Str == "FooBar";
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
17 Sink = Str == "123456"; // Try to confuse the fuzzer
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
18 if (Eq) {
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
19 std::cout << "BINGO; Found the target, exiting\n";
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
20 std::cout.flush();
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
21 abort();
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
22 }
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
23 return 0;
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
24 }
f476a9ba4795 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff changeset
25