Skip to content

Commit 0a8d034

Browse files
committed
fuzz with corpus + coverage
1 parent 0e577c7 commit 0a8d034

File tree

4 files changed

+63
-526
lines changed

4 files changed

+63
-526
lines changed

.github/workflows/checks.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,65 @@ jobs:
228228
RUST_BACKTRACE=1 cargo fuzz run --no-default-features --features="$features" $target -- -max_total_time=10
229229
done
230230
231+
fuzz-code-coverage:
232+
name: Fuzz with code coverage
233+
runs-on: ubuntu-latest
234+
strategy:
235+
matrix:
236+
include:
237+
- fuzz_target: decompress
238+
corpus: "bzip2-files/compressed"
239+
features: '--no-default-features --features="disable-checksum"'
240+
flags: fuzz-decompress
241+
- fuzz_target: compress
242+
corpus: ""
243+
features: ''
244+
flags: fuzz-compress
245+
steps:
246+
- name: Checkout sources
247+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
248+
with:
249+
persist-credentials: false
250+
- name: Install nightly toolchain
251+
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
252+
with:
253+
toolchain: nightly
254+
components: llvm-tools-preview
255+
- name: Install cargo fuzz & rustfilt
256+
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8
257+
with:
258+
tool: cargo-fuzz,rustfilt
259+
- name: Download custom decompression corpus
260+
if: ${{ contains(matrix.corpus, 'bzip2-files') }}
261+
run: |
262+
wget https://github.com/trifectatechfoundation/compression-corpus/releases/download/2025-04-14-151155/bzip2-files.zip
263+
unzip bzip2-files.zip -d bzip2-files
264+
- name: Run `cargo fuzz`
265+
env:
266+
RUST_BACKTRACE: "1"
267+
run: |
268+
cargo fuzz run ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}} -- -max_total_time=10
269+
- name: Fuzz codecov
270+
run: |
271+
cargo fuzz coverage ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}}
272+
$(rustc --print sysroot)/lib/rustlib/$(rustc --print host-tuple)/bin/llvm-cov export -Xdemangler=rustfilt \
273+
target/$(rustc --print host-tuple)/coverage/$(rustc --print host-tuple)/release/${{matrix.fuzz_target}} \
274+
-instr-profile=fuzz/coverage/${{matrix.fuzz_target}}/coverage.profdata \
275+
--format=lcov \
276+
-ignore-filename-regex="\.cargo|\.rustup|fuzz/src|test-libbz2" > lcov.info
277+
- name: List the corpus
278+
if: ${{ contains(matrix.corpus, 'bzip2-files') }}
279+
run: |
280+
ls ${{matrix.corpus}}
281+
- name: Upload coverage to Codecov
282+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
283+
with:
284+
files: ./lcov.info
285+
fail_ci_if_error: false
286+
flags: ${{ matrix.flags }}
287+
token: ${{ secrets.CODECOV_TOKEN }}
288+
name: fuzz
289+
231290
wasm32:
232291
name: "wasm32"
233292
runs-on: ubuntu-latest

fuzz/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target
22
corpus
33
artifacts
4+
Cargo.lock

0 commit comments

Comments
 (0)