1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[libFuzzer] add -abort_on_timeout option

llvm-svn: 258631
This commit is contained in:
Kostya Serebryany 2016-01-23 19:34:19 +00:00
parent 59d64a8443
commit 0c11655f17
6 changed files with 7 additions and 0 deletions

View File

@ -61,6 +61,7 @@ The most important flags are::
cross_over 1 If 1, cross over inputs.
mutate_depth 5 Apply this number of consecutive mutations to each input.
timeout 1200 Timeout in seconds (if positive). If one unit runs more than this number of seconds the process will abort.
abort_on_timeout 0 If positive, call abort on timeout.
max_total_time 0 If positive, indicates the maximal total time in seconds to run the fuzzer.
help 0 Print help.
merge 0 If 1, the 2-nd, 3-rd, etc corpora will be merged into the 1-st corpus. Only interesting units will be taken.

View File

@ -268,6 +268,7 @@ int FuzzerDriver(const std::vector<std::string> &Args,
Options.Verbosity = Flags.verbosity;
Options.MaxLen = Flags.max_len;
Options.UnitTimeoutSec = Flags.timeout;
Options.AbortOnTimeout = Flags.abort_on_timeout;
Options.MaxTotalTimeSec = Flags.max_total_time;
Options.DoCrossOver = Flags.cross_over;
Options.MutateDepth = Flags.mutate_depth;

View File

@ -29,6 +29,7 @@ FUZZER_FLAG_INT(
timeout, 1200,
"Timeout in seconds (if positive). "
"If one unit runs more than this number of seconds the process will abort.")
FUZZER_FLAG_INT(abort_on_timeout, 0, "If positive, call abort on timeout.")
FUZZER_FLAG_INT(max_total_time, 0, "If positive, indicates the maximal total "
"time in seconds to run the fuzzer.")
FUZZER_FLAG_INT(help, 0, "Print help.")

View File

@ -174,6 +174,7 @@ public:
int Verbosity = 1;
int MaxLen = 0;
int UnitTimeoutSec = 300;
bool AbortOnTimeout = false;
int MaxTotalTimeSec = 0;
bool DoCrossOver = true;
int MutateDepth = 5;

View File

@ -112,6 +112,8 @@ void Fuzzer::AlarmCallback() {
if (__sanitizer_print_stack_trace)
__sanitizer_print_stack_trace();
Printf("SUMMARY: libFuzzer: timeout\n");
if (Options.AbortOnTimeout)
abort();
exit(1);
}
}

View File

@ -11,3 +11,4 @@ RUN: not LLVMFuzzer-TimeoutTest -timeout=1 -test_single_input=%S/hi.txt 2>&1 | F
SingleInputTimeoutTest: ALARM: working on the last Unit for
SingleInputTimeoutTest-NOT: Test unit written to ./timeout-
RUN: not --crash LLVMFuzzer-TimeoutTest -timeout=1 -abort_on_timeout=1