From 11120f9c4d1ea1f951dd36a405e92fc672a72470 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Thu, 19 Oct 2023 15:27:59 +0100 Subject: [PATCH 1/2] Modify lcov.sh to work in tf-psa-crypto as well Add repository detection (credit to davidhorstmann-arm for adding this in all.sh previously) and use repository detection to set the library directory and title variables. Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 6bba02fd24..9e52b98441 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -42,16 +42,21 @@ EOF set -eu +# Repository detection +in_mbedtls_repo () { + test -d include -a -d library -a -d programs -a -d tests + } + # Collect stats and build a HTML report. lcov_library_report () { rm -rf Coverage mkdir Coverage Coverage/tmp - lcov --capture --initial --directory library -o Coverage/tmp/files.info - lcov --rc lcov_branch_coverage=1 --capture --directory library -o Coverage/tmp/tests.info + lcov --capture --initial --directory $library_dir -o Coverage/tmp/files.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 --remove Coverage/tmp/all.info -o Coverage/tmp/final.info '*.h' 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 echo "Coverage report in: Coverage/index.html" } @@ -59,9 +64,9 @@ lcov_library_report () { # Reset the traces to 0. lcov_reset_traces () { # Location with plain make - rm -f library/*.gcda + rm -f $library_dir/*.gcda # Location with CMake - rm -f library/CMakeFiles/*.dir/*.gcda + rm -f $library_dir/CMakeFiles/*.dir/*.gcda } if [ $# -gt 0 ] && [ "$1" = "--help" ]; then @@ -69,6 +74,14 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then exit fi +if in_mbedtls_repo; then + library_dir='library' + title='Mbed TLS' +else + library_dir='build/core' + title='TF-PSA-Crypto' +fi + main=lcov_library_report while getopts r OPTLET; do case $OPTLET in From c0ae5690669871b6e00e90eec211aaa1b17f99b0 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Mon, 23 Oct 2023 17:25:52 +0100 Subject: [PATCH 2/2] Make lcov.sh run from the build directory lcov.sh can now be called from any build directory and also still works with in-place builds too. Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 9e52b98441..2cf566a8d2 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -43,8 +43,8 @@ EOF set -eu # Repository detection -in_mbedtls_repo () { - test -d include -a -d library -a -d programs -a -d tests +in_mbedtls_build_dir () { + test -d library } # Collect stats and build a HTML report. @@ -74,11 +74,11 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then exit fi -if in_mbedtls_repo; then +if in_mbedtls_build_dir; then library_dir='library' title='Mbed TLS' else - library_dir='build/core' + library_dir='core' title='TF-PSA-Crypto' fi