Skip to content

Commit

Permalink
[libFuzzer] when an invalid flag is given, warn, but don't crash
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271404 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed Jun 1, 2016
1 parent da6ed23 commit 3886b25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Fuzzer/FuzzerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ static bool ParseOneFlag(const char *Param) {
}
}
}
PrintHelp();
exit(1);
Printf("\n\nWARNING: unrecognized flag '%s'; "
"use -help=1 to list all flags\n\n", Param);
return true;
}

// We don't use any library to minimize dependencies.
Expand Down
4 changes: 4 additions & 0 deletions lib/Fuzzer/test/fuzzer.test
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ RUN: LLVMFuzzer-SimpleTest %S/dict1.txt -runs=33 -print_final_stats=1 2>&1 | Fil
FINAL_STATS1: stat::number_of_executed_units: 33
FINAL_STATS1: stat::peak_rss_mb:

RUN: LLVMFuzzer-SimpleTest -foo_bar=1 2>&1 | FileCheck %s --check-prefix=FOO_BAR
FOO_BAR: WARNING: unrecognized flag '-foo_bar=1'; use -help=1 to list all flags
FOO_BAR: BINGO

RUN: LLVMFuzzer-SpamyTest -runs=1 2>&1 | FileCheck %s --check-prefix=FD_MASK_0
RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=0 2>&1 | FileCheck %s --check-prefix=FD_MASK_0
RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=1 2>&1 | FileCheck %s --check-prefix=FD_MASK_1
Expand Down

0 comments on commit 3886b25

Please sign in to comment.