diff options
author | Gilles Peskine <Gilles.Peskine@arm.com> | 2022-12-16 12:03:39 +0100 |
---|---|---|
committer | Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com> | 2022-12-19 10:17:10 +0100 |
commit | 38a49560ded58c0bf32b6497beb7a4d1e46d61eb (patch) | |
tree | c7518b1f56c6c0e38d11bcef7efd5387ba4643bd | |
parent | 2200f12094d57deb81ee7b199077a0966583917e (diff) | |
download | mbedtls-38a49560ded58c0bf32b6497beb7a4d1e46d61eb.zip mbedtls-38a49560ded58c0bf32b6497beb7a4d1e46d61eb.tar.gz mbedtls-38a49560ded58c0bf32b6497beb7a4d1e46d61eb.tar.bz2 |
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>
-rwxr-xr-x | tests/scripts/basic-build-test.sh | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/tests/scripts/basic-build-test.sh b/tests/scripts/basic-build-test.sh index 3a90291..7c0fe5a 100755 --- a/tests/scripts/basic-build-test.sh +++ b/tests/scripts/basic-build-test.sh @@ -247,35 +247,16 @@ rm -f "tests/basic-build-test-$$.ok" echo - # Step 4e - Coverage - echo "Coverage" - - LINES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* lines)/\1/p') - LINES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) lines)/\1/p') - FUNCS_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* functions)$/\1/p') - FUNCS_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) functions)$/\1/p') - BRANCHES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* branches)$/\1/p') - BRANCHES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) branches)$/\1/p') - - LINES_PERCENT=$((1000*$LINES_TESTED/$LINES_TOTAL)) - LINES_PERCENT="$(($LINES_PERCENT/10)).$(($LINES_PERCENT-($LINES_PERCENT/10)*10))" - - FUNCS_PERCENT=$((1000*$FUNCS_TESTED/$FUNCS_TOTAL)) - FUNCS_PERCENT="$(($FUNCS_PERCENT/10)).$(($FUNCS_PERCENT-($FUNCS_PERCENT/10)*10))" - - BRANCHES_PERCENT=$((1000*$BRANCHES_TESTED/$BRANCHES_TOTAL)) - BRANCHES_PERCENT="$(($BRANCHES_PERCENT/10)).$(($BRANCHES_PERCENT-($BRANCHES_PERCENT/10)*10))" + # Step 4e - Coverage report + echo "Coverage statistics:" + sed -n '1,/^Overall coverage/d; /%/p' cov-$TEST_OUTPUT + echo rm unit-test-$TEST_OUTPUT rm sys-test-$TEST_OUTPUT rm compat-test-$TEST_OUTPUT rm cov-$TEST_OUTPUT - echo "Lines Tested : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%" - echo "Functions Tested : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%" - echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%" - echo - # Mark the report generation as having succeeded. This must be the # last thing in the report generation. touch "basic-build-test-$$.ok" |