From 922d9f1f7e9b7586a261e4dc48de311fbadfbd50 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 30 Mar 2026 14:09:13 +0200 Subject: [PATCH] fuzz: fix coverage report to include library crates Since cargo-llvm-cov 0.7.0, only workspace members are instrumented by default. Since the fuzz crate is a standalone workspace, library crates like lightning were not instrumented, and the coverage report was empty. Add --dep-coverage to instrument the library path dependencies. This alone is not sufficient for the report: --dep-coverage's report filtering only supports crates.io deps, not path deps (per a TODO in cargo-llvm-cov source). Add --no-default-ignore-filename-regex to include all instrumented code, then use a custom --ignore-filename-regex to exclude unwanted paths (cargo registry, rustup toolchains, fuzz harness). AI tools were used in preparing this commit. --- contrib/generate_fuzz_coverage.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/generate_fuzz_coverage.sh b/contrib/generate_fuzz_coverage.sh index 22826ca0c38..6be9956bbca 100755 --- a/contrib/generate_fuzz_coverage.sh +++ b/contrib/generate_fuzz_coverage.sh @@ -57,7 +57,11 @@ mkdir -p "$OUTPUT_DIR" # dont run this command when running in CI if [ "$OUTPUT_CODECOV_JSON" = "0" ]; then - cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR" + cargo llvm-cov --html \ + --dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \ + --no-default-ignore-filename-regex \ + --ignore-filename-regex "(\.cargo/registry|\.rustup/toolchains|/fuzz/)" \ + --output-dir "$OUTPUT_DIR" echo "Coverage report generated in $OUTPUT_DIR/html/index.html" else # Clean previous coverage artifacts to ensure a fresh run. @@ -78,7 +82,10 @@ else fi echo "Replaying imported corpus (if found) via tests to generate coverage..." - cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \ + cargo llvm-cov -j8 --codecov \ + --dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \ + --no-default-ignore-filename-regex \ + --ignore-filename-regex "(\.cargo/registry|\.rustup/toolchains|/fuzz/)" \ --output-path "$OUTPUT_DIR/fuzz-codecov.json" --tests echo "Fuzz codecov report available at $OUTPUT_DIR/fuzz-codecov.json"