From: Karel Zak Date: Fri, 18 May 2007 13:00:22 +0000 (+0200) Subject: tests: "if [...]" clean up X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaf2f7233c19fa6efdf9bbb4901847e1bb4dd4d6;p=util-linux tests: "if [...]" clean up Signed-off-by: Karel Zak --- diff --git a/tests/ts-col-multibyte b/tests/ts-col-multibyte index 125e396c..c1affe48 100755 --- a/tests/ts-col-multibyte +++ b/tests/ts-col-multibyte @@ -10,8 +10,5 @@ ts_init cat $TS_INPUT | $TS_CMD_COL > /dev/null 2> $TS_OUTPUT - - - ts_finalize diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs index b2c43e62..d183f472 100755 --- a/tests/ts-cramfs-mkfs +++ b/tests/ts-cramfs-mkfs @@ -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 diff --git a/tests/ts-hwclock-systohc b/tests/ts-hwclock-systohc index 43d66320..743eea69 100755 --- a/tests/ts-hwclock-systohc +++ b/tests/ts-hwclock-systohc @@ -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" diff --git a/tests/ts-ipcs-headers b/tests/ts-ipcs-headers index 62b1856a..c0f1e147 100755 --- a/tests/ts-ipcs-headers +++ b/tests/ts-ipcs-headers @@ -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 diff --git a/tests/ts-login-checktty b/tests/ts-login-checktty index f51ab0fa..d0509b05 100755 --- a/tests/ts-login-checktty +++ b/tests/ts-login-checktty @@ -7,10 +7,6 @@ TS_COMPONENT="login" TS_DESC="checktty" ts_init - -touch $TS_OUTPUT - $TS_CMD_CHECKTTY >> $TS_OUTPUT - ts_finalize diff --git a/tests/ts-look-separator b/tests/ts-look-separator index e7772bb4..fe86e2ca 100755 --- a/tests/ts-look-separator +++ b/tests/ts-look-separator @@ -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 diff --git a/tests/ts-mount-move b/tests/ts-mount-move index 76400b44..88458110 100755 --- a/tests/ts-mount-move +++ b/tests/ts-mount-move @@ -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 diff --git a/tests/ts-mount-special b/tests/ts-mount-special index 3fb193ea..4d29167c 100755 --- a/tests/ts-mount-special +++ b/tests/ts-mount-special @@ -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