Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / BigFileCopy.cpp
blob5515365246b44f1740230f1bdc4dec9b509f2e9f
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 <cstddef>
6 #include <cstdint>
7 #include <cstdio>
8 #include <cstdlib>
9 #include <cstring>
11 #include "FuzzerIO.h"
13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14 const char *FileName = "big-file.txt";
15 FILE *f = fopen(FileName, "w");
17 // This is the biggest file possible unless CopyFileToErr() uses Puts()
18 fprintf(f, "%2147483646s", "2Gb-2");
20 // This makes the file too big if CopyFileToErr() uses fprintf("%s", <file>)
21 fprintf(f, "THIS LINE RESPONSIBLE FOR EXCEEDING 2Gb FILE SIZE\n");
22 fclose(f);
24 // Should now because CopyFileToErr() now uses Puts()
25 fuzzer::CopyFileToErr(FileName);
27 // File is >2Gb so clean up
28 remove(FileName);
30 return 0;