From ff7f0ff85c40174f1885ec61fa4ab6b73d02b555 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 14 Nov 2010 12:02:39 +0100 Subject: tests: convert 'if test "$VERBOSE" = yes; then' to test ... && --- tests/chmod/silent | 8 +------- tests/cp/acl | 11 ++--------- tests/cp/cp-mv-backup | 8 +------- tests/cp/cp-mv-enotsup-xattr | 8 ++------ tests/cp/perm | 8 ++------ tests/cp/preserve-gid | 7 ++----- tests/ln/sf-1 | 7 +------ tests/ls/nameless-uid | 7 ++----- tests/ls/rt-1 | 8 +------- tests/misc/arch | 8 ++------ tests/misc/env-null | 9 +-------- tests/misc/md5sum-parallel | 7 +------ tests/misc/printenv | 7 +------ tests/misc/printf | 7 ++----- tests/misc/printf-hex | 12 ++---------- tests/misc/printf-surprise | 7 ++----- tests/misc/pwd-long | 2 ++ tests/misc/pwd-option | 6 +----- tests/misc/pwd-unreadable-parent | 7 +------ tests/misc/selinux | 11 ++--------- tests/misc/stdbuf | 7 ++----- tests/misc/stty | 7 ++----- tests/misc/stty-row-col | 10 ++-------- tests/misc/su-fail | 8 ++------ tests/misc/sum-sysv | 7 +------ tests/misc/truncate-owned-by-other | 8 ++------ tests/misc/wc-parallel | 7 +------ tests/misc/xattr | 8 +------- tests/mkdir/selinux | 8 +------- tests/mv/acl | 9 ++------- tests/mv/childproof | 9 ++------- tests/mv/diag | 7 +------ tests/mv/dup-source | 9 ++------- tests/mv/hard-2 | 8 ++------ tests/mv/i-2 | 11 ++--------- tests/mv/part-symlink | 8 ++------ tests/mv/update | 7 +------ tests/rm/one-file-system | 1 - 38 files changed, 59 insertions(+), 235 deletions(-) (limited to 'tests') diff --git a/tests/chmod/silent b/tests/chmod/silent index 9f9f86f97..2cfbcbbd7 100755 --- a/tests/chmod/silent +++ b/tests/chmod/silent @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - chgrp --version - chmod --version - chown --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { chgrp --version; chmod --version; chown --version; } chmod -f 0 no-such 2> out && fail=1 chgrp -f 0 no-such 2>> out && fail=1 diff --git a/tests/cp/acl b/tests/cp/acl index c19eb4e93..3e93645ab 100755 --- a/tests/cp/acl +++ b/tests/cp/acl @@ -17,16 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Make sure we get English translations. - -if test "$VERBOSE" = yes; then - set -x - mv --version - getfacl --version - setfacl --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { mv --version; getfacl --version; setfacl --version; } + require_acl_ # Skip this test if cp was built without ACL support: diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup index 515c0c54c..c978ba253 100755 --- a/tests/cp/cp-mv-backup +++ b/tests/cp/cp-mv-backup @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version -fi - -# Ensure that ls sorts the same way for everyone. - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && cp --version umask 022 diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr index 7e7b6456f..bd0ef0ed8 100755 --- a/tests/cp/cp-mv-enotsup-xattr +++ b/tests/cp/cp-mv-enotsup-xattr @@ -18,13 +18,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } + require_root_ cwd=`pwd` diff --git a/tests/cp/perm b/tests/cp/perm index f68e529f7..346b24536 100755 --- a/tests/cp/perm +++ b/tests/cp/perm @@ -16,13 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } + very_expensive_ umask 037 diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid index f9a9d2a7e..a5190e4e7 100755 --- a/tests/cp/preserve-gid +++ b/tests/cp/preserve-gid @@ -17,6 +17,8 @@ # along with this program. If not, see . . $srcdir/test-lib.sh +test "$VERBOSE" = yes && cp --version + require_root_ # Some of the tests expect a umask that grants group and/or world read access. @@ -58,11 +60,6 @@ t1() { "$nameless_uid" "$@" } -if test "x$VERBOSE" = xyes; then - set -x - cp --version -fi - nameless_uid=`$PERL -le 'foreach my $i (1000..16*1024-1) { getpwuid $i or (print $i), exit }'` nameless_gid1=`$PERL -le 'foreach my $i (1000..16*1024) { getgrgid $i or (print $i), exit }'` nameless_gid2=`$PERL -le 'foreach my $i ('"$nameless_gid1"'+1..16*1024) { getgrgid $i or (print $i), exit }'` diff --git a/tests/ln/sf-1 b/tests/ln/sf-1 index 518990cab..fdfc3f711 100755 --- a/tests/ln/sf-1 +++ b/tests/ln/sf-1 @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - ln --version -fi - -# Make sure we get English translations. . $srcdir/test-lib.sh +test "$VERBOSE" = yes && ln --version echo foo > a || framework_failure ln -s . b || framework_failure diff --git a/tests/ls/nameless-uid b/tests/ls/nameless-uid index 55e8d1672..bf2dfcd52 100755 --- a/tests/ls/nameless-uid +++ b/tests/ls/nameless-uid @@ -16,15 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - ls --version -fi - : ${srcdir=.} . $srcdir/require-perl . $srcdir/test-lib.sh +test "$VERBOSE" = yes && ls --version + require_root_ nameless_uid=`$PERL -e 'foreach my $i (1000..16*1024) { getpwuid $i or (print "$i\n"), exit }'` diff --git a/tests/ls/rt-1 b/tests/ls/rt-1 index da632bbe5..51d023642 100755 --- a/tests/ls/rt-1 +++ b/tests/ls/rt-1 @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -if test "$VERBOSE" = yes; then - set -x - ls --version - touch --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { ls --version; touch --version; } date=1998-01-15 diff --git a/tests/misc/arch b/tests/misc/arch index b7164e455..a4475e6d0 100755 --- a/tests/misc/arch +++ b/tests/misc/arch @@ -17,13 +17,9 @@ # along with this program. If not, see . . $srcdir/test-lib.sh -require_built_ arch - -if test "$VERBOSE" = yes; then - set -x - arch --version -fi +test "$VERBOSE" = yes && arch --version +require_built_ arch arch > out || fail=1 uname -m > exp || fail=1 diff --git a/tests/misc/env-null b/tests/misc/env-null index 53d1b62c5..ed2e21d58 100755 --- a/tests/misc/env-null +++ b/tests/misc/env-null @@ -16,15 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -if test "$VERBOSE" = yes; then - set -x - env --version - env -- printenv --version -fi - . $srcdir/test-lib.sh - +test "$VERBOSE" = yes && { env --version; env -- printenv --version; } # POSIX is clear that environ may, but need not be, sorted. # Environment variable values may contain newlines, which cannot be diff --git a/tests/misc/md5sum-parallel b/tests/misc/md5sum-parallel index 0243e8503..6f38b8b1b 100755 --- a/tests/misc/md5sum-parallel +++ b/tests/misc/md5sum-parallel @@ -18,12 +18,7 @@ # along with this program. If not, see . . $srcdir/test-lib.sh - -if test "$VERBOSE" = yes; then - set -x - md5sum --version -fi - +test "$VERBOSE" = yes && md5sum --version (mkdir tmp && cd tmp && seq 500 | xargs touch) diff --git a/tests/misc/printenv b/tests/misc/printenv index f0e2cd257..dd82c0509 100755 --- a/tests/misc/printenv +++ b/tests/misc/printenv @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - env -- printenv --version -fi - . $srcdir/test-lib.sh - +test "$VERBOSE" = yes && env -- printenv --version # Without arguments, printenv behaves like env. Some shells provide # printenv as a builtin, so we must invoke it via "env". diff --git a/tests/misc/printf b/tests/misc/printf index e8e4f2e5d..cf376f3ba 100755 --- a/tests/misc/printf +++ b/tests/misc/printf @@ -18,12 +18,9 @@ prog="$abs_top_builddir/src/printf" -if test "$VERBOSE" = yes; then - set -x - "$prog" --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && env -- printf --version + getlimits_ diff --git a/tests/misc/printf-hex b/tests/misc/printf-hex index e428d2605..39b70d6ef 100755 --- a/tests/misc/printf-hex +++ b/tests/misc/printf-hex @@ -16,18 +16,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -prog="$abs_top_builddir/src/printf" - -if test "$VERBOSE" = yes; then - set -x - "$prog" --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && env -- printf --version - - -"$prog" '\x7e3\n' > out || fail=1 +env printf '\x7e3\n' > out || fail=1 cat <<\EOF > exp ~3 EOF diff --git a/tests/misc/printf-surprise b/tests/misc/printf-surprise index 581a6d47a..702ab67a3 100755 --- a/tests/misc/printf-surprise +++ b/tests/misc/printf-surprise @@ -18,12 +18,9 @@ prog=printf -if test "$VERBOSE" = yes; then - set -x - env $prog --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && env -- printf --version + require_ulimit_ diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long index 570255239..c58207abe 100755 --- a/tests/misc/pwd-long +++ b/tests/misc/pwd-long @@ -21,6 +21,8 @@ . $srcdir/require-perl . $srcdir/test-lib.sh +test "$VERBOSE" = yes && env -- pwd --version + require_readable_root_ ARGV_0=$0 diff --git a/tests/misc/pwd-option b/tests/misc/pwd-option index c1a28fef8..e4ecf11f9 100755 --- a/tests/misc/pwd-option +++ b/tests/misc/pwd-option @@ -16,12 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - env -- pwd --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && env -- pwd --version mkdir -p a/b || framework_failure ln -s a/b c || framework_failure diff --git a/tests/misc/pwd-unreadable-parent b/tests/misc/pwd-unreadable-parent index dc6dde418..1f3d914eb 100755 --- a/tests/misc/pwd-unreadable-parent +++ b/tests/misc/pwd-unreadable-parent @@ -18,13 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - env -- pwd --version - readlink --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { env -- pwd --version; readlink --version; } test $host_os != linux-gnu && skip_test_ 'vendor getcwd may be inadequate' diff --git a/tests/misc/selinux b/tests/misc/selinux index 3729024fa..0a8259fef 100755 --- a/tests/misc/selinux +++ b/tests/misc/selinux @@ -16,16 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - chcon --version - cp --version - ls --version - mv --version - stat --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && for i in chcon cp ls mv stat; do $i --version; done + require_root_ require_selinux_ skip_if_mcstransd_is_running_ diff --git a/tests/misc/stdbuf b/tests/misc/stdbuf index 5822698ea..8302c4896 100755 --- a/tests/misc/stdbuf +++ b/tests/misc/stdbuf @@ -17,14 +17,11 @@ # along with this program. If not, see . . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { stdbuf --version; mv --version; } + getlimits_ require_built_ stdbuf -if test "$VERBOSE" = yes; then - set -x - stdbuf --version -fi - # stdbuf fails when the absolute top build dir name contains e.g., space, TAB, NL lf=' ' diff --git a/tests/misc/stty b/tests/misc/stty index 28dd90e12..0659d51a5 100755 --- a/tests/misc/stty +++ b/tests/misc/stty @@ -16,13 +16,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - stty --version -fi - # Make sure there's a tty on stdin. . $srcdir/test-lib.sh +test "$VERBOSE" = yes && stty --version + require_controlling_input_terminal_ trap '' TTOU # Ignore SIGTTOU diff --git a/tests/misc/stty-row-col b/tests/misc/stty-row-col index bb1153a2d..5acb3d0bb 100755 --- a/tests/misc/stty-row-col +++ b/tests/misc/stty-row-col @@ -16,14 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -# This script takes no arguments. - -if test "$VERBOSE" = yes; then - set -x - stty --version -fi - # Setting this envvar to a very small value used to cause e.g., `stty size' # to generate slightly different output on certain systems. COLUMNS=80 @@ -37,6 +29,8 @@ LC_ALL=C export LC_ALL . $srcdir/test-lib.sh +test "$VERBOSE" = yes && stty --version + require_controlling_input_terminal_ trap '' TTOU # Ignore SIGTTOU diff --git a/tests/misc/su-fail b/tests/misc/su-fail index c230f1754..4c57c945b 100755 --- a/tests/misc/su-fail +++ b/tests/misc/su-fail @@ -17,13 +17,9 @@ # along with this program. If not, see . . $srcdir/test-lib.sh -require_built_ su - -if test "$VERBOSE" = yes; then - set -x - su --version -fi +test "$VERBOSE" = yes && su --version +require_built_ su # Very little that we can test without a root password su --- / true # unknown option diff --git a/tests/misc/sum-sysv b/tests/misc/sum-sysv index 3de278414..705de2766 100755 --- a/tests/misc/sum-sysv +++ b/tests/misc/sum-sysv @@ -16,11 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - sum --version -fi - : ${srcdir=.} . $srcdir/require-perl @@ -31,7 +26,7 @@ LC_ALL=C export LC_ALL . $srcdir/test-lib.sh - +test "$VERBOSE" = yes && sum --version # FYI, 16843009 is floor (2^32 / 255). diff --git a/tests/misc/truncate-owned-by-other b/tests/misc/truncate-owned-by-other index 3a8bde037..86fd5288e 100755 --- a/tests/misc/truncate-owned-by-other +++ b/tests/misc/truncate-owned-by-other @@ -16,13 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - truncate --version -fi - -. $srcdir/envvar-check . $srcdir/test-lib.sh +test "$VERBOSE" = yes && truncate --version + require_root_ group_num=$(id -g $NON_ROOT_USERNAME) diff --git a/tests/misc/wc-parallel b/tests/misc/wc-parallel index 8afdb2aa6..47f10441c 100755 --- a/tests/misc/wc-parallel +++ b/tests/misc/wc-parallel @@ -18,12 +18,7 @@ # along with this program. If not, see . . $srcdir/test-lib.sh - -if test "$VERBOSE" = yes; then - set -x - md5sum --version -fi - +test "$VERBOSE" = yes && md5sum --version (mkdir tmp && cd tmp && seq 2000 | xargs touch) diff --git a/tests/misc/xattr b/tests/misc/xattr index 21e0f1ccb..3a27f15e0 100755 --- a/tests/misc/xattr +++ b/tests/misc/xattr @@ -18,14 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version - ginstall --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; ginstall --version; } # Skip this test if cp was built without xattr support: touch src dest || framework_failure diff --git a/tests/mkdir/selinux b/tests/mkdir/selinux index 674b0b353..b0240eb0a 100755 --- a/tests/mkdir/selinux +++ b/tests/mkdir/selinux @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mkdir --version - mkfifo --version - mknod --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { mkdir --version; mkfifo --version; mknod --version; } # Note: on an SELinux/enforcing system running mcstransd older than # mcstrans-0.2.8-1.fc9, the following commands may mistakenly exit diff --git a/tests/mv/acl b/tests/mv/acl index 16d7692f5..c67630ed0 100755 --- a/tests/mv/acl +++ b/tests/mv/acl @@ -17,14 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mv --version - getfacl --version - setfacl --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { mv --version; getfacl --version; setfacl --version; } + require_acl_ # Skip this test if cp was built without ACL support: diff --git a/tests/mv/childproof b/tests/mv/childproof index 057ce91d4..2e5e4611c 100755 --- a/tests/mv/childproof +++ b/tests/mv/childproof @@ -18,14 +18,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version - ln --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; ln --version; } + skip_if_root_ mkdir a b c || framework_failure diff --git a/tests/mv/diag b/tests/mv/diag index 1a23b5333..f40fc7c42 100755 --- a/tests/mv/diag +++ b/tests/mv/diag @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mv --version -fi - -# Make sure we get English translations. . $srcdir/test-lib.sh +test "$VERBOSE" = yes && mv --version touch f1 || framework_failure touch f2 || framework_failure diff --git a/tests/mv/dup-source b/tests/mv/dup-source index ad947b4b5..9ede87ef6 100755 --- a/tests/mv/dup-source +++ b/tests/mv/dup-source @@ -19,15 +19,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version -fi - . $srcdir/test-lib.sh -skip_if_root_ +test "$VERBOSE" = yes && { cp --version; mv --version; } +skip_if_root_ for i in cp; do diff --git a/tests/mv/hard-2 b/tests/mv/hard-2 index 1ae0a34ef..704e2679d 100755 --- a/tests/mv/hard-2 +++ b/tests/mv/hard-2 @@ -17,13 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mv --version - cp --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } + skip_if_root_ mkdir dst || framework_failure diff --git a/tests/mv/i-2 b/tests/mv/i-2 index aed1c9eee..83596426e 100755 --- a/tests/mv/i-2 +++ b/tests/mv/i-2 @@ -17,16 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mv --version - cp --version -fi - - -# Make sure we get English translations. - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } + skip_if_root_ for i in a b c d e f g h; do diff --git a/tests/mv/part-symlink b/tests/mv/part-symlink index 3b8e442ef..bf2fd451a 100755 --- a/tests/mv/part-symlink +++ b/tests/mv/part-symlink @@ -17,13 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - mv --version - cp --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } + cleanup_() { rm -rf "$other_partition_tmpdir"; } . "$abs_srcdir/other-fs-tmpdir" diff --git a/tests/mv/update b/tests/mv/update index a8035922e..b0a532c63 100755 --- a/tests/mv/update +++ b/tests/mv/update @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if test "$VERBOSE" = yes; then - set -x - cp --version - mv --version -fi - . $srcdir/test-lib.sh +test "$VERBOSE" = yes && { cp --version; mv --version; } echo old > old || framework_failure touch -d yesterday old || framework_failure diff --git a/tests/rm/one-file-system b/tests/rm/one-file-system index 8abf7dc71..371607be6 100755 --- a/tests/rm/one-file-system +++ b/tests/rm/one-file-system @@ -20,7 +20,6 @@ test "$VERBOSE" = yes && rm --version require_root_ -# If used, these must *follow* test-lib.sh. cleanup_() { # When you take the undesirable shortcut of making /etc/mtab a link -- cgit v1.2.3-54-g00ecf