]> err.no Git - util-linux/commitdiff
tests: code refactoring -- new ts_skip_nonroot function
authorKarel Zak <kzak@redhat.com>
Tue, 15 May 2007 22:41:14 +0000 (00:41 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 11:09:12 +0000 (13:09 +0200)
The patch moves "if $UID != 0" test to a new function. That's better
than duplicate the code on many places.

Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh
tests/ts-cramfs-mkfs
tests/ts-hwclock-systohc
tests/ts-ipcs-limits
tests/ts-look-separator
tests/ts-mkswap-doit
tests/ts-mount-move
tests/ts-mount-mtablock
tests/ts-mount-remount
tests/ts-mount-special

index c04022b3bf6d871e8833cc2042ab9974b7ffe0eb..969592f7e471f7bcff91c4bdb355128ac774bee8 100644 (file)
@@ -9,6 +9,12 @@ function ts_skip {
        exit 0
 }
 
+function ts_skip_nonroot {
+       if [ $UID != 0 ]; then
+               ts_skip "not root permissions"
+       fi
+}
+
 function ts_failed {
        if [ x"$1" == x"" ]; then
                echo " FAILED ($TS_NAME)"
index 1f7156ee395c3d457c6c849906ef227b1feedc5f..c1f46f11609413d3e4adc94107f13acc70e13b34 100755 (executable)
@@ -24,14 +24,10 @@ TS_COMPONENT="mkfs.cramfs"
 TS_DESC="mkfs"
 
 ts_init
-
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
+ts_skip_nonroot
 
 set -o pipefail
 
-
 touch $TS_OUTPUT
 
 IMAGE="$TS_OUTDIR/cramfs-loop.img"
index 6171ab30c2ce37d5026b807b5b7c21939f103353..43d663203a8b13442d50f58d3037e642568074c3 100755 (executable)
@@ -26,10 +26,8 @@ TS_DESC="systohc"
 NTP_SERVER="0.fedora.pool.ntp.org"
 
 ts_init
+ts_skip_nonroot
 
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
 if [ -x "ntpdate" ]; then
        ts_skip "cannot found ntpdate command"
 fi
index 542819f16bcf3f5bc23270004e68b48d96f0d605..99a11c20f02ccfc3a1364337785a9b592415ace9 100755 (executable)
@@ -8,7 +8,7 @@ TS_DESC="limits overflow"
 
 if [ $UID != 0 ]; then
        ts_init
-       ts_skip "not root permissions"
+       ts_skip_nonroot
 fi
 
 . ts-ipcs.sh
index d86e707796c00fbfa6451f218c3cad94234425d8..e7772bb454e44e681a727154529757ec4c30d65e 100755 (executable)
@@ -21,7 +21,7 @@ TS_DESC="separator"
 ts_init
 
 if [ ! -f "/usr/share/dict/words" ]; then
-       ts_ignore "/usr/share/dict/words not such file" 
+       ts_skip "/usr/share/dict/words not such file" 
 fi
 
 touch $TS_OUTPUT
index e4b5b76326cfbc30beb5e47c6e8a74e9638e817f..b3632b70772ff9f9981edbc83ddaae3537c5a677 100755 (executable)
@@ -24,10 +24,7 @@ TS_COMPONENT="mkswap"
 TS_DESC="doit"
 
 ts_init
-
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
+ts_skip_nonroot
 
 set -o pipefail
 
index aa253b7554dcf72e281fd0ce9b04e83c0e86e002..76400b4493f300f88cd82719d8da34632764204b 100755 (executable)
@@ -11,10 +11,7 @@ TS_COMPONENT="mount"
 TS_DESC="move "
 
 ts_init
-
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
+ts_skip_nonroot
 
 touch $TS_OUTPUT
 
index dc9c8e47896e4401f34d3d2dc212a112102765f7..5ef76f2b62b178faaba2353fd2400eee9f5b7d21 100755 (executable)
@@ -7,10 +7,7 @@ TS_COMPONENT="mount"
 TS_DESC="mtablock"
 
 ts_init
-
-if [ $UID != 0 ]; then
-        ts_skip "not root permissions"
-fi
+ts_skip_nonroot
 
 #
 # Be careful with number of processes. Don't forget that there is time limit
index 16e845824b2fcb4402af77c68b1ed2a4726eb306..28064e745e9fa2efdda237a44afd7cd35b184748 100755 (executable)
@@ -11,10 +11,7 @@ TS_COMPONENT="mount"
 TS_DESC="remount"
 
 ts_init
-
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
+ts_skip_nonroot
 
 # clean up
 test_cleanup() {
index b2ea77d674fce2295f47f17febd01712e4200f6e..3fb193eab958b803aaf444f93b380defc7db6c4f 100755 (executable)
@@ -13,13 +13,10 @@ TS_DESC="special program"
 MOUNTER="/sbin/mount.mytest"
 
 ts_init
+ts_skip_nonroot
 
 touch $TS_OUTPUT
 
-if [ $UID != 0 ]; then
-       ts_skip "not root permissions"
-fi
-
 cat > $MOUNTER << EOF
 #!/bin/bash 
 # This util-linux-ng regression test component