20c80674366c579852625c7c78a744a6bd28532e
[oota-llvm.git] / lib / Fuzzer / test / SimpleDictionaryTest.cpp
1 // Simple test for a fuzzer.
2 // The fuzzer must find a string based on dictionary words:
3 //   "Elvis"
4 //   "Presley"
5 #include <cstdint>
6 #include <cstdlib>
7 #include <cstddef>
8 #include <cstring>
9 #include <iostream>
10
11 static volatile int Zero = 0;
12
13 extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14   const char *Expected = "ElvisPresley";
15   if (Size < strlen(Expected)) return;
16   size_t Match = 0;
17   for (size_t i = 0; Expected[i]; i++)
18     if (Expected[i] + Zero == Data[i])
19       Match++;
20   if (Match == strlen(Expected)) {
21     std::cout << "BINGO; Found the target, exiting\n";
22     exit(1);
23   }
24 }
25