1*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
3*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4ef521ffeSMatt Morehouse 
5ef521ffeSMatt Morehouse // Simple test for a fuzzer. The fuzzer must find the string "Hi!".
6ef521ffeSMatt Morehouse #include <assert.h>
7ef521ffeSMatt Morehouse #include <cstdint>
8ef521ffeSMatt Morehouse #include <cstdio>
9ef521ffeSMatt Morehouse #include <cstdlib>
10ef521ffeSMatt Morehouse 
11ef521ffeSMatt Morehouse static volatile int Sink;
12ef521ffeSMatt Morehouse 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)13ef521ffeSMatt Morehouse extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14ef521ffeSMatt Morehouse   assert(Data);
15ef521ffeSMatt Morehouse   if (Size > 0 && Data[0] == 'H') {
16ef521ffeSMatt Morehouse     Sink = 1;
17ef521ffeSMatt Morehouse     if (Size > 1 && Data[1] == 'i') {
18ef521ffeSMatt Morehouse       Sink = 2;
19ef521ffeSMatt Morehouse       if (Size > 2 && Data[2] == '!') {
20ef521ffeSMatt Morehouse         fprintf(stderr, "BINGO; Found the target, exiting\n");
21ef521ffeSMatt Morehouse         exit(0);
22ef521ffeSMatt Morehouse       }
23ef521ffeSMatt Morehouse     }
24ef521ffeSMatt Morehouse   }
25ef521ffeSMatt Morehouse   return 0;
26ef521ffeSMatt Morehouse }
27ef521ffeSMatt Morehouse 
28