From: Karel Zak Date: Mon, 19 Jan 2009 21:36:27 +0000 (+0100) Subject: tests: fix TS_* paths X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a02f320d4bf6a09d1c3b904db01a4188bbaee562;p=util-linux tests: fix TS_* paths Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh.in b/tests/commands.sh.in index 58401cab..4e95d685 100644 --- a/tests/commands.sh.in +++ b/tests/commands.sh.in @@ -1,7 +1,4 @@ -TOPDIR=@top_srcdir@ -TS_TOPDIR=$TOPDIR/tests - -AWK=@AWK@ +TOPDIR="$TS_TOPDIR/.." # Misc settings TS_TESTUSER=${TS_TESTUSER:-"test"} diff --git a/tests/functions.sh b/tests/functions.sh index ecb205b1..f24984e3 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -14,13 +14,11 @@ # 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 { diff --git a/tests/run.sh b/tests/run.sh index 8a2c7f24..f4a6e7bf 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -15,13 +15,13 @@ # 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 []" @@ -44,7 +44,7 @@ echo res=0 count=0 for ts in $comps; do - ./$ts "$1" + $ts "$1" res=$(( $res + $? )) count=$(( $count + 1 )) done