Skip to content

Commit 936598d

Browse files
aescolarnashif
authored andcommitted
tests/bsim/common sh: Improve getting test name/relative path
Improve function which guesses the test name so the calling script can be invoked from any folder, not just Zephyr's base. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
1 parent cb7aae6 commit 936598d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/bsim/sh_common.source

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,21 @@ function Execute() {
5050
}
5151

5252
function _guess_test_relpath(){
53-
local PA="$(realpath --relative-to "${ZEPHYR_BASE}" $(dirname "${BASH_SOURCE[2]}"))"
53+
local PA="$(cd -- "$(dirname "${BASH_SOURCE[2]}")" && pwd)"
54+
PA="$(realpath --relative-to "${ZEPHYR_BASE}" "${PA}")"
5455
echo $PA | sed -E 's/\/tests?_scripts//'
5556
}
5657

5758
# For a caller running from a tests_script/ folder, get the path of its parent
5859
# relative to $ZEPHYR_BASE
60+
# This must be run without/before cd'ing into another directory
5961
function guess_test_relpath(){
6062
echo $(_guess_test_relpath)
6163
}
6264

6365
# For a caller running from a tests_script/ folder, get the path of its parent
6466
# relative to $ZEPHYR_BASE, replacing "/" with "_"
67+
# This must be run without/before cd'ing into another directory
6568
function guess_test_long_name(){
6669
echo $(_guess_test_relpath) | tr / _
6770
}

0 commit comments

Comments
 (0)