Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 82 additions & 2 deletions .github/workflows/L1-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,91 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run unit tests
run: sh run_ut.sh
run: |
if sh -e run_ut.sh --enable-cov; then
echo "PR L1 tests and coverage collection passed."
else
status=$?
echo "::error title=L1 tests failed::PR L1 build, unit tests or coverage collection failed (exit $status). See the failing command and gtest results above."
exit "$status"
fi

- name: Upload test results to automatic test result management system
run: >
gtest-json-result-push.py /tmp/Gtest_Report https://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results `pwd`

- name: Checkout base commit for L1 coverage comparison
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .l1-base

- name: Collect base L1 coverage using the same runner
working-directory: .l1-base
run: |
if sh -e "$GITHUB_WORKSPACE/run_ut.sh" --enable-cov; then
echo "Base L1 coverage collected successfully."
else
status=$?
echo "::error title=L1 baseline failed::Base-commit build, tests or coverage collection failed (exit $status); coverage regression cannot be checked."
exit "$status"
fi

- name: Fail if L1 line coverage decreases
uses: actions/github-script@v7
with:
script: |
const fs = require('node:fs');
function readCoverage(file, label) {
try {
const text = fs.readFileSync(file, 'utf8').trim();
if (!text.endsWith('end_of_record')) throw new Error('Empty or incomplete tracefile');
const sources = new Set();
let hit = 0;
let found = 0;
for (const record of text.split('end_of_record')) {
if (!record.trim()) continue;
const source = record.match(/^SF:(.+)\r?$/m);
const linesHit = record.match(/^LH:(\d+)\r?$/m);
const linesFound = record.match(/^LF:(\d+)\r?$/m);
if (!source || !linesHit || !linesFound) throw new Error('Missing SF/LH/LF counters');
const name = source[1].trim();
const recordHit = Number(linesHit[1]);
const recordFound = Number(linesFound[1]);
if (!name || sources.has(name) || recordHit > recordFound) {
throw new Error('Duplicate source or inconsistent coverage counters');
}
sources.add(name);
hit += recordHit;
found += recordFound;
}
if (!Number.isSafeInteger(hit) || !Number.isSafeInteger(found) || found === 0) {
throw new Error('No valid executable-line coverage');
}
return { hit, found };
} catch (error) {
throw new Error(`${label} coverage unavailable or invalid: ${error.message}`);
}
}
try {
const base = readCoverage('.l1-base/src/unittest/coverage.info', 'Base');
const head = readCoverage('src/unittest/coverage.info', 'PR');
const percentage = value => `${(100 * value.hit / value.found).toFixed(6)}%`;
const decreased = BigInt(head.hit) * BigInt(base.found) < BigInt(base.hit) * BigInt(head.found);
const message = `PR ${percentage(head)} (${head.hit}/${head.found} lines); base ${percentage(base)} (${base.hit}/${base.found} lines).`;
await core.summary.addHeading('L1 Coverage Comparison')
.addRaw(`${decreased ? 'FAIL: coverage decreased.' : 'PASS: no coverage decrease.'} ${message}`)
.write();
if (decreased) {
core.setFailed(`L1 line coverage decreased. ${message} No decrease is allowed; full-precision ratios are compared.`);
} else {
core.info(`L1 line coverage passed. ${message}`);
}
} catch (error) {
core.setFailed(error.message);
}
2 changes: 1 addition & 1 deletion .github/workflows/L2-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'rdkcentral/docker-device-mgt-service-test'
ref: 'develop'
ref: 'feature/l2docupdate'
path: docker-device-mgt-service-test

- name: Check out dependent repostiories
Expand Down
4 changes: 4 additions & 0 deletions test/functional-tests/L2_Coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
| Functions hit | 76 |
| Functions not hit | 52 |
| Current functional coverage | 59.4% |
| Compiled-function coverage (lcov) | 61.1% (77/126 functions) |
| Target L2 functional coverage | ~100% |

> Function coverage = functions called at least once during the L2 run (lcov `FNDA` > 0),
> divided by all function definitions in `src/*.c`, including those compiled out by `#if`.

> Compiled-function coverage (lcov) = sum of FNH / sum of FNF for matched module files.
> This measures compiled functions recorded by lcov, excluding compiled-out definitions.

**L2 Test Summary**

| Metric | Value |
Expand Down
Loading