]> err.no Git - util-linux/commitdiff
tests: fix TS_* paths
authorKarel Zak <kzak@redhat.com>
Mon, 19 Jan 2009 21:36:27 +0000 (22:36 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:30:14 +0000 (23:30 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/commands.sh.in
tests/functions.sh
tests/run.sh

index 58401cabe266aaaab5ed66b0c3716179013f37b2..4e95d68509ca22c189c96108a228d3b2468e7240 100644 (file)
@@ -1,7 +1,4 @@
-TOPDIR=@top_srcdir@
-TS_TOPDIR=$TOPDIR/tests
-
-AWK=@AWK@
+TOPDIR="$TS_TOPDIR/.."
 
 # Misc settings
 TS_TESTUSER=${TS_TESTUSER:-"test"}
index ecb205b13b6434277f69ef2284b0efab944970f3..f24984e3f9fa6843ce59518acbe84f1aa762fc91 100644 (file)
 # GNU General Public License for more details.
 #
 
-TS_OUTDIR="output"
-TS_DIFFDIR="diff"
-TS_EXPECTEDDIR="expected"
-TS_INPUTDIR="input"
-TS_VERBOSE="no"
 
-. ./commands.sh
+function ts_abspath {
+       cd $1
+       pwd
+}
 
 function ts_skip {
        echo " IGNORE ($1)"
@@ -62,18 +60,17 @@ function ts_log {
 function ts_has_option {
        NAME="$1"
        ALL="$2"
-       echo -n $ALL | sed 's/ //g' | $AWK 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }'
+       echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }'
 }
 
 function ts_init {
-       local is_fake
-
-       export LANG="en_US.UTF-8":
+       local is_fake=$( ts_has_option "fake" "$*")
+       local mydir=$(ts_abspath $(dirname $0))
 
-       TS_VERBOSE=$( ts_has_option "verbose" "$*")
-       is_fake=$( ts_has_option "fake" "$*")
+       export LANG="en_US.UTF-8"
 
-       TS_SCRIPT="$0"
+       TS_TOPDIR=$(ts_abspath $mydir/../../)
+       TS_SCRIPT="$mydir/$(basename $0)"
        TS_SUBDIR=$(dirname $TS_SCRIPT)
        TS_TESTNAME=$(basename $TS_SCRIPT)
        TS_COMPONENT=$(basename $TS_SUBDIR)
@@ -81,11 +78,12 @@ function ts_init {
        TS_NS="$TS_COMPONENT/$TS_TESTNAME"
        TS_SELF="$TS_SUBDIR"
 
-       TS_OUTPUT="$TS_OUTDIR/$TS_NS"
-       TS_DIFF="$TS_DIFFDIR/$TS_NS"
-       TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NS"
-       TS_MOUNTPOINT="$(pwd)/$TS_OUTDIR/${TS_NS}_mnt"
+       TS_OUTPUT="$TS_TOPDIR/output/$TS_NS"
+       TS_DIFF="$TS_TOPDIR/diff/$TS_NS"
+       TS_EXPECTED="$TS_TOPDIR/expected/$TS_NS"
+       TS_MOUNTPOINT="$TS_OUTPUT/${TS_NS}_mnt"
 
+       TS_VERBOSE=$( ts_has_option "verbose" "$*")
        TS_HAS_VOLUMEID="no"
 
        BLKID_FILE="$TS_OUTDIR/${TS_NS}.blkidtab"
@@ -97,13 +95,13 @@ function ts_init {
        declare -a TS_SUID_USER
        declare -a TS_SUID_GROUP
 
+       . $TS_TOPDIR/commands.sh
+
        export BLKID_FILE
 
        if [ -x $TS_CMD_MOUNT ]; then
                ldd $TS_CMD_MOUNT | grep -q 'libvolume_id' &> /dev/null
-               if [ "$?" == "0" ]; then
-                       TS_HAS_VOLUMEID="yes"
-               fi
+               [ "$?" == "0" ] && TS_HAS_VOLUMEID="yes"
        fi
 
        rm -f $TS_OUTPUT
@@ -114,8 +112,8 @@ function ts_init {
        if [ "$TS_VERBOSE" == "yes" ]; then
                echo
                echo "     script: $TS_SCRIPT"
-               echo "    top dir: $TS_TOPDIR"
                echo "    sub dir: $TS_SUBDIR"
+               echo "    top dir: $TS_TOPDIR"
                echo "       self: $TS_SELF"
                echo "  test name: $TS_TESTNAME"
                echo "  test desc: $TS_DESC"
@@ -129,7 +127,6 @@ function ts_init {
        fi
 
        [ "$is_fake" == "yes" ] && ts_skip "fake mode"
-
 }
 
 function ts_init_suid {
index 8a2c7f245fbc2e53dc56bdb440f4598db31dee55..f4a6e7bfe9c024524c9e89b22a8bb3eda2cd7323 100755 (executable)
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
-. functions.sh
 
-comps=$(find ts/ -type f -perm /a+x -regex "[^\.~]*" |  sort)
+TS_TOPDIR=$(cd $(dirname $0) && pwd)
+comps=$(find $TS_TOPDIR/ts/ -type f -perm /a+x -regex "[^\.~]*" |  sort)
 
 if [ -n "$1" ]; then
-       if [ -d "ts/$1" ]; then
-               comps=$(find ts/$1 -type f -perm /a+x -regex "[^\.~]*" |  sort)
+       if [ -d "$TS_TOPDIR/ts/$1" ]; then
+               comps=$(find $TS_TOPDIR/ts/$1 -type f -perm /a+x -regex "[^\.~]*" |  sort)
        else
                echo
                echo "usage: $0 [<component>]"
@@ -44,7 +44,7 @@ echo
 res=0
 count=0
 for ts in $comps; do
-       ./$ts "$1"
+       $ts "$1"
        res=$(( $res + $? ))
        count=$(( $count + 1 ))
 done