From c0386bf2a70d7bce52ff4e4aa5331e26d7216f21 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 5 Dec 2023 11:02:30 +0000 Subject: [PATCH 1/8] Introduce project_name.txt This file is used for detecting which project a script is being run from. Signed-off-by: Thomas Daubney --- scripts/project_name.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/project_name.txt diff --git a/scripts/project_name.txt b/scripts/project_name.txt new file mode 100644 index 0000000000..a38cf263b6 --- /dev/null +++ b/scripts/project_name.txt @@ -0,0 +1 @@ +Mbed TLS From d9312eaa4bf20d828a3dc3e41572f43d1d482dba Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 5 Dec 2023 11:24:06 +0000 Subject: [PATCH 2/8] Modify all.sh to use new project name file Signed-off-by: Thomas Daubney --- tests/scripts/all.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 4f0e9bba14..03c9d321f8 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -115,12 +115,15 @@ set -e -o pipefail -u # Enable ksh/bash extended file matching patterns shopt -s extglob +# For project detection +PROJECT_NAME_FILE='./scripts/project_name.txt' + in_mbedtls_repo () { - test -d include -a -d library -a -d programs -a -d tests + grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" } in_tf_psa_crypto_repo () { - test -d include -a -d core -a -d drivers -a -d programs -a -d tests + grep -Fxq "TF-PSA-Crypto" "$PROJECT_NAME_FILE" } pre_check_environment () { From bbb41f7afb5be7d674a5eb95c8ce59e2dabfe9e0 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 5 Dec 2023 11:42:51 +0000 Subject: [PATCH 3/8] Modify lcov.sh to use new project name file Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 9a0c58243f..faf14f34e8 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -30,10 +30,12 @@ EOF set -eu -# Repository detection -in_mbedtls_build_dir () { - test -d library -} +# Project detection +PROJECT_NAME_FILE='./scripts/project_name.txt' + +in_mbedtls_repo () { + grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" + } # Collect stats and build a HTML report. lcov_library_report () { @@ -68,7 +70,7 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then exit fi -if in_mbedtls_build_dir; then +if in_mbedtls_repo; then library_dir='library' title='Mbed TLS' else From 6a864dc5feb9392d3a85424951e813e1e5bb595b Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Fri, 26 Jul 2024 17:31:46 +0100 Subject: [PATCH 4/8] Add check for existence of project name file Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 6 +++++- tests/scripts/all.sh | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index faf14f34e8..15b13c10ee 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -34,8 +34,12 @@ set -eu PROJECT_NAME_FILE='./scripts/project_name.txt' in_mbedtls_repo () { + if [ ! -f $PROJECT_NAME_FILE ]; then + echo "$PROJECT_NAME_FILE does not exist... Exiting..." + exit 1 + fi grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" - } +} # Collect stats and build a HTML report. lcov_library_report () { diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 03c9d321f8..fdd7b946e2 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -119,10 +119,18 @@ shopt -s extglob PROJECT_NAME_FILE='./scripts/project_name.txt' in_mbedtls_repo () { + if [ ! -f $PROJECT_NAME_FILE ]; then + echo "$PROJECT_NAME_FILE does not exist... Exiting..." + exit 1 + fi grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" -} + } in_tf_psa_crypto_repo () { + if [ ! -f $PROJECT_NAME_FILE ]; then + echo "$PROJECT_NAME_FILE does not exist... Exiting..." + exit 1 + fi grep -Fxq "TF-PSA-Crypto" "$PROJECT_NAME_FILE" } From 5e9ffa90960f77bb61ff8f425c6814a4c5a11ff1 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Mon, 29 Jul 2024 12:09:57 +0100 Subject: [PATCH 5/8] Redirect error message to stderr Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 2 +- tests/scripts/all.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 15b13c10ee..2885537e14 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -35,7 +35,7 @@ PROJECT_NAME_FILE='./scripts/project_name.txt' in_mbedtls_repo () { if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 exit 1 fi grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index fdd7b946e2..c17d627b54 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -120,7 +120,7 @@ PROJECT_NAME_FILE='./scripts/project_name.txt' in_mbedtls_repo () { if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 exit 1 fi grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" @@ -128,7 +128,7 @@ in_mbedtls_repo () { in_tf_psa_crypto_repo () { if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 exit 1 fi grep -Fxq "TF-PSA-Crypto" "$PROJECT_NAME_FILE" From b991ac2d9078ee82206bd4fb115f1dd26fdbad4b Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Mon, 29 Jul 2024 12:10:27 +0100 Subject: [PATCH 6/8] Remove suprious whitespace Signed-off-by: Thomas Daubney --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c17d627b54..a68c778ab4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -124,7 +124,7 @@ in_mbedtls_repo () { exit 1 fi grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" - } +} in_tf_psa_crypto_repo () { if [ ! -f $PROJECT_NAME_FILE ]; then From bda3e46846052eb84852e5ecb6a3828c849153e3 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 30 Jul 2024 15:52:58 +0100 Subject: [PATCH 7/8] Check for file at script startup Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 10 +++++----- tests/scripts/all.sh | 16 ++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 2885537e14..2d2f42bcbc 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -32,13 +32,13 @@ set -eu # Project detection PROJECT_NAME_FILE='./scripts/project_name.txt' +if read -r PROJECT_NAME < "$PROJECT_NAME_FILE"; then :; else + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 + exit 1 +fi in_mbedtls_repo () { - if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 - exit 1 - fi - grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" + test "$PROJECT_NAME" = "Mbed TLS" } # Collect stats and build a HTML report. diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index a68c778ab4..825cc673b7 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -117,21 +117,17 @@ shopt -s extglob # For project detection PROJECT_NAME_FILE='./scripts/project_name.txt' +if read -r PROJECT_NAME < "$PROJECT_NAME_FILE"; then :; else + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 + exit 1 +fi in_mbedtls_repo () { - if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 - exit 1 - fi - grep -Fxq "Mbed TLS" "$PROJECT_NAME_FILE" + test "$PROJECT_NAME" = "Mbed TLS" } in_tf_psa_crypto_repo () { - if [ ! -f $PROJECT_NAME_FILE ]; then - echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 - exit 1 - fi - grep -Fxq "TF-PSA-Crypto" "$PROJECT_NAME_FILE" + test "$PROJECT_NAME" = "TF-PSA-Crypto" } pre_check_environment () { From b55679736bed71a42f2c7d84580c531f85cca6e6 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 6 Aug 2024 17:35:38 +0100 Subject: [PATCH 8/8] Move some proj detection code inside pre_check_environment Signed-off-by: Thomas Daubney --- tests/scripts/all.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 825cc673b7..1202326a8f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -116,12 +116,6 @@ set -e -o pipefail -u shopt -s extglob # For project detection -PROJECT_NAME_FILE='./scripts/project_name.txt' -if read -r PROJECT_NAME < "$PROJECT_NAME_FILE"; then :; else - echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 - exit 1 -fi - in_mbedtls_repo () { test "$PROJECT_NAME" = "Mbed TLS" } @@ -131,6 +125,13 @@ in_tf_psa_crypto_repo () { } pre_check_environment () { + # For project detection + PROJECT_NAME_FILE='./scripts/project_name.txt' + if read -r PROJECT_NAME < "$PROJECT_NAME_FILE"; then :; else + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 + exit 1 + fi + if in_mbedtls_repo || in_tf_psa_crypto_repo; then :; else echo "Must be run from Mbed TLS / TF-PSA-Crypto root" >&2 exit 1