Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / Labels20Test.cpp
blob0422a54e6e15642b43a155f44f395ef1b840f030
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 // Needs to find a string "FUZZxxxxxxxxxxxxMxxE", where 'x' is any byte.
7 #include <assert.h>
8 #include <cstddef>
9 #include <cstdint>
10 #include <cstdlib>
11 #include <cstdio>
13 extern "C" bool Func1(const uint8_t *Data, size_t Size);
14 extern "C" bool Func2(const uint8_t *Data, size_t Size);
16 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
17 if (Size >= 20
18 && Data[0] == 'F'
19 && Data[1] == 'U'
20 && Data[2] == 'Z'
21 && Data[3] == 'Z'
22 && Func1(Data, Size)
23 && Func2(Data, Size)) {
24 fprintf(stderr, "BINGO\n");
25 abort();
27 return 0;
30 extern "C"
31 __attribute__((noinline))
32 bool Func1(const uint8_t *Data, size_t Size) {
33 // assumes Size >= 5, doesn't check it.
34 return Data[16] == 'M';
37 extern "C"
38 __attribute__((noinline))
39 bool Func2(const uint8_t *Data, size_t Size) {
40 return Size >= 20 && Data[19] == 'E';