]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: more robust symlinks usage
authorKarel Zak <kzak@redhat.com>
Mon, 30 Jul 2012 15:10:38 +0000 (17:10 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 30 Jul 2012 15:10:38 +0000 (17:10 +0200)
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh

index a3bb482d8f8274032f4a4b5c56868a0a68e3470d..eee6be35220606e849431719689140a93b5107a1 100644 (file)
@@ -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