Index: lib/Fuzzer/FuzzerDriver.cpp =================================================================== --- lib/Fuzzer/FuzzerDriver.cpp +++ lib/Fuzzer/FuzzerDriver.cpp @@ -277,12 +277,17 @@ return 1; if (Flags.verbosity > 0 && !Options.Dictionary.empty()) Printf("Dictionary: %zd entries\n", Options.Dictionary.size()); + Options.SaveUnits = !Flags.test_single_input; Fuzzer F(USF, Options); if (Flags.apply_tokens) return ApplyTokens(F, Flags.apply_tokens); + // Timer + if (Flags.timeout > 0) + SetTimer(Flags.timeout / 2 + 1); + if (Flags.test_single_input) return RunOneTest(&F, Flags.test_single_input); @@ -294,10 +299,6 @@ Printf("Seed: %u\n", Seed); USF.GetRand().ResetSeed(Seed); - // Timer - if (Flags.timeout > 0) - SetTimer(Flags.timeout / 2 + 1); - if (Flags.verbosity >= 2) { Printf("Tokens: {"); for (auto &T : Options.Tokens) Index: lib/Fuzzer/FuzzerInternal.h =================================================================== --- lib/Fuzzer/FuzzerInternal.h +++ lib/Fuzzer/FuzzerInternal.h @@ -93,6 +93,7 @@ std::string ArtifactPrefix = "./"; std::vector Tokens; std::vector Dictionary; + bool SaveUnits = true; }; Fuzzer(UserSuppliedFuzzer &USF, FuzzingOptions Options); void AddToCorpus(const Unit &U) { Corpus.push_back(U); } Index: lib/Fuzzer/FuzzerLoop.cpp =================================================================== --- lib/Fuzzer/FuzzerLoop.cpp +++ lib/Fuzzer/FuzzerLoop.cpp @@ -237,6 +237,8 @@ } void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) { + if (!Options.SaveUnits) + return; std::string Path = Options.ArtifactPrefix + Prefix + Hash(U); WriteToFile(U, Path); Printf("artifact_prefix='%s'; Test unit written to %s\n", Index: lib/Fuzzer/test/fuzzer.test =================================================================== --- lib/Fuzzer/test/fuzzer.test +++ lib/Fuzzer/test/fuzzer.test @@ -1,7 +1,8 @@ CHECK: BINGO RUN: LLVMFuzzer-SimpleTest 2>&1 | FileCheck %s -RUN: LLVMFuzzer-SimpleTest -test_single_input=%S/hi.txt 2>&1 | FileCheck %s +RUN: not LLVMFuzzer-NullDerefTest -test_single_input=%S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInput +SingleInput-NOT: Test unit written to ./crash- RUN: not LLVMFuzzer-InfiniteTest -timeout=2 2>&1 | FileCheck %s --check-prefix=InfiniteTest InfiniteTest: ALARM: working on the last Unit for @@ -14,6 +15,10 @@ TimeoutTest: ALARM: working on the last Unit for TimeoutTest: Test unit written to ./timeout- +RUN: not LLVMFuzzer-TimeoutTest -timeout=5 -test_single_input=%S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest +SingleInputTimeoutTest: ALARM: working on the last Unit for +SingleInputTimeoutTest-NOT: Test unit written to ./timeout- + RUN: not LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest NullDerefTest: Test unit written to ./crash- RUN: not LLVMFuzzer-NullDerefTest -artifact_prefix=ZZZ 2>&1 | FileCheck %s --check-prefix=NullDerefTestPrefix