blob: b9cb2f0270a33f72e1d328306be5c7b2f43d6b95 [file] [log] [blame]
Kostya Serebryany7d211662015-09-04 00:12:11 +00001// 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
11static volatile int Zero = 0;
12
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000013extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryany7d211662015-09-04 00:12:11 +000014 const char *Expected = "ElvisPresley";
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000015 if (Size < strlen(Expected)) return 0;
Kostya Serebryany7d211662015-09-04 00:12:11 +000016 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 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000024 return 0;
Kostya Serebryany7d211662015-09-04 00:12:11 +000025}
26