tests: harden topotest gcov coverage setup and reporting - #22104
Conversation
Jafaral
commented
May 29, 2026
- Exit immediately during pytest configure when --cov-topotest is used without a gcov-enabled build, with a clear message instead of failing every test with missing GCOV_* env var errors.
- Make parallel coverage collection reliable under xdist by compiling gcov builds with -fprofile-update=atomic and having lcov ignore corrupted counters so full topotest runs still produce coverage.info.
Exit during pytest configure if no *.gcno files are found, instead of running all topotests and failing with missing GCOV_* env var KeyErrors. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Greptile SummaryThis PR hardens the gcov/lcov coverage infrastructure for topotests in two ways: it adds early failure with clear diagnostics when
Confidence Score: 5/5Safe to merge β all changes are confined to the gcov/lcov coverage tooling path and do not touch any FRR daemon code or test logic. The changes are narrowly scoped: early-exit guards in setup_coverage, a new version-detection helper for lcov, and one new compiler flag gated behind AC_C_FLAG. The lcov 1.x/2.x compatibility concern raised in prior reviews is correctly resolved by probing lcov --version stdout and restricting 2.x-only categories to matching systems. The -fprofile-update=atomic flag is silently dropped by AC_C_FLAG on compilers that don't support it, so there is no risk of breaking older build environments. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["pytest --cov-topotest"] --> B["setup_coverage()"]
B --> C{build dir exists?}
C -- No --> D["pytest.exit() with clear message"]
C -- Yes --> E["find zebra_nb.gcno"]
E --> F{gcno files found?}
F -- No --> G["pytest.exit() with rebuild instructions"]
F -- Yes --> H["Set FRR_BUILD_DIR / GCOV_PREFIX env vars"]
H --> I["Run tests (FRR writes .gcda files)"]
I --> J["coverage_finish()"]
J --> K{FRR_BUILD_DIR and GCOV_PREFIX set?}
K -- No --> L["Log warning and return"]
K -- Yes --> M["lcov_ignore_errors(commander)"]
M --> N["lcov --version"]
N --> O{LCOV version 2?}
O -- Yes --> P["negative,gcov,source,unexecuted"]
O -- No --> Q["gcov,source"]
P & Q --> R["lcov --capture --ignore-errors ..."]
R --> S["coverage.info"]
S --> T["lcov --summary"]
Reviews (2): Last reviewed commit: "tests: make gcov coverage robust under p..." | Re-trigger Greptile |
Use -fprofile-update=atomic for gcov builds and tell lcov to ignore corrupted counters so xdist runs can still produce coverage.info. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
|
once ci finishes I'll get this in |
|
@Mergifyio backport stable/10.6 stable/10.5 |
β Backports have been createdDetails
|
tests: harden topotest gcov coverage setup and reporting (backport #22104)