mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-13 08:54:59 +00:00
[libFuzzer] add option -report_slow_units=Nsec to control when slow units are printed
llvm-svn: 244152
This commit is contained in:
parent
5be4cb583e
commit
80051e17c0
@ -247,6 +247,7 @@ int FuzzerDriver(int argc, char **argv, UserSuppliedFuzzer &USF) {
|
||||
if (Flags.sync_command)
|
||||
Options.SyncCommand = Flags.sync_command;
|
||||
Options.SyncTimeout = Flags.sync_timeout;
|
||||
Options.ReportSlowUnits = Flags.report_slow_units;
|
||||
Fuzzer F(USF, Options);
|
||||
|
||||
if (Flags.apply_tokens)
|
||||
|
@ -58,3 +58,5 @@ FUZZER_FLAG_STRING(sync_command, "Execute an external command "
|
||||
"\"<sync_command> <test_corpus>\" "
|
||||
"to synchronize the test corpus.")
|
||||
FUZZER_FLAG_INT(sync_timeout, 600, "Minimum timeout between syncs.")
|
||||
FUZZER_FLAG_INT(report_slow_units, 10,
|
||||
"Report slowest units if they run for more than this number of seconds.")
|
||||
|
@ -79,6 +79,7 @@ class Fuzzer {
|
||||
int PreferSmallDuringInitialShuffle = -1;
|
||||
size_t MaxNumberOfRuns = ULONG_MAX;
|
||||
int SyncTimeout = 600;
|
||||
int ReportSlowUnits = 10;
|
||||
std::string OutputCorpus;
|
||||
std::string SyncCommand;
|
||||
std::vector<std::string> Tokens;
|
||||
|
@ -159,12 +159,13 @@ size_t Fuzzer::RunOne(const Unit &U) {
|
||||
auto UnitStopTime = system_clock::now();
|
||||
auto TimeOfUnit =
|
||||
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
|
||||
if (TimeOfUnit > TimeOfLongestUnitInSeconds) {
|
||||
if (TimeOfUnit > TimeOfLongestUnitInSeconds &&
|
||||
TimeOfUnit >= Options.ReportSlowUnits) {
|
||||
TimeOfLongestUnitInSeconds = TimeOfUnit;
|
||||
Printf("Longest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
|
||||
Printf("Slowest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
|
||||
if (U.size() <= kMaxUnitSizeToPrint)
|
||||
Print(U, "\n");
|
||||
WriteUnitToFileWithPrefix(U, "long-running-unit-");
|
||||
WriteUnitToFileWithPrefix(U, "slow-unit-");
|
||||
}
|
||||
return Res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user