]> err.no Git - util-linux/commitdiff
tests: add ts_log and --verbose support
authorKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 13:34:28 +0000 (15:34 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 13:34:28 +0000 (15:34 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
21 files changed:
tests/README
tests/functions.sh
tests/run.sh
tests/ts-col-multibyte
tests/ts-cramfs-mkfs
tests/ts-hwclock-systohc
tests/ts-ipcs-headers
tests/ts-ipcs-limits
tests/ts-ipcs-limits2
tests/ts-ipcs.sh
tests/ts-login-checktty
tests/ts-look-separator
tests/ts-mount-move
tests/ts-mount-mtablock
tests/ts-mount-paths
tests/ts-mount-remount
tests/ts-mount-special
tests/ts-namei-logic
tests/ts-swapon-devname
tests/ts-swapon-label
tests/ts-swapon-uuid

index bcade3d7af0c000d8833971d93edfcd546e87b17..8eca0854441b865a6cc12ac1816be95d61bde606 100644 (file)
@@ -8,9 +8,9 @@
 
  Run all tests:
 
-       ./run.sh
+       ./run.sh [--verbose]
 
  Run one tests:
 
-       ./ts-<component_name>-<test_name>.sh
+       ./ts-<component_name>-<test_name>.sh [--verbose]
 
index 001c39f96bb6904bf5fa967c6b998efc8c7a9675..24308f696fa1c80b6dcf0703940d9b37259038ee 100644 (file)
@@ -3,6 +3,7 @@ TS_OUTDIR="output"
 TS_DIFFDIR="diff"
 TS_EXPECTEDDIR="expected"
 TS_INPUTDIR="input"
+TS_VERBOSE="no"
 
 function ts_skip {
        echo " IGNORE ($1)"
@@ -36,6 +37,11 @@ function ts_ok {
        exit 0
 }
 
+function ts_log {
+       echo "$1" >> $TS_OUTPUT
+       [ "$TS_VERBOSE" == "yes" ] && echo "$1"
+}
+
 function ts_init {
        export LANG="en_US.UTF-8":
        TS_NAME=$(basename $0)
@@ -45,6 +51,7 @@ function ts_init {
        if [ ! -d $TS_DIFFDIR ]; then
                mkdir -p $TS_DIFFDIR
        fi
+       [ "$1" == "--verbose" ] && TS_VERBOSE="yes"
        TS_OUTPUT="$TS_OUTDIR/$TS_NAME"
        TS_DIFF="$TS_DIFFDIR/$TS_NAME"
        TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME"
@@ -80,7 +87,7 @@ function ts_finalize {
 }
 
 function ts_die {
-       echo "$1" >> $TS_OUTPUT
+       ts_log "$1"
        if [ -n "$2" ] && [ -b "$2" ]; then
                ts_device_deinit "$2"
        fi
index 4a475d826512d0181c502ba719c101d79953e445..51b7f738376a62292df29c187da4cc0b6546e19a 100755 (executable)
@@ -11,7 +11,7 @@ rm -f *~
 res=0
 count=0
 for ts in $(find -maxdepth 1 -regex "\./ts[^\.~]*" |  sort); do
-       $TS_TOPDIR/$ts
+       $TS_TOPDIR/$ts "$1"
        res=$(( $res + $? ))
        count=$(( $count + 1 ))
 done
index c1affe48e72eacc051db38f42d776dbca947d20f..00ebb2b3af644e54bd07898dd83f283beeccd413 100755 (executable)
@@ -6,7 +6,7 @@
 TS_COMPONENT="col"
 TS_DESC="multibyte"
 
-ts_init
+ts_init "$1"
 
 cat $TS_INPUT | $TS_CMD_COL > /dev/null  2> $TS_OUTPUT
 
index d183f472f4d27c3fdae1bbbfd465651c96bdc1d0..cbe37292e8cd74cafc61df1f62f61c0d2227a2ae 100755 (executable)
@@ -23,7 +23,7 @@
 TS_COMPONENT="mkfs.cramfs"
 TS_DESC="mkfs"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 set -o pipefail
@@ -34,10 +34,10 @@ IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
 LABEL="testCramfs"
 MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
 
-echo "create mountpoint dir" >> $TS_OUTPUT
+ts_log "create mountpoint dir"
 [ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT
 
-echo "generate data" >> $TS_OUTPUT
+ts_log "generate data"
 if [ ! -d "$IMAGE_DATA" ]; then
        mkdir -p $IMAGE_DATA
        for d in `seq 0 110`; do
@@ -50,45 +50,45 @@ if [ ! -d "$IMAGE_DATA" ]; then
        done
 fi
 
-echo "list checksums from original data" >> $TS_OUTPUT
+ts_log "list checksums from original data"
 find $IMAGE_DATA -type f -exec md5sum {} \; >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "create cramfs image" >> $TS_OUTPUT
+ts_log "create cramfs image"
 $TS_CMD_MKCRAMFS -n $LABEL $IMAGE_DATA $IMAGE 2>&1 >> $TS_OUTPUT
 [ -s "$IMAGE" ] || ts_die "Cannot create $IMAGE"
 
-echo "count MD5 from the image" >> $TS_OUTPUT
+ts_log "count MD5 from the image"
 md5sum $IMAGE 2>&1 >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "create loop device from image" >> $TS_OUTPUT
+ts_log "create loop device from image"
 DEVICE=$( $TS_CMD_LOSETUP -f )
 $TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
 
-echo "check the image" >> $TS_OUTPUT
+ts_log "check the image"
 ts_device_has "TYPE" "cramfs" $DEVICE
 [  "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
 
 ts_udev_dev_support "by-label" $LABEL
 [ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
 
-echo "mount the image" >> $TS_OUTPUT
+ts_log "mount the image"
 $TS_CMD_MOUNT -L $LABEL $MOUNTPOINT 2>&1 >> $TS_OUTPUT
 
 # check it
 grep -q $DEVICE /proc/mounts
 [ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
 
-echo "list the image" >> $TS_OUTPUT
+ts_log "list the image"
 ls -laR $MOUNTPOINT >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "list checksums from new data" >> $TS_OUTPUT
+ts_log "list checksums from new data"
 find $MOUNTPOINT -type f -exec md5sum {} \; >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "umount the image" >> $TS_OUTPUT
+ts_log "umount the image"
 $TS_CMD_UMOUNT $DEVICE
 $TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
 ts_finalize
index 743eea69148419325ad1272b1e9f90cf2800fb13..2bbe9ce1c0ee29aadc3b7fd34029ddbc60a40fe5 100755 (executable)
@@ -25,7 +25,7 @@ TS_DESC="systohc"
 
 NTP_SERVER="0.fedora.pool.ntp.org"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 [ -x "/usr/sbin/ntpdate" ] || ts_skip "cannot found ntpdate command"
index c0f1e147adb67e000e3a7a7ae2016569d240506e..b8728d6c9c9d8f4f399f99426a2970b3558643bc 100755 (executable)
@@ -6,9 +6,9 @@
 TS_COMPONENT="ipcs"
 TS_DESC="headers"
 
-ts_init
+ts_init "$1"
 
-echo "test: shm headers" >> $TS_OUTPUT
+ts_log "test: shm headers"
 $TS_CMD_IPCS -m -t | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -m -p | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -m -c | grep --after-context=1 "^---"  >> $TS_OUTPUT
@@ -16,7 +16,7 @@ $TS_CMD_IPCS -m -l | grep "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -m -u | grep "^---"  >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "test: mesg headers" >> $TS_OUTPUT
+ts_log "test: mesg headers"
 $TS_CMD_IPCS -q -t | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -q -p | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -q -c | grep --after-context=1 "^---"  >> $TS_OUTPUT
@@ -24,7 +24,7 @@ $TS_CMD_IPCS -q -l | grep  "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -q -u | grep  "^---"  >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "test: sem headers" >> $TS_OUTPUT
+ts_log "test: sem headers"
 $TS_CMD_IPCS -s -t | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -s -p | grep --after-context=1 "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -s -c | grep --after-context=1 "^---"  >> $TS_OUTPUT
@@ -32,7 +32,7 @@ $TS_CMD_IPCS -s -l | grep  "^---"  >> $TS_OUTPUT
 $TS_CMD_IPCS -s -u | grep  "^---"  >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
-echo "test: all headers" >> $TS_OUTPUT
+ts_log "test: all headers"
 $TS_CMD_IPCS -a | grep --after-context=1 "^---"  >> $TS_OUTPUT
 
 $TS_CMD_IPCS -a -t | grep --after-context=1 "^---"  >> $TS_OUTPUT
index 99a11c20f02ccfc3a1364337785a9b592415ace9..98656b6850d95a1a39983b4eefc59977db67625c 100755 (executable)
@@ -7,37 +7,34 @@ TS_COMPONENT="ipcs"
 TS_DESC="limits overflow"
 
 if [ $UID != 0 ]; then
-       ts_init
+       ts_init "$1"
        ts_skip_nonroot
 fi
 
 . ts-ipcs.sh
 
-ts_init
+ts_init "$1"
 
-(
-       echo "load original values"
-       for i in $IPCS_IDX; do
-               SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
-       done
+ts_log "load original values"
+for i in $IPCS_IDX; do
+       SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
+done >> $TS_OUTPUT
                
-       echo "check for difference between kernel and IPC"
-       ipcs_limits_check
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
 
-       echo "maximalize kernel setting"
-       for i in $IPCS_IDX; do
-               echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
-       done
+ts_log "maximalize kernel setting"
+for i in $IPCS_IDX; do
+       echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
+done >> $TS_OUTPUT
 
-       echo "re-check for difference between kernel and IPC"
-       ipcs_limits_check
+ts_log "re-check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
 
-       echo "write original values to kernel"
-       for i in $IPCS_IDX; do
-               echo ${SHM_ORG[$i]} >> ${IPCS_PROCFILES[$i]}
-       done
-
-) > $TS_OUTPUT
+ts_log "write original values to kernel"
+for i in $IPCS_IDX; do
+       echo ${SHM_ORG[$i]} >> ${IPCS_PROCFILES[$i]}
+done >> $TS_OUTPUT
 
 ts_finalize
 
index 59e10d4fe0acdbdb8aae2d4210b1afca06b77def..05256f97bce804b89ebf984c207741fca8ba710d 100755 (executable)
@@ -8,13 +8,10 @@ TS_DESC="basic limits"
 
 . ts-ipcs.sh
 
-ts_init
+ts_init "$1"
 
-(
-       echo "check for difference between kernel and IPC"
-       ipcs_limits_check
-
-) > $TS_OUTPUT
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
 
 ts_finalize
 
index 9f9e119c2679e77c39ce983f25d76d43e5fd4c96..ff0fc717ed1b91e14bd5065e8c2de2f64833b194 100644 (file)
@@ -1,10 +1,5 @@
 #!/bin/bash
 
-if [ ! -f "/proc/sys/kernel/shmall" ]; then
-       ts_init
-       ts_skip "not IPC in kernel"
-fi
-
 PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
 
 # kernel files
index d0509b0508232c3f0f37d9d55a74825edae2b7f7..a79b02d0a49cc22d681e79ca4ff01021eaac9b88 100755 (executable)
@@ -6,7 +6,7 @@
 TS_COMPONENT="login"
 TS_DESC="checktty"
 
-ts_init
+ts_init "$1"
 $TS_CMD_CHECKTTY  >> $TS_OUTPUT
 ts_finalize
 
index fe86e2ca0d41fa936176b772f83f63b5c31107ed..c6f6ed4c683df638317580c6b0b8ade7b9ce4877 100755 (executable)
@@ -18,7 +18,7 @@
 TS_COMPONENT="look"
 TS_DESC="separator"
 
-ts_init
+ts_init "$1"
 
 [ -f "/usr/share/dict/words" ] || ts_skip "/usr/share/dict/words not such file"
 
index 88458110a0546e341f1fe9830e0054b8731b7924..3b182658a768dbdbc60a64561097ae990ef3d17b 100755 (executable)
@@ -10,7 +10,7 @@
 TS_COMPONENT="mount"
 TS_DESC="move "
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 PWD=$(pwd)
@@ -44,6 +44,6 @@ fi
 $TS_CMD_UMOUNT $DIR_SRC
 rmdir $DIR_SRC $DIR_A $DIR_B
 
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
 ts_finalize
 
index 5ef76f2b62b178faaba2353fd2400eee9f5b7d21..87f807700f44271ceeda55e38eaf8f1414de0f49 100755 (executable)
@@ -6,7 +6,7 @@
 TS_COMPONENT="mount"
 TS_DESC="mtablock"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 #
index 137aade38deaee155893f522e94acfc6ef397c21..32198c41f08e57bfcf996fafedc88eec6044da0c 100755 (executable)
@@ -6,7 +6,7 @@
 TS_COMPONENT="mount"
 TS_DESC="basic paths"
 
-ts_init
+ts_init "$1"
 
 $TS_CMD_MOUNT -n -f --debug=2 /dev/dummy /mnt &> $TS_OUTPUT
 
index dcaf28886e064e762b3ca7a480ea1e3786974cf7..295ca509704f0d90696937a610f49feb8a8ab420 100755 (executable)
@@ -9,7 +9,7 @@
 TS_COMPONENT="mount"
 TS_DESC="remount"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 # mountpoint
@@ -40,6 +40,6 @@ egrep -q "^$DEVICE $MOUNTPOINT ext2 ro 0 0" /etc/mtab
 
 ts_device_deinit $DEVICE
 
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
 ts_finalize
 
index 4d29167c2c0aa86d062265d29b4f43a330b52ab0..e0d3f9974cb1c4ad5a548b4098e8db9a87ec9185 100755 (executable)
@@ -12,7 +12,7 @@ TS_DESC="special program"
 
 MOUNTER="/sbin/mount.mytest"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 cat > $MOUNTER << EOF
index 55cd75799d5ca5a72e40f2167ada9b60f0ccdd2b..0a4693c468cd7d0fcf500fdb5dc70e089da4ca52 100755 (executable)
@@ -6,15 +6,13 @@
 TS_COMPONENT="namei"
 TS_DESC="logic"
 
-ts_init
+ts_init "$1"
 
 SANDBOX="$TS_OUTDIR/namei"
 
 mkdir -p $SANDBOX/namei1/namei2
 touch $SANDBOX/namei1/namei2/a $SANDBOX/namei1/namei2/b
 
-touch $TS_OUTPUT
-
 $TS_CMD_NAMEI $SANDBOX/namei1/namei2/a   >> $TS_OUTPUT 2>&1
 $TS_CMD_NAMEI $SANDBOX/namei1/namei2/b   >> $TS_OUTPUT 2>&1
 $TS_CMD_NAMEI $SANDBOX/namei1/namei2/a/b >> $TS_OUTPUT 2>&1
index 674f179c2a7f03a53f2d25cdfde1650e0ed271c7..f8552a6e33139cb0cb7a1cb829519af7a44881aa 100755 (executable)
@@ -21,7 +21,7 @@
 TS_COMPONENT="swapon"
 TS_DESC="devname"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 set -o pipefail
@@ -43,6 +43,6 @@ grep -q $DEVICE /proc/swaps
 ts_swapoff $DEVICE
 ts_device_deinit $DEVICE
 
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
 ts_finalize
 
index 2f8aef10585d4e85ea9ee407211a7ec25a5cc410..0d7dc93a8f18734579c7851ab06c7b6987b86364 100755 (executable)
@@ -23,7 +23,7 @@ TS_DESC="label"
 
 LABEL="testSwapLabel"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 set -o pipefail
@@ -48,6 +48,6 @@ grep -q $DEVICE /proc/swaps
 ts_swapoff $DEVICE
 ts_device_deinit $DEVICE
 
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
 ts_finalize
 
index b77b06aaec981a999e84c57638cc4f55cfaebd03..6e2a90faed901fb50b8726346cb631f2e0646247 100755 (executable)
@@ -21,7 +21,7 @@
 TS_COMPONENT="swapon"
 TS_DESC="uuid"
 
-ts_init
+ts_init "$1"
 ts_skip_nonroot
 
 set -o pipefail
@@ -48,6 +48,6 @@ grep -q $DEVICE /proc/swaps
 ts_swapoff $DEVICE
 ts_device_deinit $DEVICE
 
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
 ts_finalize