OSDN Git Service

Update aosp/master LLVM for rebase to r256229
[android-x86/external-llvm.git] / lib / Fuzzer / test / SimpleTest.cpp
1 // Simple test for a fuzzer. The fuzzer must find the string "Hi!".
2 #include <assert.h>
3 #include <cstdint>
4 #include <cstdlib>
5 #include <cstddef>
6 #include <iostream>
7
8 static volatile int Sink;
9
10 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
11   assert(Data);
12   if (Size > 0 && Data[0] == 'H') {
13     Sink = 1;
14     if (Size > 1 && Data[1] == 'i') {
15       Sink = 2;
16       if (Size > 2 && Data[2] == '!') {
17         std::cout << "BINGO; Found the target, exiting\n";
18         exit(0);
19       }
20     }
21   }
22   return 0;
23 }
24