Skip to content

Commit

Permalink
[libFuzzer] extend the messages printed by afl_driver
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276052 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed Jul 19, 2016
1 parent 63be720 commit 1f0a7ed
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/Fuzzer/afl/afl_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,16 @@ static void maybe_duplicate_stderr() {
}

int main(int argc, char **argv) {
fprintf(stderr, "Running in AFl-fuzz mode\nUsage:\n"
"afl-fuzz [afl-flags] %s [N] "
fprintf(stderr, "======================= INFO =========================\n"
"This binary is built for AFL-fuzz.\n"
"To run the target function on a single input execute this:\n"
" %s < INPUT_FILE\n"
"To run the fuzzing execute this:\n"
" afl-fuzz [afl-flags] %s [N] "
"-- run N fuzzing iterations before "
"re-spawning the process (default: 1000)\n",
argv[0]);
"re-spawning the process (default: 1000)\n"
"======================================================\n",
argv[0], argv[0]);
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize(&argc, &argv);
// Do any other expensive one-time initialization here.
Expand All @@ -258,6 +263,7 @@ int main(int argc, char **argv) {
N = atoi(argv[1]);
assert(N > 0);
time_t unit_time_secs;
int num_runs = 0;
while (__afl_persistent_loop(N)) {
ssize_t n_read = read(0, AflInputBuf, kMaxAflInputSize);
if (n_read > 0) {
Expand All @@ -270,6 +276,7 @@ int main(int argc, char **argv) {
CHECK_ERROR(gettimeofday(&unit_start_time, NULL) == 0,
"Calling gettimeofday failed");

num_runs++;
LLVMFuzzerTestOneInput(copy, n_read);

struct timeval unit_stop_time;
Expand All @@ -284,4 +291,5 @@ int main(int argc, char **argv) {
delete[] copy;
}
}
fprintf(stderr, "%s: successfully executed %d input(s)\n", argv[0], num_runs);
}

0 comments on commit 1f0a7ed

Please sign in to comment.