Skip to content

Commit

Permalink
[libFuzzer] add -timeout_exitcode option
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259265 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed Jan 29, 2016
1 parent 2801207 commit 58b3c64
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/LibFuzzer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The most important flags are::
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.
timeout_exitcode 77 Unless abort_on_timeout is set, use this exitcode 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.
Expand Down
1 change: 1 addition & 0 deletions lib/Fuzzer/FuzzerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ int FuzzerDriver(const std::vector<std::string> &Args,
Options.MaxLen = Flags.max_len;
Options.UnitTimeoutSec = Flags.timeout;
Options.AbortOnTimeout = Flags.abort_on_timeout;
Options.TimeoutExitCode = Flags.timeout_exitcode;
Options.MaxTotalTimeSec = Flags.max_total_time;
Options.DoCrossOver = Flags.cross_over;
Options.MutateDepth = Flags.mutate_depth;
Expand Down
2 changes: 2 additions & 0 deletions lib/Fuzzer/FuzzerFlags.def
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ FUZZER_FLAG_INT(
"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(timeout_exitcode, 77,
"Unless abort_on_timeout is set, use this exitcode 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.")
Expand Down
1 change: 1 addition & 0 deletions lib/Fuzzer/FuzzerInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class Fuzzer {
int MaxLen = 0;
int UnitTimeoutSec = 300;
bool AbortOnTimeout = false;
int TimeoutExitCode = 77;
int MaxTotalTimeSec = 0;
bool DoCrossOver = true;
int MutateDepth = 5;
Expand Down
2 changes: 1 addition & 1 deletion lib/Fuzzer/FuzzerLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void Fuzzer::AlarmCallback() {
Printf("SUMMARY: libFuzzer: timeout\n");
if (Options.AbortOnTimeout)
abort();
exit(1);
exit(Options.TimeoutExitCode);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/Fuzzer/test/fuzzer-timeout.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ SingleInputTimeoutTest: ALARM: working on the last Unit for
SingleInputTimeoutTest-NOT: Test unit written to ./timeout-

RUN: ASAN_OPTIONS=handle_abort=0 not --crash LLVMFuzzer-TimeoutTest -timeout=1 -abort_on_timeout=1
RUN: LLVMFuzzer-TimeoutTest -timeout=1 -timeout_exitcode=0

0 comments on commit 58b3c64

Please sign in to comment.