Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / SimpleDictionaryTest.cpp
blob72b2440d421ea71e8d4518b971d359031be021fe
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
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>
16 static volatile int Zero = 0;
18 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
19 const char *Expected = "ElvisPresley";
20 if (Size < strlen(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(Expected)) {
26 std::cout << "BINGO; Found the target, exiting\n" << std::flush;
27 exit(1);
29 return 0;