-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add a script to run the fuzzer and compute the coverage
- Loading branch information
1 parent
4323935
commit f86eb28
Showing
1 changed file
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Clean | ||
rm -rf build | ||
|
||
# Build the fuzzer | ||
cmake -B build -S . -DCMAKE_C_COMPILER=/usr/bin/clang | ||
cmake --build build | ||
|
||
# Create the corpus directory if it doesn't exist | ||
if ! [ -d ./corpus ]; then | ||
mkdir corpus | ||
fi | ||
|
||
# Run the fuzzer on half CPU cores | ||
ncpus=$(nproc) | ||
jobs=$(($ncpus/2)) | ||
echo "The fuzzer will start very soon, press Ctrl-C when you want to stop it and compute the coverage" | ||
./build/fuzzer -max_len=8192 -jobs="$jobs" ./corpus | ||
|
||
|
||
read -p "Would you like to compute coverage (y/n)? " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Nn]$ ]] | ||
then | ||
exit 0 | ||
fi | ||
|
||
# Remove previous artifcats | ||
rm default.profdata default.profraw | ||
|
||
# Run profiling on the corpus | ||
./build/fuzzer -max_len=8192 -runs=0 ./corpus | ||
|
||
# Compute coverage | ||
llvm-profdata merge -sparse *.profraw -o default.profdata | ||
llvm-cov show build/fuzzer -instr-profile=default.profdata -format=html -ignore-filename-regex='ethereum-plugin-sdk\/|secure-sdk\/' > report.html | ||
llvm-cov report build/fuzzer -instr-profile=default.profdata -ignore-filename-regex='ethereum-plugin-sdk\/|secure-sdk\/' |