Files
nanoreth/.github/scripts/fuzz.sh
Bjerg ed4213fdff ci: speed up fuzz tests (#544)
* ci: run fuzz tests in matrix

* ci: fail if fuzzing fails

* ci: rename fuzz step

* ci: clean up env

* ci: fix fuzz test target matching

* ci: prebuild fuzz corpus

* ci: collect coverage while running tests

Instead of running tests twice, we can just run them
once while collecting coverage data.

* ci: temporarily disable `reth-eth-wire` fuzzing

* ci: collect fuzz coverage data

* ci: fix fuzz coverage collection

* ci: re-enable `reth-eth-wire`
2022-12-20 22:18:53 +01:00

30 lines
757 B
Bash
Executable File

#!/bin/bash
set -e
# Runs fuzz tests using `cargo test-fuzz`.
PACKAGE=$1
TEST_TIME=${2:-5}
echo Building corpus.
cargo test -p $PACKAGE
# We configure coverage after building a corpus to only include
# fuzz tests in the coverage report.
echo Configuring coverage.
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace
# Gets the list of tests present in the package.
TESTS=$(cargo test-fuzz --list -p $PACKAGE | head -n -3 | tail -n+9 | cat - <(echo \"--list\"]) | cat - | jq -r ".[]")
for test in $TESTS
do
echo Running test: $test
set -x
cargo test-fuzz --no-ui --exact -p "$PACKAGE" $test -- -V $TEST_TIME
set +x
done;
echo Building coverage report.
cargo llvm-cov report --lcov --output-path lcov.info