]> err.no Git - util-linux/commitdiff
tests: add support for subdirs to basic test functions
authorKarel Zak <kzak@redhat.com>
Mon, 19 Jan 2009 17:08:06 +0000 (18:08 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:27:55 +0000 (23:27 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh
tests/run.sh
tests/ts/col/multibyte
tests/ts/ipcs/functions.sh [moved from tests/ts/ipcs/function.sh with 100% similarity]
tests/ts/ipcs/limits
tests/ts/ipcs/limits2
tests/ts/login/islocal
tests/ts/mount/fstab-symlink
tests/ts/script/race

index 371deb6aff9da9f9e6ac8eb4a9f28a84e5f5cb90..ecb205b13b6434277f69ef2284b0efab944970f3 100644 (file)
@@ -20,6 +20,8 @@ TS_EXPECTEDDIR="expected"
 TS_INPUTDIR="input"
 TS_VERBOSE="no"
 
+. ./commands.sh
+
 function ts_skip {
        echo " IGNORE ($1)"
        if [ -n "$2" -a -b "$2" ]; then
@@ -36,7 +38,7 @@ function ts_skip_nonroot {
 
 function ts_failed {
        if [ x"$1" == x"" ]; then
-               echo " FAILED ($TS_NAME)"
+               echo " FAILED ($TS_NS)"
        else
                echo " FAILED ($1)"
        fi
@@ -64,28 +66,37 @@ function ts_has_option {
 }
 
 function ts_init {
+       local is_fake
+
        export LANG="en_US.UTF-8":
-       TS_NAME=$(basename $0)
-       if [ ! -d $TS_OUTDIR ]; then
-               mkdir -p $TS_OUTDIR
-       fi
-       if [ ! -d $TS_DIFFDIR ]; then
-               mkdir -p $TS_DIFFDIR
-       fi
+
+       TS_VERBOSE=$( ts_has_option "verbose" "$*")
+       is_fake=$( ts_has_option "fake" "$*")
+
+       TS_SCRIPT="$0"
+       TS_SUBDIR=$(dirname $TS_SCRIPT)
+       TS_TESTNAME=$(basename $TS_SCRIPT)
+       TS_COMPONENT=$(basename $TS_SUBDIR)
+
+       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_HAS_VOLUMEID="no"
+
+       BLKID_FILE="$TS_OUTDIR/${TS_NS}.blkidtab"
+
+       [ ! -d "$(dirname $TS_OUTPUT)" ] && mkdir -p $(dirname $TS_OUTPUT)
+       [ ! -d "$(dirname $TS_DIFF)" ] && mkdir -p $(dirname $TS_DIFF)
 
        declare -a TS_SUID_PROGS
        declare -a TS_SUID_USER
        declare -a TS_SUID_GROUP
 
-       TS_VERBOSE=$( ts_has_option "verbose" "$*")
-       TS_OUTPUT="$TS_OUTDIR/$TS_NAME"
-       TS_DIFF="$TS_DIFFDIR/$TS_NAME"
-       TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME"
-       TS_INPUT="$TS_INPUTDIR/$TS_NAME"
-       TS_MOUNTPOINT="$(pwd)/$TS_OUTDIR/${TS_NAME}_mnt"
-       TS_HAS_VOLUMEID="no"
-       BLKID_FILE="$TS_OUTDIR/$TS_NAME.blkidtab"
-
        export BLKID_FILE
 
        if [ -x $TS_CMD_MOUNT ]; then
@@ -99,6 +110,26 @@ function ts_init {
        touch $TS_OUTPUT
 
        printf "%15s: %-25s ..." "$TS_COMPONENT" "$TS_DESC"
+
+       if [ "$TS_VERBOSE" == "yes" ]; then
+               echo
+               echo "     script: $TS_SCRIPT"
+               echo "    top dir: $TS_TOPDIR"
+               echo "    sub dir: $TS_SUBDIR"
+               echo "       self: $TS_SELF"
+               echo "  test name: $TS_TESTNAME"
+               echo "  test desc: $TS_DESC"
+               echo "  component: $TS_COMPONENT"
+               echo "  namespace: $TS_NS"
+               echo "    verbose: $TS_VERBOSE"
+               echo "     output: $TS_OUTPUT"
+               echo "   expected: $TS_EXPECTED"
+               echo " mountpoint: $TS_MOUNTPOINT"
+               echo
+       fi
+
+       [ "$is_fake" == "yes" ] && ts_skip "fake mode"
+
 }
 
 function ts_init_suid {
@@ -153,7 +184,7 @@ function ts_die {
 }
 
 function ts_device_init {
-       local IMAGE="$TS_OUTDIR/$TS_NAME.img"
+       local IMAGE="$TS_OUTDIR/${TS_NS}.img"
        local DEV=""
 
        dd if=/dev/zero of="$IMAGE" bs=1M count=5 &> /dev/null
index 7b662390efd692cba169dbd372d365563f0da3d6..cef1371606579a87e72fd54af9d8df7b00708708 100755 (executable)
@@ -15,7 +15,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
-. ./commands.sh
+. functions.sh
 
 echo
 echo "------------------ Utils-linux-ng regression tests ------------------"
@@ -24,12 +24,10 @@ echo "                    For development purpose only.                    "
 echo "                 Don't execute on production system!                 "
 echo
 
-rm -f *~
-
 res=0
 count=0
-for ts in $(find -maxdepth 1 -regex "\./ts[^\.~]*" |  sort); do
-       $TS_TOPDIR/$ts "$1"
+for ts in $(find ts/ -type f -perm /a+x -regex "[^\.~]*" |  sort); do
+       ./$ts "$1"
        res=$(( $res + $? ))
        count=$(( $count + 1 ))
 done
index 357d7f1504c689ff4533a9fa072ca37f653d51f7..b030beadf98ec63381af842c8de11820d8fa9aa4 100755 (executable)
@@ -23,7 +23,7 @@ TS_DESC="multibyte"
 
 ts_init "$*"
 
-cat $TS_INPUT | $TS_CMD_COL > /dev/null  2> $TS_OUTPUT
+cat $TS_SELF/multibyte.data | $TS_CMD_COL > /dev/null  2> $TS_OUTPUT
 
 ts_finalize
 
index 6224ac4406396681959f69e5da1a2efb17bc2b80..0fb316064765d9b03211cac3f7eae01c4a6eecc8 100755 (executable)
 TS_COMPONENT="ipcs"
 TS_DESC="limits overflow"
 
-. ./ts-ipcs.sh
-
 ts_init "$*"
 ts_skip_nonroot
+. $TS_SELF/functions.sh
 
 ts_log "load original values"
 for i in $IPCS_IDX; do
index f539e8a6e9afcb94fbe3175ac3bcbd1724707484..17c3c702f049bc08d3ecc334d731b1468697790d 100755 (executable)
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
-. ./commands.sh
-. ./functions.sh
 
-TS_COMPONENT="ipcs"
 TS_DESC="basic limits"
 
-. ./ts-ipcs.sh
-
+. ./functions.sh
 ts_init "$*"
 
+. $TS_SELF/functions.sh
+
 ts_log "check for difference between kernel and IPC"
 ipcs_limits_check >> $TS_OUTPUT
 
index 0c8d779853dada46c1ea99d50c6403b586e988cc..acffb07735c3b13216aefebf6738bea595d6f611 100755 (executable)
@@ -22,7 +22,7 @@ TS_COMPONENT="login"
 TS_DESC="islocal"
 
 ts_init "$*"
-$TS_CMD_ISLOCAL "$TS_INPUT" root nobody "" youngman youngman2 \
+$TS_CMD_ISLOCAL "$TS_SELF/islocal.data" root nobody "" youngman youngman2 \
     abcdefghx nobo long rot al malformed \
     nonl znobody >> $TS_OUTPUT
 ts_finalize
index 336ecdba6344b1555ad961e209f5937bf25d96dd..f567e8fdbe085c21877a9e734628d736356586b3 100755 (executable)
@@ -26,7 +26,7 @@ ts_skip_nonroot
 
 set -o pipefail
 
-LINKNAME="$(pwd)/$TS_OUTDIR/${TS_NAME}_lnk"
+LINKNAME="$(pwd)/$TS_OUTDIR/${TS_NS}_lnk"
 
 DEVICE=$(ts_device_init)
 [ "$?" == 0 ] || ts_die "Cannot init device"
index 818d0c5e048219bf48b91de5dd81dc14481c7acc..d450ec5dd9af2c990786b516a2562ac7cabc3803 100755 (executable)
@@ -23,7 +23,7 @@ TS_DESC="race conditions"
 
 ts_init "$*"
 
-bingofile="$TS_OUTDIR/$TS_NAME-bingo"
+bingofile="$TS_OUTDIR/${TS_NS}-bingo"
 
 set -o pipefail