From 6dfe6f0e829912e3dfca87d69f1211c0b4f5a900 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 30 Jul 2012 17:10:38 +0200 Subject: tests: more robust symlinks usage Reported-by: Bernhard Voelker Signed-off-by: Karel Zak --- tests/functions.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index a3bb482d8..eee6be352 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -20,6 +20,17 @@ function ts_abspath { pwd } +function ts_canonicalize { + P="$1" + C=$(readlink -f $P) + + if [ -n "$C" ]; then + echo "$C" + else + echo "$P" + fi +} + function ts_skip_subtest { echo " IGNORE ($1)" } @@ -107,6 +118,8 @@ function ts_init_env { LC_ALL="POSIX" CHARSET="UTF-8" + mydir=$(ts_canonicalize "$mydir") + export LANG LANGUAGE LC_ALL CHARSET TS_TOPDIR=$(ts_abspath $mydir/../../) @@ -377,7 +390,7 @@ function ts_device_has_uuid { } function ts_is_mounted { - local DEV=$( readlink -f $1 ) + local DEV=$(ts_canonicalize "$1") if [ ".$DEV" = '.' ]; then DEV=$1 fi -- cgit v1.2.3-55-g7522