Skip to content

Commit 2970d91

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

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/checks.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,61 @@ 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+
wget https://github.com/trifectatechfoundation/compression-corpus/releases/download/2025-04-14-103007/gzip-files.zip
289+
unzip gzip-files.zip -d gzip-files
290+
- name: Run `cargo fuzz`
291+
env:
292+
RUST_BACKTRACE: "1"
293+
run: |
294+
cargo fuzz run ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}} -- -max_total_time=10
295+
- name: Fuzz codecov
296+
run: |
297+
cargo fuzz coverage ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}}
298+
$(rustc --print sysroot)/lib/rustlib/$(rustc --print host-tuple)/bin/llvm-cov export -Xdemangler=rustfilt \
299+
target/$(rustc --print host-tuple)/coverage/$(rustc --print host-tuple)/release/${{matrix.fuzz_target}} \
300+
-instr-profile=fuzz/coverage/${{matrix.fuzz_target}}/coverage.profdata \
301+
--format=lcov \
302+
-ignore-filename-regex="\.cargo|\.rustup" > lcov.info
303+
- name: Upload coverage to Codecov
304+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
305+
with:
306+
files: ./lcov.info
307+
fail_ci_if_error: false
308+
flags: ${{ matrix.flags }}
309+
token: ${{ secrets.CODECOV_TOKEN }}
310+
name: fuzz
311+
257312
link-c-dynamic-library:
258313
name: vanilla dynamic library
259314
strategy:

0 commit comments

Comments
 (0)