blob: 82773231569ab296d5eeef87271567d623f8b34a [file] [log] [blame]
Kostya Serebryany52a788e2015-03-31 20:13:20 +00001// Simple test for a fuzzer. The fuzzer must find a sequence of C++ tokens.
2#include <cstdint>
3#include <cstdlib>
4#include <cstddef>
5#include <cstring>
6#include <iostream>
7
8static void Found() {
Kostya Serebryanya407dde2015-05-07 00:11:33 +00009 std::cout << "BINGO; Found the target, exiting\n";
Kostya Serebryany52a788e2015-03-31 20:13:20 +000010 exit(1);
11}
12
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000013extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryany52a788e2015-03-31 20:13:20 +000014 // looking for "thread_local unsigned A;"
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000015 if (Size < 24) return 0;
Kostya Serebryany52a788e2015-03-31 20:13:20 +000016 if (0 == memcmp(&Data[0], "thread_local", 12))
17 if (Data[12] == ' ')
18 if (0 == memcmp(&Data[13], "unsigned", 8))
19 if (Data[21] == ' ')
20 if (Data[22] == 'A')
21 if (Data[23] == ';')
22 Found();
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000023 return 0;
Kostya Serebryany52a788e2015-03-31 20:13:20 +000024}
25