From: Karel Zak Date: Mon, 11 Jun 2007 12:45:32 +0000 (+0200) Subject: tests: pass all arguments to ts_init, add ts_has_option function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d9acab1c14a4464a757dbd5d68a1bf1dca117b2;p=util-linux tests: pass all arguments to ts_init, add ts_has_option function This patch: - replaces "$1" with "$*" for ts_init function - add ts_has_option function - removes some tailing white-spaces Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh.in b/tests/commands.sh.in index 26c77791..86f3d11a 100644 --- a/tests/commands.sh.in +++ b/tests/commands.sh.in @@ -3,6 +3,7 @@ TS_TOPDIR=$TOPDIR/tests # helpers TS_HELPER_SYSINFO="$TS_TOPDIR/helpers/mnt_test_sysinfo" +TS_HELPER_LIBPRELOAD_TIME="$TS_TOPDIR/helpers/.libs/libpreload-time.so" # external commands TS_ECMD_BLKID="@BLKID@" @@ -26,8 +27,11 @@ TS_CMD_COL=${TS_CMD_COL:-"$TOPDIR/text-utils/col"} TS_CMD_NAMEI=${TS_CMD_NAMEI-"$TOPDIR/misc-utils/namei"} TS_CMD_LOOK=${TS_CMD_LOOK-"$TOPDIR/misc-utils/look"} +TS_CMD_CAL=${TS_CMD_CAL-"$TOPDIR/misc-utils/cal"} TS_CMD_CHECKTTY=${TS_CMD_CHECKTTY-"$TOPDIR/login-utils/checktty_test"} TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$TOPDIR/hwclock/hwclock"} + + diff --git a/tests/functions.sh b/tests/functions.sh index ed435092..a33b885b 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -42,6 +42,12 @@ function ts_log { [ "$TS_VERBOSE" == "yes" ] && echo "$1" } +function ts_has_option { + NAME="$1" + ALL="$2" + echo -n $ALL | sed 's/ //g' | gawk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }' +} + function ts_init { export LANG="en_US.UTF-8": TS_NAME=$(basename $0) @@ -51,7 +57,8 @@ function ts_init { if [ ! -d $TS_DIFFDIR ]; then mkdir -p $TS_DIFFDIR fi - [ "$1" == "--verbose" ] && TS_VERBOSE="yes" + + TS_VERBOSE=$( ts_has_option "verbose" "$*") TS_OUTPUT="$TS_OUTDIR/$TS_NAME" TS_DIFF="$TS_DIFFDIR/$TS_NAME" TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME" diff --git a/tests/ts-col-multibyte b/tests/ts-col-multibyte index 00ebb2b3..4ca11ccb 100755 --- a/tests/ts-col-multibyte +++ b/tests/ts-col-multibyte @@ -6,7 +6,7 @@ TS_COMPONENT="col" TS_DESC="multibyte" -ts_init "$1" +ts_init "$*" cat $TS_INPUT | $TS_CMD_COL > /dev/null 2> $TS_OUTPUT diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs index c2d6c131..4d7ca23d 100755 --- a/tests/ts-cramfs-mkfs +++ b/tests/ts-cramfs-mkfs @@ -23,7 +23,7 @@ TS_COMPONENT="mkfs.cramfs" TS_DESC="mkfs" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-devname b/tests/ts-fstab-devname index 30e2414a..64ab8e57 100755 --- a/tests/ts-fstab-devname +++ b/tests/ts-fstab-devname @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="fstab" TS_DESC="devname" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-devname2label b/tests/ts-fstab-devname2label index 9b7926ba..96ce9acd 100755 --- a/tests/ts-fstab-devname2label +++ b/tests/ts-fstab-devname2label @@ -27,7 +27,7 @@ TS_DESC="devname2label" LABEL="testMountD2L" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-devname2uuid b/tests/ts-fstab-devname2uuid index 602ab59f..e81897e4 100755 --- a/tests/ts-fstab-devname2uuid +++ b/tests/ts-fstab-devname2uuid @@ -25,7 +25,7 @@ TS_COMPONENT="fstab" TS_DESC="devname2uuid" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-label b/tests/ts-fstab-label index 8edb342f..b6be12df 100755 --- a/tests/ts-fstab-label +++ b/tests/ts-fstab-label @@ -23,7 +23,7 @@ TS_DESC="label" LABEL="testFstabLabel" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail @@ -31,7 +31,7 @@ set -o pipefail DEVICE=$(ts_device_init) [ "$?" == 0 ] || ts_die "Cannot init device" -mkfs.ext3 -L $LABEL $DEVICE &> /dev/null +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null [ "$?" == "0" ] || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has "LABEL" $LABEL $DEVICE diff --git a/tests/ts-fstab-label2devname b/tests/ts-fstab-label2devname index 92497c59..569e0a0d 100755 --- a/tests/ts-fstab-label2devname +++ b/tests/ts-fstab-label2devname @@ -27,7 +27,7 @@ TS_DESC="label2devname" LABEL="testMountL2D" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-label2uuid b/tests/ts-fstab-label2uuid index 5467b460..9579a426 100755 --- a/tests/ts-fstab-label2uuid +++ b/tests/ts-fstab-label2uuid @@ -27,7 +27,7 @@ TS_DESC="label2uuid" LABEL="testMountL2U" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-uuid b/tests/ts-fstab-uuid index 0cd7f4db..f8a8d5c4 100755 --- a/tests/ts-fstab-uuid +++ b/tests/ts-fstab-uuid @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="fstab" TS_DESC="uuid" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail @@ -29,7 +29,7 @@ set -o pipefail DEVICE=$(ts_device_init) [ "$?" == 0 ] || ts_die "Cannot init device" -mkfs.ext3 $DEVICE &> /dev/null +mkfs.ext3 $DEVICE &> /dev/null [ "$?" == "0" ] || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has_uuid $DEVICE diff --git a/tests/ts-fstab-uuid2devname b/tests/ts-fstab-uuid2devname index 53162349..da0e03c0 100755 --- a/tests/ts-fstab-uuid2devname +++ b/tests/ts-fstab-uuid2devname @@ -25,7 +25,7 @@ TS_COMPONENT="fstab" TS_DESC="uuid2devname" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-fstab-uuid2label b/tests/ts-fstab-uuid2label index 9fa4f6cf..7f4c0afe 100755 --- a/tests/ts-fstab-uuid2label +++ b/tests/ts-fstab-uuid2label @@ -27,7 +27,7 @@ TS_DESC="uuid2label" LABEL="testMountU2L" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-hwclock-systohc b/tests/ts-hwclock-systohc index 2bbe9ce1..63758647 100755 --- a/tests/ts-hwclock-systohc +++ b/tests/ts-hwclock-systohc @@ -25,7 +25,7 @@ TS_DESC="systohc" NTP_SERVER="0.fedora.pool.ntp.org" -ts_init "$1" +ts_init "$*" ts_skip_nonroot [ -x "/usr/sbin/ntpdate" ] || ts_skip "cannot found ntpdate command" diff --git a/tests/ts-ipcs-headers b/tests/ts-ipcs-headers index b8728d6c..601bea80 100755 --- a/tests/ts-ipcs-headers +++ b/tests/ts-ipcs-headers @@ -6,7 +6,7 @@ TS_COMPONENT="ipcs" TS_DESC="headers" -ts_init "$1" +ts_init "$*" ts_log "test: shm headers" $TS_CMD_IPCS -m -t | grep --after-context=1 "^---" >> $TS_OUTPUT diff --git a/tests/ts-ipcs-limits b/tests/ts-ipcs-limits index 98656b68..33624de6 100755 --- a/tests/ts-ipcs-limits +++ b/tests/ts-ipcs-limits @@ -7,19 +7,19 @@ TS_COMPONENT="ipcs" TS_DESC="limits overflow" if [ $UID != 0 ]; then - ts_init "$1" + ts_init "$*" ts_skip_nonroot fi . ts-ipcs.sh -ts_init "$1" +ts_init "$*" ts_log "load original values" for i in $IPCS_IDX; do SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]}) done >> $TS_OUTPUT - + ts_log "check for difference between kernel and IPC" ipcs_limits_check >> $TS_OUTPUT diff --git a/tests/ts-ipcs-limits2 b/tests/ts-ipcs-limits2 index 05256f97..1c8307f6 100755 --- a/tests/ts-ipcs-limits2 +++ b/tests/ts-ipcs-limits2 @@ -8,7 +8,7 @@ TS_DESC="basic limits" . ts-ipcs.sh -ts_init "$1" +ts_init "$*" ts_log "check for difference between kernel and IPC" ipcs_limits_check >> $TS_OUTPUT diff --git a/tests/ts-login-checktty b/tests/ts-login-checktty index a79b02d0..f31efab3 100755 --- a/tests/ts-login-checktty +++ b/tests/ts-login-checktty @@ -6,7 +6,7 @@ TS_COMPONENT="login" TS_DESC="checktty" -ts_init "$1" +ts_init "$*" $TS_CMD_CHECKTTY >> $TS_OUTPUT ts_finalize diff --git a/tests/ts-look-separator b/tests/ts-look-separator index c6f6ed4c..0a43df8d 100755 --- a/tests/ts-look-separator +++ b/tests/ts-look-separator @@ -18,7 +18,7 @@ TS_COMPONENT="look" TS_DESC="separator" -ts_init "$1" +ts_init "$*" [ -f "/usr/share/dict/words" ] || ts_skip "/usr/share/dict/words not such file" diff --git a/tests/ts-mount-devname b/tests/ts-mount-devname index a2ebb332..cf7450cf 100755 --- a/tests/ts-mount-devname +++ b/tests/ts-mount-devname @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="mount" TS_DESC="devname" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail @@ -29,7 +29,7 @@ set -o pipefail DEVICE=$(ts_device_init) [ "$?" == 0 ] || ts_die "Cannot init device" -mkfs.ext3 $DEVICE &> /dev/null +mkfs.ext3 $DEVICE &> /dev/null [ "$?" == "0" ] || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has "TYPE" "ext3" $DEVICE diff --git a/tests/ts-mount-label b/tests/ts-mount-label index 2861d531..f5d0bef5 100755 --- a/tests/ts-mount-label +++ b/tests/ts-mount-label @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -23,7 +23,7 @@ TS_DESC="label" LABEL="testMountLabel" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail @@ -31,7 +31,7 @@ set -o pipefail DEVICE=$(ts_device_init) [ "$?" == 0 ] || ts_die "Cannot init device" -mkfs.ext3 -L $LABEL $DEVICE &> /dev/null +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null [ "$?" == "0" ] || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has "LABEL" $LABEL $DEVICE diff --git a/tests/ts-mount-move b/tests/ts-mount-move index 3b182658..522b6343 100755 --- a/tests/ts-mount-move +++ b/tests/ts-mount-move @@ -10,7 +10,7 @@ TS_COMPONENT="mount" TS_DESC="move " -ts_init "$1" +ts_init "$*" ts_skip_nonroot PWD=$(pwd) diff --git a/tests/ts-mount-mtablock b/tests/ts-mount-mtablock index 87f80770..edcf723e 100755 --- a/tests/ts-mount-mtablock +++ b/tests/ts-mount-mtablock @@ -6,7 +6,7 @@ TS_COMPONENT="mount" TS_DESC="mtablock" -ts_init "$1" +ts_init "$*" ts_skip_nonroot # diff --git a/tests/ts-mount-paths b/tests/ts-mount-paths index fe3ef920..7a8e9ff7 100755 --- a/tests/ts-mount-paths +++ b/tests/ts-mount-paths @@ -6,7 +6,7 @@ TS_COMPONENT="mount" TS_DESC="basic paths" -ts_init "$1" +ts_init "$*" $TS_CMD_MOUNT -n -f -v -v -v /dev/dummy /mnt &> $TS_OUTPUT diff --git a/tests/ts-mount-remount b/tests/ts-mount-remount index b293572a..8a2e59ed 100755 --- a/tests/ts-mount-remount +++ b/tests/ts-mount-remount @@ -9,7 +9,7 @@ TS_COMPONENT="mount" TS_DESC="remount" -ts_init "$1" +ts_init "$*" ts_skip_nonroot # mountpoint diff --git a/tests/ts-mount-special b/tests/ts-mount-special index bcdec248..aeffc250 100755 --- a/tests/ts-mount-special +++ b/tests/ts-mount-special @@ -12,11 +12,11 @@ TS_DESC="special program" MOUNTER="/sbin/mount.mytest" -ts_init "$1" +ts_init "$*" ts_skip_nonroot cat > $MOUNTER << EOF -#!/bin/bash +#!/bin/bash # This util-linux-ng regression test component # It's safe to remove me... # diff --git a/tests/ts-mount-uuid b/tests/ts-mount-uuid index cb004e91..64d934c6 100755 --- a/tests/ts-mount-uuid +++ b/tests/ts-mount-uuid @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="mount" TS_DESC="uuid" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail @@ -29,7 +29,7 @@ set -o pipefail DEVICE=$(ts_device_init) [ "$?" == 0 ] || ts_die "Cannot init device" -mkfs.ext3 $DEVICE &> /dev/null +mkfs.ext3 $DEVICE &> /dev/null [ "$?" == "0" ] || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has_uuid $DEVICE diff --git a/tests/ts-namei-logic b/tests/ts-namei-logic index 0a4693c4..2c44c601 100755 --- a/tests/ts-namei-logic +++ b/tests/ts-namei-logic @@ -6,7 +6,7 @@ TS_COMPONENT="namei" TS_DESC="logic" -ts_init "$1" +ts_init "$*" SANDBOX="$TS_OUTDIR/namei" diff --git a/tests/ts-swapon-devname b/tests/ts-swapon-devname index f8552a6e..4193fb00 100755 --- a/tests/ts-swapon-devname +++ b/tests/ts-swapon-devname @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="swapon" TS_DESC="devname" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-swapon-label b/tests/ts-swapon-label index 0d7dc93a..0f79340d 100755 --- a/tests/ts-swapon-label +++ b/tests/ts-swapon-label @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -23,7 +23,7 @@ TS_DESC="label" LABEL="testSwapLabel" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail diff --git a/tests/ts-swapon-uuid b/tests/ts-swapon-uuid index 6e2a90fa..14d79caf 100755 --- a/tests/ts-swapon-uuid +++ b/tests/ts-swapon-uuid @@ -1,14 +1,14 @@ #!/bin/bash -# +# # Copyright (C) 2007 Karel Zak -# +# # This file is part of util-linux-ng. -# +# # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# +# # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,7 +21,7 @@ TS_COMPONENT="swapon" TS_DESC="uuid" -ts_init "$1" +ts_init "$*" ts_skip_nonroot set -o pipefail