mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-22 20:20:03 +00:00
[libFuzzer] When -test_single_input crashes the test it is not necessary to write crash-file because input is already known to the user. Patch by Mike Aizatsky
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250564 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d6d66ea302
commit
17062e257e
@ -277,12 +277,17 @@ int FuzzerDriver(const std::vector<std::string> &Args,
|
||||
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);
|
||||
|
||||
@ -294,10 +299,6 @@ int FuzzerDriver(const std::vector<std::string> &Args,
|
||||
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)
|
||||
|
@ -49,6 +49,10 @@ static std::vector<std::string> ListFilesInDir(const std::string &Dir,
|
||||
|
||||
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>());
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ class Fuzzer {
|
||||
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); }
|
||||
|
@ -237,6 +237,8 @@ void Fuzzer::WriteToOutputCorpus(const Unit &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",
|
||||
|
@ -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 @@ RUN: not LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=Ti
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user