Skip to content

Commit

Permalink
Add fuzz test coverage Makefile target (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Feb 27, 2025
1 parent a5ad4a0 commit 5c91b8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
lcov.info
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ test:
fuzz:
cargo +nightly fuzz run fuzz_roundtrip -j 4

# Generate a lcov.info file for tools like VSCode's Coverage Gutters extension,
# and output basic coverage information on the command line.
RUST_LLVM_COV=$(shell find $(shell rustc --print sysroot) -name llvm-cov)
RUST_TARGET_TRIPLE=$(shell rustc -vV | sed -n 's|host: ||p')
fuzz-coverage:
rustup component add --toolchain nightly llvm-tools-preview
cargo +nightly fuzz coverage fuzz_roundtrip
@$(RUST_LLVM_COV) export \
-instr-profile=fuzz/coverage/fuzz_roundtrip/coverage.profdata \
-object target/$(RUST_TARGET_TRIPLE)/coverage/$(RUST_TARGET_TRIPLE)/release/fuzz_roundtrip \
--ignore-filename-regex "rustc" \
-format=lcov \
> lcov.info
@$(RUST_LLVM_COV) report \
-instr-profile=fuzz/coverage/fuzz_roundtrip/coverage.profdata \
-object target/$(RUST_TARGET_TRIPLE)/coverage/$(RUST_TARGET_TRIPLE)/release/fuzz_roundtrip \
--ignore-filename-regex ".cargo/registry"
@echo "View the coverage in lcov.info in VSCode using the Coverage Gutters extension."

build:
cargo build
cargo build --features serde
Expand Down

0 comments on commit 5c91b8e

Please sign in to comment.