-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[tools] initial fuzz coverage script #10289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fd15170
initial coverage script
asraa 83cb80b
fix script because i misunderstood merge
asraa 540dd43
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa 616a834
fixup
asraa 45411d0
build in single invokation
asraa 8ea16bf
fixup more comments
asraa ae48280
fixup
asraa 48f51ed
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa de89135
fixup
asraa e60cc43
oops
asraa bf70062
add comment
asraa 73ddc72
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa 97b3b41
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa e8b0cf2
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa 42a9e20
add build options
asraa 178d684
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa d14e72a
Merge remote-tracking branch 'upstream/master' into fuzz-coverage
asraa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| if [[ $# -gt 0 ]]; then | ||
| FUZZ_TARGETS=$* | ||
| else | ||
| echo "This script should be called from tools/run_envoy_bazel_coverage.sh" | ||
| fi | ||
|
|
||
| LIBFUZZER_TARGETS="" | ||
| # Build all fuzz targets to run instrumented with libfuzzer in sequence. | ||
| for t in ${FUZZ_TARGETS} | ||
| do | ||
| LIBFUZZER_TARGETS+=${t}_with_libfuzzer | ||
| done | ||
|
|
||
| bazel build ${LIBFUZZER_TARGETS} --config asan-fuzzer -c opt | ||
|
|
||
| # Now run each fuzz target in parallel for 60 seconds. | ||
| pids="" | ||
|
asraa marked this conversation as resolved.
Outdated
|
||
| TEMP_CORPORA="" | ||
|
|
||
| for t in ${FUZZ_TARGETS} | ||
| do | ||
| # Make a temporary corpus for this fuzz target. | ||
| TARGET_BINARY="${t/://}" | ||
| TEMP_CORPUS_PATH=${TARGET_BINARY:2} | ||
| CORPUS_DIR="/tmp/${TEMP_CORPUS_PATH////_}_corpus" | ||
|
asraa marked this conversation as resolved.
Outdated
|
||
| mkdir -v ${CORPUS_DIR} | ||
|
asraa marked this conversation as resolved.
Outdated
|
||
| # Get the original corpus for the fuzz target | ||
| CORPUS_LOCATION="$(bazel query "labels(data, ${t})" | head -1)" | ||
| ORIGINAL_CORPUS="$(bazel query "labels(srcs, ${CORPUS_LOCATION})" | head -1)" | ||
| ORIGINAL_CORPUS=${ORIGINAL_CORPUS/://} | ||
| ORIGINAL_CORPUS="$(dirname ${ORIGINAL_CORPUS})" | ||
| # Copy entries in original corpus into temp. | ||
| cp -r "$(pwd)"${ORIGINAL_CORPUS:1} ${CORPUS_DIR} | ||
| TEMP_CORPORA+="${CORPUS_DIR} " | ||
| # Run fuzzing process. | ||
| bazel-bin/${TARGET_BINARY:2}_with_libfuzzer -max_total_time=60 ${CORPUS_DIR} & | ||
|
asraa marked this conversation as resolved.
Outdated
|
||
| # Add pid to pids list | ||
| pids="$pids $!" | ||
| done | ||
|
|
||
| # Wait for background process to run. | ||
| for pid in $pids; do | ||
| wait ${pid} | ||
| if [ $? -ne 0 ]; then | ||
| echo "${pid} FAILED" | ||
| fi | ||
| done | ||
|
|
||
| echo ${TEMP_CORPORA} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using ${BAZEL_BUiLD_OPTIONS} here @lizan ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes unless there's reason not to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Sorry about that