Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions contrib/generate_fuzz_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lightning-types is a transitive dependency (used by lightning, lightning-invoice, and lightning-liquidity) and contains non-trivial code (features.rs, payment.rs, routing.rs, string.rs). It should likely be included in the --dep-coverage list so that coverage of its code is tracked.

Similarly, possiblyrandom is a dependency of lightning and may warrant inclusion depending on whether its coverage is of interest.

--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.
Expand All @@ -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 \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --dep-coverage list and the --ignore-filename-regex are now duplicated between the HTML path (lines 60-64) and the codecov JSON path (lines 85-88). If a new dependency is added to fuzz/Cargo.toml, both places must be updated in lockstep. Consider extracting these common flags into a shell variable (e.g., LLVM_COV_FLAGS) to avoid divergence.

--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"
Expand Down
Loading