Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / KeepSeedTest.cpp
blobf343161abde52d781d430c312bf01082616b7644
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 // Test whether the fuzzer can find "SELECT FROM WHERE", given a seed input
6 // "SELECTxFROMxWHERE". Without -keep_seed=1, it takes longer time to trigger
7 // find the desired string, because the seed input is more likely to be reduced
8 // to a prefix of the given input first, losing useful fragments towards the end
9 // of the seed input.
10 #include <cstdint>
11 #include <cstdio>
12 #include <cstdlib>
13 #include <cstring>
15 static volatile int Sink = 0;
17 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
18 if (Size > 17)
19 return 0;
21 if (Size >= 6 && Data[0] == 'S' && Data[1] == 'E' && Data[2] == 'L' &&
22 Data[3] == 'E' && Data[4] == 'C' && Data[5] == 'T') {
23 if (Size >= 7 && Data[6] == ' ') {
24 if (Size >= 11 && Data[7] == 'F' && Data[8] == 'R' && Data[9] == 'O' &&
25 Data[10] == 'M') {
26 if (Size >= 12 && Data[11] == ' ') {
27 if (Size >= 17 && Data[12] == 'W' && Data[13] == 'H' &&
28 Data[14] == 'E' && Data[15] == 'R' && Data[16] == 'E') {
29 fprintf(stderr, "BINGO; Found the target, exiting.\n");
30 exit(1);
36 return 0;