summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2012-07-30 17:10:38 +0200
committerKarel Zak2012-07-30 17:10:38 +0200
commit6dfe6f0e829912e3dfca87d69f1211c0b4f5a900 (patch)
tree79d664ea7cd1a2954507863b2c3cc71650a6818b /tests/functions.sh
parenttests: use ts_is_mounted in mount/regfile (diff)
downloadkernel-qcow2-util-linux-6dfe6f0e829912e3dfca87d69f1211c0b4f5a900.tar.gz
kernel-qcow2-util-linux-6dfe6f0e829912e3dfca87d69f1211c0b4f5a900.tar.xz
kernel-qcow2-util-linux-6dfe6f0e829912e3dfca87d69f1211c0b4f5a900.zip
tests: more robust symlinks usage
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh15
1 files changed, 14 insertions, 1 deletions
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