return 1;
if (Flags.verbosity > 0 && !Options.Dictionary.empty())
Printf("Dictionary: %zd entries\n", Options.Dictionary.size());
+ Options.SaveArtifacts = !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);
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)
Unit FileToVector(const std::string &Path) {
std::ifstream T(Path);
+ if (!T) {
+ Printf("No such directory: %s; exiting\n", Path.c_str());
+ exit(1);
+ }
return Unit((std::istreambuf_iterator<char>(T)),
std::istreambuf_iterator<char>());
}
std::string ArtifactPrefix = "./";
std::vector<std::string> Tokens;
std::vector<Unit> Dictionary;
+ bool SaveArtifacts = true;
};
Fuzzer(UserSuppliedFuzzer &USF, FuzzingOptions Options);
void AddToCorpus(const Unit &U) { Corpus.push_back(U); }
}
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
+ if (!Options.SaveArtifacts)
+ return;
std::string Path = Options.ArtifactPrefix + Prefix + Hash(U);
WriteToFile(U, Path);
Printf("artifact_prefix='%s'; Test unit written to %s\n",
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
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