forked from bgornicki/app-hive
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fuzzing hash_parser target & coverage
- Loading branch information
Showing
5 changed files
with
70 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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,23 @@ | ||
#!/usr/bin/env bash | ||
# Generate code coverage reports from fuzzing results | ||
|
||
set -e | ||
|
||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
BUILDDIR="$SCRIPTDIR/cmake-build-fuzz-coverage" | ||
CORPUSDIR="$SCRIPTDIR/corpus" | ||
HTMLCOVDIR="$SCRIPTDIR/html-coverage" | ||
|
||
# Compile the fuzzer with code coverage support | ||
rm -rf "$BUILDDIR" "$HTMLCOVDIR" | ||
mkdir "$BUILDDIR" | ||
cd "$BUILDDIR" | ||
cmake -DCMAKE_C_COMPILER=clang -DCODE_COVERAGE=1 -B"$BUILDDIR" .. | ||
cmake --build "$BUILDDIR" --target fuzz_hive | ||
|
||
# Run the fuzzer on the corpus files | ||
export LLVM_PROFILE_FILE="$BUILDDIR/fuzz_hive.profraw" | ||
"$BUILDDIR/fuzz_hive" "$CORPUSDIR"/* | ||
llvm-profdata merge --sparse "$LLVM_PROFILE_FILE" -o "$BUILDDIR/fuzz_hive.profdata" | ||
llvm-cov show "$BUILDDIR/fuzz_hive" -instr-profile="$BUILDDIR/fuzz_hive.profdata" -show-line-counts-or-regions -output-dir="$HTMLCOVDIR" -format=html | ||
llvm-cov report "$BUILDDIR/fuzz_hive" -instr-profile="$BUILDDIR/fuzz_hive.profdata" |
This file contains 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 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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
BUILDDIR="$SCRIPTDIR/cmake-build-fuzz" | ||
CORPUSDIR="$SCRIPTDIR/corpus" | ||
|
||
"$BUILDDIR"/fuzz_hive "$CORPUSDIR" "$@" > /dev/null |