]> err.no Git - util-linux/commitdiff
tests: "if [...]" clean up
authorKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 13:00:22 +0000 (15:00 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 13:00:22 +0000 (15:00 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/ts-col-multibyte
tests/ts-cramfs-mkfs
tests/ts-hwclock-systohc
tests/ts-ipcs-headers
tests/ts-login-checktty
tests/ts-look-separator
tests/ts-mount-move
tests/ts-mount-special

index 125e396c77bd6831d2d46a5bc50c94135e918fb4..c1affe48e72eacc051db38f42d776dbca947d20f 100755 (executable)
@@ -10,8 +10,5 @@ ts_init
 
 cat $TS_INPUT | $TS_CMD_COL > /dev/null  2> $TS_OUTPUT
 
-
-
-
 ts_finalize
 
index b2c43e62d2184ce60b364c9736351ae30a67d403..d183f472f4d27c3fdae1bbbfd465651c96bdc1d0 100755 (executable)
@@ -28,8 +28,6 @@ ts_skip_nonroot
 
 set -o pipefail
 
-touch $TS_OUTPUT
-
 IMAGE="$TS_OUTDIR/cramfs-loop.img"
 IMAGE_DATA="$TS_OUTDIR/cramfs-data"
 IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
@@ -37,9 +35,7 @@ LABEL="testCramfs"
 MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
 
 echo "create mountpoint dir" >> $TS_OUTPUT
-if [ ! -d "$MOUNTPOINT" ]; then
-       mkdir -p $MOUNTPOINT
-fi
+[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT
 
 echo "generate data" >> $TS_OUTPUT
 if [ ! -d "$IMAGE_DATA" ]; then
index 43d663203a8b13442d50f58d3037e642568074c3..743eea69148419325ad1272b1e9f90cf2800fb13 100755 (executable)
@@ -28,29 +28,20 @@ NTP_SERVER="0.fedora.pool.ntp.org"
 ts_init
 ts_skip_nonroot
 
-if [ -x "ntpdate" ]; then
-       ts_skip "cannot found ntpdate command"
-fi
+[ -x "/usr/sbin/ntpdate" ] || ts_skip "cannot found ntpdate command"
 
 set -o pipefail
 
 # sync with server
 (ntpdate $NTP_SERVER | sed "s/^.*offset \([0-9.]*\) sec/\1/g") &> /dev/null
-
-if [ "$?" == "1" ]; then
-       ts_skip "cannot sync with $NTP_SERVER"
-fi
+[ "$?" == "1" ] && ts_skip "cannot sync with $NTP_SERVER"
 
 # sync again and check difference
 OFFSET=$( ntpdate $NTP_SERVER 2> /dev/null | sed "s/^.*offset [\-]*\([0-9.]*\) sec/\1/g" )
-if [ "$?" == "1" ]; then
-       ts_skip "cannot sync with $NTP_SERVER (2nd attempt)"
-fi
+[ "$?" == "1" ] && ts_skip "cannot sync with $NTP_SERVER (2nd attempt)"
 
 DIFF=$( echo "$OFFSET > 1" | bc )
-if [ "$DIFF" == "1" ]; then
-       ts_skip "diff between systime and NTP is greated than 1 second"
-fi
+[ "$DIFF" == "1" ] && ts_skip "diff between systime and NTP is greated than 1 second"
 
 # call hwclock
 for i in `seq 0 10`; do
@@ -61,14 +52,10 @@ done
 
 # sync with NTP and check new difference
 OFFSET=$( ntpdate $NTP_SERVER 2> /dev/null | sed "s/^.*offset [\-]*\([0-9.]*\) sec/\1/g" )
-if [ "$?" == "1" ]; then
-       ts_skip "cannot sync with $NTP_SERVER (3rd attempt)"
-fi
+[ "$?" == "1" ] && ts_skip "cannot sync with $NTP_SERVER (3rd attempt)"
 
 DIFF=$( echo "$OFFSET > 1" | bc )
-if [ "$DIFF" == "1" ]; then
-       ts_failed "offset is $OFFSET"
-fi
+[ "$DIFF" == "1" ] && ts_failed "offset is $OFFSET"
 
 ts_ok "offset is $OFFSET"
 
index 62b1856a6c6a21f9f1526de767decc20fd963887..c0f1e147adb67e000e3a7a7ae2016569d240506e 100755 (executable)
@@ -8,8 +8,6 @@ TS_DESC="headers"
 
 ts_init
 
-touch $TS_OUTPUT
-
 echo "test: shm headers" >> $TS_OUTPUT
 $TS_CMD_IPCS -m -t | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -m -p | grep --after-context=1 "^---"  >> $TS_OUTPUT
index f51ab0fa391d0721879c0aa3fe067cdda6ee06fa..d0509b0508232c3f0f37d9d55a74825edae2b7f7 100755 (executable)
@@ -7,10 +7,6 @@ TS_COMPONENT="login"
 TS_DESC="checktty"
 
 ts_init
-
-touch $TS_OUTPUT
-
 $TS_CMD_CHECKTTY  >> $TS_OUTPUT
-
 ts_finalize
 
index e7772bb454e44e681a727154529757ec4c30d65e..fe86e2ca0d41fa936176b772f83f63b5c31107ed 100755 (executable)
@@ -20,13 +20,8 @@ TS_DESC="separator"
 
 ts_init
 
-if [ ! -f "/usr/share/dict/words" ]; then
-       ts_skip "/usr/share/dict/words not such file" 
-fi
-
-touch $TS_OUTPUT
+[ -f "/usr/share/dict/words" ] || ts_skip "/usr/share/dict/words not such file"
 
 $TS_CMD_LOOK apple-pie >> $TS_OUTPUT
-
 ts_finalize
 
index 76400b4493f300f88cd82719d8da34632764204b..88458110a0546e341f1fe9830e0054b8731b7924 100755 (executable)
@@ -13,39 +13,31 @@ TS_DESC="move "
 ts_init
 ts_skip_nonroot
 
-touch $TS_OUTPUT
-
 PWD=$(pwd)
 
 DIR_SRC="$PWD/$TS_OUTDIR/mnt-move-src"
 DIR_A="$PWD/$TS_OUTDIR/mnt-move-A"
 DIR_B="$PWD/$TS_OUTDIR/mnt-move-B"
 
-mkdir $DIR_SRC $DIR_A $DIR_B
+[ -d $DIR_SRC ] || mkdir $DIR_SRC
+[ -d $DIR_A ] || mkdir $DIR_A
+[ -d $DIR_B ] || mkdir $DIR_B
 
 # bind
 $TS_CMD_MOUNT --bind $DIR_SRC $DIR_A
 
 # check the bind
 egrep -q "^$DIR_SRC $DIR_A" /etc/mtab
-
-if [ "$?" != "0" ]; then
-        echo "Cannot found binded $DIR_SRC in /etc/mtab" >> $TS_OUTPUT
-       rmdir $DIR_SRC $DIR_A $DIR_B
-        ts_finalize
-fi
+[ "$?" == "0" ] || ts_die "Cannot found binded $DIR_SRC in /etc/mtab"
 
 # move
 $TS_CMD_MOUNT --move $DIR_A $DIR_B
 
 # check the move
 egrep -q "^$DIR_SRC $DIR_B" /etc/mtab
-
 if [ "$?" != "0" ]; then
-        echo "Cannot found moved $DIR_SRC in /etc/mtab" >> $TS_OUTPUT
        $TS_CMD_UMOUNT $DIR_SRC
-       rmdir $DIR_SRC $DIR_A $DIR_B
-        ts_finalize
+       ts_die "Cannot found moved $DIR_SRC in /etc/mtab"
 fi
 
 # clean up
@@ -53,6 +45,5 @@ $TS_CMD_UMOUNT $DIR_SRC
 rmdir $DIR_SRC $DIR_A $DIR_B
 
 echo "Success" >> $TS_OUTPUT
-
 ts_finalize
 
index 3fb193eab958b803aaf444f93b380defc7db6c4f..4d29167c2c0aa86d062265d29b4f43a330b52ab0 100755 (executable)
@@ -15,8 +15,6 @@ MOUNTER="/sbin/mount.mytest"
 ts_init
 ts_skip_nonroot
 
-touch $TS_OUTPUT
-
 cat > $MOUNTER << EOF
 #!/bin/bash 
 # This util-linux-ng regression test component