Skip to content

Commit 98d3a67

Browse files
Simplify the coverage statistics summary
The script was parsing the output from `make lcov` to extract numbers and calculate percentages. But everything including the percentages is already present in the output of `make lcov`, just with a slightly different presentation. So replace all this by a simple extraction of the relevant lines from the output of `make lcov`. This is more robust than the previous code, which relied on `tail -n4` to extract relevant lines, which broke when `make lcov` started to emit one extra line at the end. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent 057b458 commit 98d3a67

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

tests/scripts/basic-build-test.sh

+4-23
Original file line numberDiff line numberDiff line change
@@ -243,35 +243,16 @@ rm -f "tests/basic-build-test-$$.ok"
243243
echo
244244

245245

246-
# Step 4e - Coverage
247-
echo "Coverage"
248-
249-
LINES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* lines)/\1/p')
250-
LINES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) lines)/\1/p')
251-
FUNCS_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* functions)$/\1/p')
252-
FUNCS_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) functions)$/\1/p')
253-
BRANCHES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* branches)$/\1/p')
254-
BRANCHES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) branches)$/\1/p')
255-
256-
LINES_PERCENT=$((1000*$LINES_TESTED/$LINES_TOTAL))
257-
LINES_PERCENT="$(($LINES_PERCENT/10)).$(($LINES_PERCENT-($LINES_PERCENT/10)*10))"
258-
259-
FUNCS_PERCENT=$((1000*$FUNCS_TESTED/$FUNCS_TOTAL))
260-
FUNCS_PERCENT="$(($FUNCS_PERCENT/10)).$(($FUNCS_PERCENT-($FUNCS_PERCENT/10)*10))"
261-
262-
BRANCHES_PERCENT=$((1000*$BRANCHES_TESTED/$BRANCHES_TOTAL))
263-
BRANCHES_PERCENT="$(($BRANCHES_PERCENT/10)).$(($BRANCHES_PERCENT-($BRANCHES_PERCENT/10)*10))"
246+
# Step 4e - Coverage report
247+
echo "Coverage statistics:"
248+
sed -n '1,/^Overall coverage/d; /%/p' cov-$TEST_OUTPUT
249+
echo
264250

265251
rm unit-test-$TEST_OUTPUT
266252
rm sys-test-$TEST_OUTPUT
267253
rm compat-test-$TEST_OUTPUT
268254
rm cov-$TEST_OUTPUT
269255

270-
echo "Lines Tested : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%"
271-
echo "Functions Tested : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%"
272-
echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
273-
echo
274-
275256
# Mark the report generation as having succeeded. This must be the
276257
# last thing in the report generation.
277258
touch "basic-build-test-$$.ok"

0 commit comments

Comments
 (0)