← Back to Pull requests

TheRock : Code Coverage - enable code coverage report generation #8602

Open
unknown opened this pull request with 515 lines diff across 6 files
View on GitHub
unknown unknown commented on Sep 29, 2026 16:29 UTC
Author

Motivation

GitHub issue: https://github.com/ROCm/TheRock/issues/6572

This is the report part of TheRock's code coverage support. It adds merge_coverage_report.py, which turns the .profraw files collected by a coverage test run into coverage reports.

It is the second of six PRs in the code coverage stack, which from the bottom is #9717, #8602, #10334, #8598, #10335 and #8605. It doesn't depend on #9717; it sits on it only because a stack is a single chain.

Technical Details

build_tools/github_actions/merge_coverage_report.py (new):

  • Finds every .profraw file under --profraw-dir, searching recursively. Instrumented binaries write one per process, so a sharded test job leaves many, spread across its downloaded artifacts.

  • Merges them with llvm-profdata merge -sparse into one .profdata index (--profdata-output, default coverage-report/coverage.profdata).

  • Resolves --object-globs (comma-separated, relative to --rocm-dir) to the instrumented binaries to report on. Versioned symlinks such as libfoo.so and libfoo.so.1 count once.

  • Writes an lcov report with llvm-cov export (--lcov-output, default coverage-report/coverage.info), which is what Codecov consumes. On request it also writes a per-file text summary (--summary-output) and an annotated HTML report (--html-output). Only the HTML report reads the sources; --path-equivalence remaps the source paths recorded at build time when the sources have moved.

  • Takes llvm-profdata and llvm-cov from <rocm-dir>/lib/llvm/bin by default (--llvm-bin-dir overrides it), because they must match the compiler that built the instrumented binaries. If they aren't there, it falls back to PATH with a warning.

  • Fails when no profiles were collected, unless --allow-empty is passed, and when none of the object globs match.
  • build_tools/github_actions/tests/merge_coverage_report_test.py (new): 19 unit tests covering tool lookup, profile discovery, object resolution, the llvm-profdata and llvm-cov command lines, and the main flow. They mock subprocess.run and shutil.which, so they need no ROCm install.

    In CI, the per-project report job (#10334) will download the .profraw files uploaded by the project's test shards, run this script, and upload the reports as an artifact.

    Producing a report locally after running an instrumented project's tests:

    export LLVM_PROFILE_FILE="$PWD/coverage-report/profraw/%p-%m.profraw"
    # ... run the tests ...
    python build_tools/github_actions/merge_coverage_report.py \
      --profraw-dir coverage-report/profraw \
      --rocm-dir <installed ROCm tree> \
      --object-globs "lib/libhiprand.so*" \
      --summary-output coverage-report/coverage_summary.txt \
      --html-output coverage-report/html
    

    Test Plan

  • Unit tests: merge_coverage_report_test.py (Python 3.12).

  • pre-commit run on the changed files.

  • End to end on an MI325X (gfx942): run hipDNN's tests in the CI test container against the instrumented hipDNN from the rocm-libraries coverage run 36168158239 with LLVM_PROFILE_FILE set. Then generate the lcov, text and HTML reports with merge_coverage_report.py and compare the totals with that run's own Coverage Report job.

  • CI on this PR.
  • Test Result

  • Unit tests: 19 passed.

  • pre-commit: all hooks pass.

  • End to end on an MI325X (gfx942):

  • - hipDNN's tests: 11/11 passed, writing 39 .profraw files.
    - merge_coverage_report.py: lcov for 183 source files, the text summary, and a 181-page HTML report using --path-equivalence. Totals are 81.09% of lines, 75.42% of functions, 83.92% of regions and 80.07% of branches, identical to that run's own Coverage Report job.
  • CI on this PR: pre-commit, Unit Tests (Linux and Windows) and the security scan pass. Multi-Arch CI: in progress (run 46054353272).
  • Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md.
  • Diff: 515 lines (+386 / -129) across 6 files Reviewer: endurthiabhilash Review duration: 90778m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.55) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 515 lines diff across 6 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #8602"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 54.7% (MEDIUM) · Higher = larger blast radius
    54.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.2% · Safe to merge
    30.2%
    Repository