summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-12-13 00:40:47 +0000
committerKostya Serebryany <kcc@google.com>2016-12-13 00:40:47 +0000
commita31300e789a6b02865952404fe750fd968942df9 (patch)
treee9dc40cb6371e955afdd0a71d15654135b13731c
parent1e2f30e957f504a67b13422e3fc8793bd6d4d55c (diff)
downloadbcm5719-llvm-a31300e789a6b02865952404fe750fd968942df9.tar.gz
bcm5719-llvm-a31300e789a6b02865952404fe750fd968942df9.zip
[libFuzzer] don't require extra flags with -minimize_crash=1 (default to -max_total_time=600). Also respect exact_artifact_path when outputting the end result
llvm-svn: 289506
-rw-r--r--llvm/lib/Fuzzer/FuzzerDriver.cpp18
-rw-r--r--llvm/lib/Fuzzer/test/minimize_crash.test8
2 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerDriver.cpp b/llvm/lib/Fuzzer/FuzzerDriver.cpp
index 4051bf680ff..2e94530e721 100644
--- a/llvm/lib/Fuzzer/FuzzerDriver.cpp
+++ b/llvm/lib/Fuzzer/FuzzerDriver.cpp
@@ -282,16 +282,18 @@ int MinimizeCrashInput(const std::vector<std::string> &Args) {
Printf("ERROR: -minimize_crash should be given one input file\n");
exit(1);
}
- if (Flags.runs <= 0 && Flags.max_total_time == 0) {
- Printf("ERROR: you need to use -runs=N or "
- "-max_total_time=N with -minimize_crash=1\n" );
- exit(1);
- }
std::string InputFilePath = Inputs->at(0);
- std::string BaseCmd = CloneArgsWithoutX(Args, "minimize_crash");
+ std::string BaseCmd =
+ CloneArgsWithoutX(Args, "minimize_crash", "exact_artifact_path");
auto InputPos = BaseCmd.find(" " + InputFilePath + " ");
assert(InputPos != std::string::npos);
BaseCmd.erase(InputPos, InputFilePath.size() + 1);
+ if (Flags.runs <= 0 && Flags.max_total_time == 0) {
+ Printf("INFO: you need to specify -runs=N or "
+ "-max_total_time=N with -minimize_crash=1\n"
+ "INFO: defaulting to -max_total_time=600\n");
+ BaseCmd += " -max_total_time=600";
+ }
// BaseCmd += " > /dev/null 2>&1 ";
std::string CurrentFilePath = InputFilePath;
@@ -322,6 +324,10 @@ int MinimizeCrashInput(const std::vector<std::string> &Args) {
Printf("CRASH_MIN: executing: %s\n", Cmd.c_str());
ExitCode = ExecuteCommand(Cmd);
if (ExitCode == 0) {
+ if (Flags.exact_artifact_path) {
+ CurrentFilePath = Flags.exact_artifact_path;
+ WriteToFile(U, CurrentFilePath);
+ }
Printf("CRASH_MIN: failed to minimize beyond %s (%d bytes), exiting\n",
CurrentFilePath.c_str(), U.size());
return 0;
diff --git a/llvm/lib/Fuzzer/test/minimize_crash.test b/llvm/lib/Fuzzer/test/minimize_crash.test
index 390f4eaab79..7e5406598e4 100644
--- a/llvm/lib/Fuzzer/test/minimize_crash.test
+++ b/llvm/lib/Fuzzer/test/minimize_crash.test
@@ -1,6 +1,6 @@
-CHECK: CRASH_MIN: failed to minimize beyond minimized-from-{{.*}} (3 bytes), exiting
RUN: echo 'Hi!rv349f34t3gg' > not_minimal_crash
RUN: LLVMFuzzer-NullDerefTest -minimize_crash=1 not_minimal_crash -max_total_time=2 2>&1 | FileCheck %s
-RUN: rm not_minimal_crash minimized-from-*
-
-
+CHECK: CRASH_MIN: failed to minimize beyond minimized-from-{{.*}} (3 bytes), exiting
+RUN: LLVMFuzzer-NullDerefTest -minimize_crash=1 not_minimal_crash -max_total_time=2 -exact_artifact_path=exact_minimized_path 2>&1 | FileCheck %s --check-prefix=CHECK_EXACT
+CHECK_EXACT: CRASH_MIN: failed to minimize beyond exact_minimized_path (3 bytes), exiting
+RUN: rm not_minimal_crash minimized-from-* exact_minimized_path
OpenPOWER on IntegriCloud