Merge pull request from tom-daubney-arm/modify_lcov_script_tf_psa_crypto

Modify lcov.sh to work in tf-psa-crypto as well
This commit is contained in:
Paul Elliott 2023-11-02 15:56:21 +00:00 committed by GitHub
commit fc31cb28ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,16 +42,21 @@ EOF
set -eu set -eu
# Repository detection
in_mbedtls_build_dir () {
test -d library
}
# Collect stats and build a HTML report. # Collect stats and build a HTML report.
lcov_library_report () { lcov_library_report () {
rm -rf Coverage rm -rf Coverage
mkdir Coverage Coverage/tmp mkdir Coverage Coverage/tmp
lcov --capture --initial --directory library -o Coverage/tmp/files.info lcov --capture --initial --directory $library_dir -o Coverage/tmp/files.info
lcov --rc lcov_branch_coverage=1 --capture --directory library -o Coverage/tmp/tests.info lcov --rc lcov_branch_coverage=1 --capture --directory $library_dir -o Coverage/tmp/tests.info
lcov --rc lcov_branch_coverage=1 --add-tracefile Coverage/tmp/files.info --add-tracefile Coverage/tmp/tests.info -o Coverage/tmp/all.info lcov --rc lcov_branch_coverage=1 --add-tracefile Coverage/tmp/files.info --add-tracefile Coverage/tmp/tests.info -o Coverage/tmp/all.info
lcov --rc lcov_branch_coverage=1 --remove Coverage/tmp/all.info -o Coverage/tmp/final.info '*.h' lcov --rc lcov_branch_coverage=1 --remove Coverage/tmp/all.info -o Coverage/tmp/final.info '*.h'
gendesc tests/Descriptions.txt -o Coverage/tmp/descriptions gendesc tests/Descriptions.txt -o Coverage/tmp/descriptions
genhtml --title "Mbed TLS" --description-file Coverage/tmp/descriptions --keep-descriptions --legend --branch-coverage -o Coverage Coverage/tmp/final.info genhtml --title "$title" --description-file Coverage/tmp/descriptions --keep-descriptions --legend --branch-coverage -o Coverage Coverage/tmp/final.info
rm -f Coverage/tmp/*.info Coverage/tmp/descriptions rm -f Coverage/tmp/*.info Coverage/tmp/descriptions
echo "Coverage report in: Coverage/index.html" echo "Coverage report in: Coverage/index.html"
} }
@ -59,9 +64,9 @@ lcov_library_report () {
# Reset the traces to 0. # Reset the traces to 0.
lcov_reset_traces () { lcov_reset_traces () {
# Location with plain make # Location with plain make
rm -f library/*.gcda rm -f $library_dir/*.gcda
# Location with CMake # Location with CMake
rm -f library/CMakeFiles/*.dir/*.gcda rm -f $library_dir/CMakeFiles/*.dir/*.gcda
} }
if [ $# -gt 0 ] && [ "$1" = "--help" ]; then if [ $# -gt 0 ] && [ "$1" = "--help" ]; then
@ -69,6 +74,14 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then
exit exit
fi fi
if in_mbedtls_build_dir; then
library_dir='library'
title='Mbed TLS'
else
library_dir='core'
title='TF-PSA-Crypto'
fi
main=lcov_library_report main=lcov_library_report
while getopts r OPTLET; do while getopts r OPTLET; do
case $OPTLET in case $OPTLET in