Skip to content

Commit ad3a3a1

Browse files
committed
Run fuzzers with a custom corpus, and track code coverage
1 parent b3707de commit ad3a3a1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/checks.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,62 @@ jobs:
254254
RUST_BACKTRACE=1 cargo fuzz run --no-default-features --features="$features" $target -- -max_total_time=10
255255
done
256256
257+
fuzz-code-coverage:
258+
name: Fuzz with code coverage
259+
runs-on: ubuntu-latest
260+
strategy:
261+
matrix:
262+
include:
263+
- fuzz_target: uncompress2
264+
corpus: "gzip-files/compressed"
265+
features: '--no-default-features --features="disable-checksum"'
266+
flags: fuzz-decompress
267+
- fuzz_target: compress
268+
corpus: ""
269+
features: ''
270+
flags: fuzz-compress
271+
steps:
272+
- name: Checkout sources
273+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
274+
with:
275+
persist-credentials: false
276+
- name: Install nightly toolchain
277+
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
278+
with:
279+
toolchain: nightly
280+
components: llvm-tools-preview
281+
- name: Install cargo fuzz & rustfilt
282+
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8
283+
with:
284+
tool: cargo-fuzz,rustfilt
285+
- name: Download custom decompression corpus
286+
if: ${{ contains(matrix.corpus, 'gzip-files') }}
287+
run: |
288+
~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show --help
289+
wget https://github.com/folkertdev/compression-corpus/releases/download/2025-04-14-103007/gzip-files.zip
290+
unzip gzip-files.zip -d gzip-files
291+
- name: Run `cargo fuzz`
292+
env:
293+
RUST_BACKTRACE: "1"
294+
run: |
295+
cargo fuzz run ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}} -- -max_total_time=10
296+
- name: Fuzz codecov
297+
run: |
298+
cargo fuzz coverage ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}}
299+
~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov export -Xdemangler=rustfilt \
300+
target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/release/${{matrix.fuzz_target}} \
301+
-instr-profile=fuzz/coverage/${{matrix.fuzz_target}}/coverage.profdata \
302+
--format=lcov \
303+
-ignore-filename-regex="\.cargo|\.rustup" > lcov.info
304+
- name: Upload coverage to Codecov
305+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
306+
with:
307+
files: ./lcov.info
308+
fail_ci_if_error: false
309+
flags: ${{ matrix.flags }}
310+
token: ${{ secrets.CODECOV_TOKEN }}
311+
name: fuzz
312+
257313
link-c-dynamic-library:
258314
name: vanilla dynamic library
259315
strategy:

0 commit comments

Comments
 (0)