[llvm] r289506 - [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
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 16:40:48 PST 2016
Author: kcc
Date: Mon Dec 12 18:40:47 2016
New Revision: 289506
URL: http://llvm.org/viewvc/llvm-project?rev=289506&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
llvm/trunk/lib/Fuzzer/test/minimize_crash.test
Modified: llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp?rev=289506&r1=289505&r2=289506&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp Mon Dec 12 18:40:47 2016
@@ -282,16 +282,18 @@ int MinimizeCrashInput(const std::vector
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
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;
Modified: llvm/trunk/lib/Fuzzer/test/minimize_crash.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/minimize_crash.test?rev=289506&r1=289505&r2=289506&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/minimize_crash.test (original)
+++ llvm/trunk/lib/Fuzzer/test/minimize_crash.test Mon Dec 12 18:40:47 2016
@@ -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
More information about the llvm-commits
mailing list