1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5// Simple test for a fuzzer.
6// The fuzzer must find a string based on dictionary words:
7// "Elvis"
8// "Presley"
9#include <cstddef>
10#include <cstdint>
11#include <cstdlib>
12#include <cstring>
13#include <iostream>
14#include <ostream>
15
16static volatile int Zero = 0;
17
18extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
19 const char *Expected = "ElvisPresley";
20 if (Size < strlen(s: Expected)) return 0;
21 size_t Match = 0;
22 for (size_t i = 0; Expected[i]; i++)
23 if (Expected[i] + Zero == Data[i])
24 Match++;
25 if (Match == strlen(s: Expected)) {
26 std::cout << "BINGO; Found the target, exiting\n" << std::flush;
27 exit(status: 1);
28 }
29 return 0;
30}
31
32

source code of compiler-rt/test/fuzzer/SimpleDictionaryTest.cpp