The following two Python scripts are used for comparing test results and code coverage across different runs. These are especially useful in comparison of AMD based runs against H100 runs, as well as in continuous integration pipelines.
-
cucim_compare_junit.pyCompare two XML test reports -
cucim_compare_coverage.pyCompare two coverage.py XML reports
Note that these scripts are integrated into the ../run_amd script as part of
the Python tests and the comparison reports are automatically written to the
files junit-cucim_report.txt and cucim-coverage_report.txt, respectively,
after each run.
- Detects test regressions, fix-ups, additions, and removals.
- Prints a summary of total tests, test suite name, run time, host, and path.
- Ensures test suite consistency between runs.
- Compares overall line and branch coverage rates.
- Detects coverage regressions, improvements, and file-level changes.
- Displays detailed metadata: version, run timestamp, line and branch statistics.
- Handles divergent source paths gracefully.
- Python 3.7+
- Standard libraries only (no third-party dependencies)
- LLVM tools for C++ coverage (llvm package)
hipCIM supports code coverage for both C++ and Python components to help ensure comprehensive testing.
hipCIM includes integrated code coverage support for C++ components using LLVM coverage tools.
Install LLVM tools for coverage analysis:
sudo apt update && sudo apt install -y llvmSingle Command
# Generate coverage with debug build (more accurate)
./run_amd cpp_coverage
# Or with release build
./run_amd cpp_coverage releaseThis command will:
- Run all C++ tests with coverage enabled
- Generate coverage data (.profraw files)
- Create HTML coverage report at
coverage_report/index.html - Display coverage summary in terminal
Terminal Summary: After running coverage, you'll see a summary showing file-by-file coverage percentages.
HTML Report:
# View locally (if GUI available)
firefox coverage_report/index.html
# View remotely (on server)
cd coverage_report
python3 -m http.server 8080
# Open http://your-server-ip:8080 in browserThe HTML report provides:
- Interactive file-by-file coverage visualization
- Line-by-line coverage highlighting (green=covered, red=not covered)
- Function-level coverage statistics
- Detailed source code view with coverage annotations
Generated Files:
coverage_report/index.html- Main HTML coverage reportmerged.profdata- Merged coverage profile datacode_cov_*.profraw- Raw coverage data from test runs
The coverage system is integrated into the CMake build system through the ENABLE_CODE_COVERAGE option:
- Automatically detects compiler type (hipcc/clang vs gcc)
- Applies appropriate coverage flags (
-fprofile-instr-generate -fcoverage-mappingfor LLVM) - Excludes test and benchmark code from coverage metrics
- Works with existing build and test infrastructure
The C++ coverage report generated by LLVM's llvm-cov or gcov/lcov shows how much of each file was executed when running your test suite. Each row corresponds to one source/header file with the following columns:
| Column | Meaning |
|---|---|
| Function Coverage | Percentage of functions in that file that were executed during tests. Example: 100.00% (3/3) means all 3 functions were executed at least once. |
| Line Coverage | Percentage of individual source lines executed during tests. Example: 78.87% (56/71) means 56 out of 71 relevant lines ran. |
| Region Coverage | A "region" is a block of code with a single entry and exit (e.g., part of a function, loop body, or conditional branch). Region coverage is finer-grained than line coverage. Example: 86.84% (33/38) means 33 out of 38 regions were executed. |
| Branch Coverage | Percentage of conditional branches (like if or switch cases) taken during tests.Example: 50.00% (10/20) means only half of all possible true/false or case outcomes were exercised. |
How to Interpret:
- High function but low branch coverage → Your tests are calling functions but not covering all decision paths inside them.
- 0% coverage → That file's code never ran during tests (often happens for unused dependencies or untested modules).
- High coverage across all columns → Strong, thorough testing.
Common Patterns in Your Report:
- Many
absl/*files have 0.00% coverage — likely third-party code not directly exercised by your tests. - Some Catch2 internal files show partial coverage (e.g., 60–80% line coverage) because only certain test scenarios hit their code paths.
- Files like
catch_get_random_seed.cpphave 100% across all metrics, meaning all lines, functions, and branches were tested.
Python code coverage is automatically generated when running Python tests through the run_amd script and saved as XML reports that can be compared using the cucim_compare_coverage.py tool described below.
Script: cucim_compare_junit.py
python cucim_compare_junit.py --baseline BASELINE_XML --report TEST_XML [--skip SKIPLIST]| Argument | Description | Required |
|---|---|---|
--baseline |
Path to baseline XML file | Yes |
--report |
Path to current test XML file | Yes |
--skip |
Path to plain text file containing list of files to skip from comparison | No |
- Metadata for both baseline and test runs
- Total tests
- Diagnostics on:
- Test suite mismatch
- Total tests mismatch
- Summary of:
- New passing tests
- New failing tests
- Fixed tests
- Removed tests
Script: cucim_compare_coverage.py
python cucim_compare_coverage.py --baseline BASELINE_XML --report COVERAGE_XML| Argument | Description | Required |
|---|---|---|
--baseline |
Path to baseline coverage XML | Yes |
--report |
Path to current coverage XML | Yes |
- Metadata for both baseline and test runs:
- Source path
- Coverage version
- Timestamp of run
- Line & branch statistics
- Complexity
- Overall line rate delta
- Regressions and progressions at the file level
- New or removed files in test run
A collection of known test results from prior executions, including those from
competitive systems, is maintained under the directory test_data/baseline/.
These baselines serve as reference points for comparison against current test
or coverage results.
To simplify identification and tracking, test result files adhere to a structured naming format that embeds the timestamp, host system, and versioning information. This standardization aids reproducibility and clarity.
-
Unit Test Results
Format:
junit-cucim_YYYYMMDD_HHMMSS_hostname.xmlExample:
junit-cucim_20250320_071825_rocm-framework-h100-sxm-1.xml -
Coverage Results
Format:
cucim-coverage_VERSION_TIMESTAMP.xmlExample:
cucim-coverage_v1.3_1742457165573.xml -
Expected Failures (Skip List)
Format:
junit-cucim_skiplist_YYYYMMDD_HHMMSS_hostname.txtExample:
junit-cucim_skiplist_20250320_071825_rocm-framework-h100-sxm-1.txt
To streamline comparisons, symbolic links are maintained to always point to the most recent test artifacts. These are used as the default baselines by the test automation scripts unless explicitly overridden via command-line options.
-
Latest unit test result
junit-cucim_latest.xml -
Latest coverage result
cucim-coverage_latest.xml -
Latest skip list
junit-cucim_skiplist_latest.txt
python cucim_compare_junit.py \
--baseline junit-cucim.xml \
--report AMD_lifescience/junit-cucim.xmlSample output:
===== Test Report Comparison Summary =====
Baseline Report:
File : junit-cucim.xml
Suite Name : pytest
Tests : 10626
Timestamp : 2025-03-20T07:18:25.157139+00:00
Hostname : rocm-framework-h100-sxm-1
Current Report:
File : AMD_lifescience/junit-cucim.xml
Suite Name : pytest
Tests : 10617
Timestamp : 2025-04-29T12:34:40.305180+00:00
Hostname : hpe-hq-08
WARNING: Total test count differs: 10626 vs. 10617
===== Test Classification =====
Total Tests : 10627
Skipped Test(s) : 0
Regression(s) : 4840 (45.54%)
Progression(s) : 47 (0.44%)
Known Failure(s) : 0
Changed Failure(s) : 3
Missing Test(s) : 10
Extra Test(s) : 1
Missing Test Case(s):
src.cucim.skimage.restoration.tests.test_j_invariant::test_calibrate_denoiser
src.cucim.skimage.restoration.tests.test_j_invariant::test_calibrate_denoiser_extra_output
src.cucim.skimage.restoration.tests.test_j_invariant::test_calibrate_denoiser_tv
...
Extra Test Case(s):
tests.unit.clara.converter.test_converter::test_image_converter_stripe_4096x4096_256_jpeg
Regression(s):
src.cucim.skimage._vendored.tests.test_morphology::test_binary_axes[binary_closing-0-origin0-0]
src.cucim.skimage._vendored.tests.test_morphology::test_binary_axes[binary_closing-0-origin0-1]
src.cucim.skimage._vendored.tests.test_morphology::test_binary_axes[binary_closing-0-origin1-0]
...
Progression(s):
tests.performance.clara.test_read_region_memory_usage::test_read_random_region_cpu_memleak[testimg_tiff_stripe_4096x4096_256_deflate]
tests.performance.clara.test_read_region_memory_usage::test_read_random_region_cpu_memleak[testimg_tiff_stripe_4096x4096_256_jpeg]
tests.performance.clara.test_read_region_memory_usage::test_read_random_region_cpu_memleak[testimg_tiff_stripe_4096x4096_256_raw]
...
Changed Failure(s):
tests.performance.clara.test_read_region_memory_usage::test_read_region_cuda_memleak
tests.unit.clara.test_image_cache::test_get_shared_memory_cache
...
python cucim_compare_coverage.py \
--baseline cucim-coverage.xml \
--report AMD_lifescience/cucim-coverage.xmlSample output:
==== Coverage Report Comparison ====
Baseline File: cucim-coverage.xml
Source Path: /home/goplanid/cucim/python/cucim
Coverage Ver: 7.7.0
Timestamp: 2025-03-20 13:22:45
Lines Valid: 10,077
Lines Covered: 9,384
Line Rate: 93.12%
Branches Valid: 0
Branches Covered:0
Branch Rate: 0.00%
Complexity: 0.0
Report File: AMD_lifescience/cucim-coverage.xml
Source Path: /home/dgoplani/dgoplani_cucim/hipCIM/python/cucim
Coverage Ver: 7.8.0
Timestamp: 2025-04-29 18:48:16
Lines Valid: 11,000
Lines Covered: 8,524
Line Rate: 77.49%
Branches Valid: 0
Branches Covered:0
Branch Rate: 0.00%
Complexity: 0.0
Line Rate Delta: -15.63%
New Files:
- src/cucim/clara/converter/tiff.py: 90.29%
- src/cucim/skimage/measure/tests/test_regionprops.py: 12.80%
Regressions:
- src/cucim/skimage/_shared/_gradient.py: 96.55% vs. 93.10%
- src/cucim/skimage/_shared/coord.py: 100.00% vs. 93.02%
...
Progressions:
- src/cucim/clara/__init__.py: 42.86% vs. 100.00%
- src/cucim/clara/cache/__init__.py: 0.00% vs. 100.00%
Test Comparison will emit diagnostics if:
- Test suite names differ → "ERROR: Test suite name mismatch"
- Total test count differs → "WARNING: Total test count mismatch"
Coverage Comparison:
- Does not raise errors for source path mismatches
- Prints line rate delta and categorizes changes
Potential enhancement(s):
- Export diffs as JSON/XML for downstream tools
- Write comparison report to a file based on CLI option
- Integrate with CI/CD (e.g., GitHub Actions, GitLab, Jenkins)
- Colorized terminal output