Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / AFLDriverTest.cpp
blob84b5f9f6ba26c7925b73d9d1e306c14b8ea8714e
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 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 // Dummy functions used to avoid dependency on AFL.
10 extern "C" void __afl_manual_init() {}
12 extern "C" int __afl_persistent_loop(unsigned int N) {
13 static int Count = N;
14 fprintf(stderr, "__afl_persistent_loop called, Count = %d\n", Count);
15 return Count--;
18 // This declaration exists to prevent the Darwin linker
19 // from complaining about this being a missing weak symbol.
20 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
21 return 0;
24 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
25 puts("STDOUT MESSAGE");
26 fflush(stdout);
27 fprintf(stderr, "STDERR MESSAGE\n"
28 "LLVMFuzzerTestOneInput called; Size = %zd\n",
29 Size);
30 if (Size < 4)
31 return 0;
33 return Data[Size];