Repository navigation
coverage: adopt the LLVM coverage pipeline from score_tooling #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4ec6667
cc9a655
836ea2d
2a404d1
9c0a6a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,3 +62,5 @@ rust-project.json | |
|
|
||
| # CodeQL local analysis output (any --output-dir placed inside the repo) | ||
| codeql-*/ | ||
| coverage_*/ | ||
| summary.md | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. summary.md?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it will be updated to github summary page of the coverage job |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| load("@score_tooling//coverage:defs.bzl", "score_coverage_reporter", "score_coverage_scope") | ||
|
|
||
| # The production components of this module (the public faces the old | ||
| # cpp-coverage workflow also targeted via //score/...). The scope aspect walks | ||
| # their transitive in-workspace deps; test suites, mocks (*_mock, | ||
| # *_test_utils) and external deps are not reachable from these roots and stay | ||
| # out of the report. Untested in-scope files appear at exact 0% via the | ||
| # --empty-profile baseline. Keep this list in sync with the module's shipped | ||
| # components. | ||
| score_coverage_scope( | ||
| name = "coverage_scope", | ||
| testonly = True, | ||
| visibility = ["//visibility:private"], | ||
| deps = [ | ||
| # Standalone public clock APIs, not reachable through the daemons: | ||
| "//score/time/steady_time", | ||
| "//score/time/system_time", | ||
| "//score/time/vehicle_time", | ||
| # The daemons transitively bring in clock_core, high_res_steady_clock | ||
| # and ts_client's gptp_ipc (verified via bazel query deps()). | ||
| # KNOWN GAP: the cc_binary entry-point sources themselves (main.cpp, | ||
| # time_daemon.cpp, time_slave.cpp) are not collected — cc_binary | ||
| # provides no CcInfo for the scope aspect. Entry-point wiring is not | ||
| # unit-testable; tracked as a scope-aspect enhancement in score_tooling. | ||
| "//score/time_daemon", | ||
| "//score/time_slave", | ||
| ], | ||
| ) | ||
|
|
||
| score_coverage_reporter( | ||
| name = "reporter_wrapper", | ||
| testonly = True, | ||
| coverage_scope = ":coverage_scope", | ||
| llvm_cov = "@llvm_toolchain_coverage//:llvm-cov", | ||
| llvm_cxxfilt = "@llvm_toolchain_coverage_llvm//:bin/llvm-cxxfilt", | ||
| llvm_profdata = "@llvm_toolchain_coverage//:llvm-profdata", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| # ============================================================================ | ||
| # LLVM source-based coverage (Linux, Clang covmap) — C++ | ||
| # Pipeline: @score_tooling//coverage (see its README.md for the guide). | ||
| # Use with: bazel coverage --config=llvm_cov //score/... --build_tests_only | ||
| # | ||
| # Do NOT combine with configs that register other C++ toolchains: the last | ||
| # --extra_toolchains wins resolution and a GCC toolchain produces no covmap. | ||
| # ============================================================================ | ||
|
|
||
| coverage:llvm_cov --nocache_test_results | ||
| coverage:llvm_cov --cxxopt=-O0 | ||
| coverage:llvm_cov --combined_report=lcov | ||
| coverage:llvm_cov --experimental_fetch_all_coverage_outputs | ||
|
|
||
| # Per-test .so files can carry clashing instrumentation between production and | ||
| # test code; the first object loaded wins, causing flaky coverage gaps. | ||
| coverage:llvm_cov --dynamic_mode=off | ||
|
|
||
| coverage:llvm_cov --experimental_generate_llvm_lcov | ||
| # NOTE: --experimental_use_llvm_covmap instruments ALL targets; source | ||
| # filtering happens at report time via the score_coverage_scope allowlist. | ||
| coverage:llvm_cov --experimental_use_llvm_covmap | ||
| coverage:llvm_cov --extra_toolchains=@llvm_toolchain_coverage//:cc-toolchain-x86_64-linux | ||
|
|
||
| coverage:llvm_cov --coverage_output_generator=@score_tooling//coverage:merger | ||
| coverage:llvm_cov --coverage_report_generator=//tools/coverage:reporter_wrapper | ||
|
|
||
| # Keep raw profraw files; the merger handles profraw -> profdata directly. | ||
| coverage:llvm_cov --test_env=GENERATE_LLVM_LCOV=0 | ||
| coverage:llvm_cov --test_env=COVERAGE_GCOV_PATH=/usr/bin/true | ||
|
|
||
| # Continuous-mode profiling: covers abnormal termination (death tests). | ||
| coverage:llvm_cov --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 | ||
| coverage:llvm_cov --features=enable_llvm_coverage_for_death_tests | ||
|
|
||
| # Under the LLVM toolchain the `coverage` feature expands to | ||
| # -fprofile-instr-generate -fcoverage-mapping (the covmap instrumentation). | ||
| coverage:llvm_cov --features=coverage | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about destingwishing between qnx and host build?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think as written in PR body, QNX is tracked as no functional yet |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| # | ||
| # Coverage Justification Database | ||
| # ================================ | ||
| # | ||
| # This file defines justified non-covered lines for achieving 100% effective coverage. | ||
| # | ||
| # Each justification has: | ||
| # - id: Unique kebab-case identifier | ||
| # - category: One of: defensive_programming, tool_false_positive, platform_specific, other | ||
| # - reason: Explanation why the line(s) cannot be covered | ||
| # - platforms: (optional) List of platforms this justification applies to: [linux], [qnx], or [linux, qnx] | ||
| # When omitted, the justification applies to all platforms. | ||
| # - locations: (optional) File + line specifications where justification applies | ||
| # | ||
| # Lines can also be justified via in-code markers referencing the ID: | ||
| # // COV_JUSTIFIED <id> — justifies the current line | ||
| # // COV_JUSTIFIED_START <id> — starts a justified region | ||
| # // COV_JUSTIFIED_STOP — ends the justified region | ||
| # | ||
| # Validation rules: | ||
| # - IDs must be unique and kebab-case (lowercase + hyphens) | ||
| # - Every justification needs a non-empty reason | ||
| # - Stale justifications (line is actually covered) produce warnings | ||
| # - References to non-existent IDs produce errors | ||
| # | ||
|
|
||
| version: 1 | ||
|
|
||
| justifications: | ||
| # Example entries (uncomment and adapt as needed): | ||
| # | ||
| # - id: config-parser-defensive-switch | ||
| # category: defensive_programming | ||
| # reason: > | ||
| # Default case in switch over fully-handled enum. All enum values are explicitly | ||
| # handled with a static_assert guard. Kept as defensive programming against | ||
| # future enum additions. | ||
| # locations: | ||
| # - file: score/mw/com/impl/configuration/config_parser.cpp | ||
| # line_start: 1201 | ||
| # line_end: 1203 | ||
| # | ||
| # - id: runtime-tool-false-positive | ||
| # category: tool_false_positive | ||
| # platforms: [linux] # only applies to Linux coverage | ||
| # reason: > | ||
| # Coverage tool incorrectly marks this line as not covered. Lines immediately | ||
| # before and after are covered, indicating a tool bug. | ||
| # locations: | ||
| # - file: score/mw/com/impl/runtime.cpp | ||
| # lines: [191] | ||
| # | ||
| - id: time-jumps-validator-time-jump-state-default | ||
| category: defensive_programming | ||
| platforms: [linux, qnx] | ||
| reason: > | ||
| Default case in switch over TimeJumpState, a private enum with exactly three values (kJumpToFuture, kJumpToPast, kNoTimeJump), all of which are explicitly handled above. Kept as defensive programming against future enum additions. | ||
| locations: | ||
| - file: score/time_daemon/src/verification_machine/svt/validators/time_jumps_validator.cpp | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really have the suppression there?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand you can do in source code also but You dont have to. I see this justification is in report Coverage Justification SummaryTotal instrumented lines: 2682 Raw line coverage: 86.61% Total branches: 796 |
||
| lines: [172, 173] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it defined by the tooling or where?
is there also the definitin of the branch coverage threshold?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/eclipse-score/tooling/blob/9a61f42bab23f1df5f7728a755ad42e2803dd6fe/coverage/README.md?plain=1#L28
I guess currently only lines. @dcalavrezo-qorix are we tracking some checks for branch too ?