From bda3e46846052eb84852e5ecb6a3828c849153e3 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 30 Jul 2024 15:52:58 +0100 Subject: [PATCH] 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 () {