diff options
author | Karel Zak | 2007-05-16 00:41:14 +0200 |
---|---|---|
committer | Karel Zak | 2007-05-18 13:09:12 +0200 |
commit | 09892fb60a33d010fc56efad8cc7b3d88dd58581 (patch) | |
tree | d09391c6c546b8d15569bfd76f061175d7d35df5 | |
parent | tests: fix dependence on blkid (diff) | |
download | kernel-qcow2-util-linux-09892fb60a33d010fc56efad8cc7b3d88dd58581.tar.gz kernel-qcow2-util-linux-09892fb60a33d010fc56efad8cc7b3d88dd58581.tar.xz kernel-qcow2-util-linux-09892fb60a33d010fc56efad8cc7b3d88dd58581.zip |
tests: code refactoring -- new ts_skip_nonroot function
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>
-rw-r--r-- | tests/functions.sh | 6 | ||||
-rwxr-xr-x | tests/ts-cramfs-mkfs | 6 | ||||
-rwxr-xr-x | tests/ts-hwclock-systohc | 4 | ||||
-rwxr-xr-x | tests/ts-ipcs-limits | 2 | ||||
-rwxr-xr-x | tests/ts-look-separator | 2 | ||||
-rwxr-xr-x | tests/ts-mkswap-doit | 5 | ||||
-rwxr-xr-x | tests/ts-mount-move | 5 | ||||
-rwxr-xr-x | tests/ts-mount-mtablock | 5 | ||||
-rwxr-xr-x | tests/ts-mount-remount | 5 | ||||
-rwxr-xr-x | tests/ts-mount-special | 5 |
10 files changed, 15 insertions, 30 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index c04022b3b..969592f7e 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -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)" diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs index 1f7156ee3..c1f46f116 100755 --- a/tests/ts-cramfs-mkfs +++ b/tests/ts-cramfs-mkfs @@ -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" diff --git a/tests/ts-hwclock-systohc b/tests/ts-hwclock-systohc index 6171ab30c..43d663203 100755 --- a/tests/ts-hwclock-systohc +++ b/tests/ts-hwclock-systohc @@ -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 diff --git a/tests/ts-ipcs-limits b/tests/ts-ipcs-limits index 542819f16..99a11c20f 100755 --- a/tests/ts-ipcs-limits +++ b/tests/ts-ipcs-limits @@ -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 diff --git a/tests/ts-look-separator b/tests/ts-look-separator index d86e70779..e7772bb45 100755 --- a/tests/ts-look-separator +++ b/tests/ts-look-separator @@ -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 diff --git a/tests/ts-mkswap-doit b/tests/ts-mkswap-doit index e4b5b7632..b3632b707 100755 --- a/tests/ts-mkswap-doit +++ b/tests/ts-mkswap-doit @@ -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 diff --git a/tests/ts-mount-move b/tests/ts-mount-move index aa253b755..76400b449 100755 --- a/tests/ts-mount-move +++ b/tests/ts-mount-move @@ -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 diff --git a/tests/ts-mount-mtablock b/tests/ts-mount-mtablock index dc9c8e478..5ef76f2b6 100755 --- a/tests/ts-mount-mtablock +++ b/tests/ts-mount-mtablock @@ -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 diff --git a/tests/ts-mount-remount b/tests/ts-mount-remount index 16e845824..28064e745 100755 --- a/tests/ts-mount-remount +++ b/tests/ts-mount-remount @@ -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() { diff --git a/tests/ts-mount-special b/tests/ts-mount-special index b2ea77d67..3fb193eab 100755 --- a/tests/ts-mount-special +++ b/tests/ts-mount-special @@ -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 |