From: Jim Meyering Date: Sun, 14 Nov 2010 11:02:39 +0000 (+0100) Subject: tests: convert 'if test "$VERBOSE" = yes; then' to test ... && X-Git-Tag: v8.8~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff7f0ff85c40174f1885ec61fa4ab6b73d02b555;p=thirdparty%2Fcoreutils.git tests: convert 'if test "$VERBOSE" = yes; then' to test ... && --- diff --git a/tests/chmod/silent b/tests/chmod/silent index 9f9f86f97f..2cfbcbbd75 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 c19eb4e935..3e93645abd 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 515c0c54c9..c978ba253b 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 7e7b6456fa..bd0ef0ed89 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 f68e529f74..346b24536d 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 f9a9d2a7e7..a5190e4e70 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 518990cabe..fdfc3f7111 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 55e8d16720..bf2dfcd529 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 da632bbe52..51d023642b 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 b7164e4550..a4475e6d05 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 53d1b62c57..ed2e21d582 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 0243e8503b..6f38b8b1bf 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 f0e2cd2571..dd82c05096 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 e8e4f2e5d4..cf376f3bac 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 e428d26052..39b70d6efc 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 581a6d47a8..702ab67a38 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 5702552397..c58207abe5 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 c1a28fef8a..e4ecf11f96 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 dc6dde418a..1f3d914eb0 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 3729024fa1..0a8259fef3 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 5822698ea1..8302c4896f 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 28dd90e125..0659d51a5e 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 bb1153a2d8..5acb3d0bbc 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 c230f1754e..4c57c945b5 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 3de278414a..705de2766e 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 3a8bde0375..86fd5288e2 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 8afdb2aa6f..47f10441c9 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 21e0f1ccbe..3a27f15e0a 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 674b0b3532..b0240eb0a0 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 16d7692f57..c67630ed0a 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 057ce91d4a..2e5e4611c8 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 1a23b5333d..f40fc7c42b 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 ad947b4b5b..9ede87ef62 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 1ae0a34eff..704e2679d4 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 aed1c9eee2..83596426e2 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 3b8e442efc..bf2fd451ac 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 a8035922e8..b0a532c635 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 8abf7dc719..371607be67 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