Skip to content

dev: LLVM source-based code coverage support#8885

Open
cdecker wants to merge 1 commit intomasterfrom
20240102-coverage
Open

dev: LLVM source-based code coverage support#8885
cdecker wants to merge 1 commit intomasterfrom
20240102-coverage

Conversation

@cdecker
Copy link
Member

@cdecker cdecker commented Feb 5, 2026

Summary

Add support for LLVM source-based code coverage instrumentation, enabling developers and CI to generate coverage reports for the Core Lightning codebase.

Changes

Build System

  • Makefile: Add coverage-clang-collect and coverage-clang-report targets for collecting and generating coverage reports
  • Makefile: Fix missing endif for PYTEST_TESTS conditional
  • Makefile: Respect CARGO_TARGET_DIR environment variable for Rust builds

Coverage Scripts (contrib/coverage/)

  • collect-coverage.sh: Merges .profraw files into a single .profdata file with validation, parallel processing, and batch handling for large file counts
  • generate-coverage-report.sh: Generates HTML reports using llvm-cov show for all instrumented binaries

CI Workflow

  • coverage.yaml: Daily workflow that builds with coverage instrumentation, runs tests, and publishes HTML reports to GitHub Pages

Usage

# Configure with coverage enabled
./configure --enable-coverage CC=clang

# Build
make -j$(nproc)

# Run tests with coverage collection
CLN_COVERAGE_DIR=/tmp/cln-coverage make pytest

# Generate coverage report
make coverage-clang
# Report available at coverage/html/index.html

Notes

  • Uses LLVM's source-based coverage instrumentation (-fprofile-instr-generate -fcoverage-mapping)
  • Handles CLN's multi-process architecture by collecting per-test .profraw files
  • Coverage scripts validate and filter corrupt/incomplete profile files before merging

Add support for LLVM source-based code coverage instrumentation, enabling
developers and CI to generate coverage reports for the Core Lightning codebase.

Build System:
- Add coverage-clang-collect and coverage-clang-report Makefile targets
- Fix missing endif for PYTEST_TESTS conditional
- Respect CARGO_TARGET_DIR environment variable for Rust builds

Coverage Scripts (contrib/coverage/):
- collect-coverage.sh: Merges .profraw files with validation and batching
- generate-coverage-report.sh: Generates HTML reports using llvm-cov

CI Workflow:
- coverage.yaml: Daily workflow for building, testing, and publishing reports

Usage:
  ./configure --enable-coverage CC=clang
  make -j$(nproc)
  CLN_COVERAGE_DIR=/tmp/cln-coverage make pytest
  make coverage-clang

Changelog-Changed: Added LLVM source-based code coverage support with CI integration
@cdecker
Copy link
Member Author

cdecker commented Feb 5, 2026

@rustyrussell sorry for forgetting the script files in the coverage PR. It was being covered by .gitignore so I didn't see them when staging the content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant