From 8da0e9eef7c824853646a519b3c467cce4ba2026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 23 Oct 2024 09:42:47 +0200 Subject: [PATCH] all.sh: rationalize relative path usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation for adding tf-psa-crypto/test/scripts/all.sh which will run from tf-psa-crypto. Use paths relative to the currently sourced file when including common files (ie, those that will soon be moved to the framework). Otherwise, use paths relative to the current directory, aka project's root. Document that test/script/all.sh must be invoked from the project's root (that was already the case, but implicit so far). Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all-core.sh | 11 ++++++----- tests/scripts/all.sh | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/scripts/all-core.sh b/tests/scripts/all-core.sh index ccd7e59ea..cfb2d8c6a 100644 --- a/tests/scripts/all-core.sh +++ b/tests/scripts/all-core.sh @@ -156,8 +156,8 @@ pre_check_environment () { # Must be called before pre_initialize_variables which sets ALL_COMPONENTS. pre_load_components () { # Include the components from components.sh - test_script_dir="${0%/*}" - for file in "$test_script_dir"/components-*.sh; do + # Use a path relative to the current directory, aka project's root. + for file in tests/scripts/components-*.sh; do source $file done } @@ -864,7 +864,8 @@ pre_check_tools () { set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; *) set "$@" RUN_ARMCC=0;; esac - "$@" scripts/output_env.sh + # Use a path relative to the currently-sourced file. + "$@" "${BASH_SOURCE%/*}"/../../scripts/output_env.sh } pre_generate_files() { @@ -879,8 +880,8 @@ pre_generate_files() { } pre_load_helpers () { - # The path is going to change when this is moved to the framework - test_script_dir="${0%/*}" + # Use a path relative to the currently-sourced file. + test_script_dir="${BASH_SOURCE%/*}" source "$test_script_dir"/all-helpers.sh } diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6708de102..a73c090df 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -8,8 +8,9 @@ # This file is executable; it is the entry point for users and the CI. # See "Files structure" in all-core.sh for other files used. +# This script must be invoked from the project's root. + # The path is going to change when this is moved to the framework -test_script_dir="${0%/*}" -source "$test_script_dir"/all-core.sh +source tests/scripts/all-core.sh main "$@"