* tests/chmod/c-option.sh: Use `compare /dev/null ... || fail=1` rather than `test -s ... && fail=1`, so that the file contents are output, thus improving diagnostics for failing tests. * tests/cp/cp-a-selinux.sh: Likewise. * tests/cp/cp-mv-enotsup-xattr.sh: Likewise. * tests/dd/misc.sh: Likewise. * tests/misc/nice.sh: Likewise. * tests/misc/xattr.sh: Likewise. * tests/mv/update.sh: Likewise. * tests/rm/deep-2.sh: Likewise. * tests/rm/read-only.sh: Likewise. * tests/split/r-chunk.sh: Likewise. * tests/tail-2/follow-stdin.sh: Likewise. * tests/tail-2/wait.sh: Likewise. * tests/touch/no-dereference.sh: Likewise. --- tests/chmod/c-option.sh | 2 +- tests/cp/cp-a-selinux.sh | 5 +++-- tests/cp/cp-mv-enotsup-xattr.sh | 8 ++++---- tests/dd/misc.sh | 6 +++--- tests/misc/nice.sh | 2 +- tests/misc/xattr.sh | 2 +- tests/mv/update.sh | 2 +- tests/rm/deep-2.sh | 2 +- tests/rm/read-only.sh | 2 +- tests/split/r-chunk.sh | 2 +- tests/tail-2/follow-stdin.sh | 2 +- tests/tail-2/wait.sh | 2 +- tests/touch/no-dereference.sh | 4 ++-- 13 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/tests/chmod/c-option.sh b/tests/chmod/c-option.sh index a1782c3..03e1db9 100755 --- a/tests/chmod/c-option.sh +++ b/tests/chmod/c-option.sh @@ -31,7 +31,7 @@ chmod u=rwx $file || fail=1 chmod -c g=rwx $file > out || fail=1 chmod -c g=rwx $file > empty || fail=1 -test -s empty && fail=1 +compare /dev/null empty || fail=1 case "$(cat out)" in "mode of 'f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;; *) cat out; fail=1 ;; diff --git a/tests/cp/cp-a-selinux.sh b/tests/cp/cp-a-selinux.sh index 3ab7e0e..ca4e8f6 100755 --- a/tests/cp/cp-a-selinux.sh +++ b/tests/cp/cp-a-selinux.sh @@ -37,7 +37,8 @@ cp -a c d 2>err || framework_failure_ cp --preserve=context c e || framework_failure_ cp --preserve=all c f || framework_failure_ ls -Z d | grep $ctx || fail=1 -test -s err && fail=1 #there must be no stderr output for -a +# there must be no stderr output for -a +compare /dev/null err || fail=1 ls -Z e | grep $ctx || fail=1 ls -Z f | grep $ctx || fail=1 @@ -116,7 +117,7 @@ echo > g || framework_failure_ # succeed (giving no diagnostics), yet leaving the destination file empty. cp -a f g 2>err || fail=1 test -s g || fail=1 # The destination file must not be empty. -test -s err && fail=1 # There must be no stderr output. +compare /dev/null err || fail=1 # ===================================================== # Here, we expect cp to succeed and not warn with "Operation not supported" diff --git a/tests/cp/cp-mv-enotsup-xattr.sh b/tests/cp/cp-mv-enotsup-xattr.sh index d711683..6c8fa83 100755 --- a/tests/cp/cp-mv-enotsup-xattr.sh +++ b/tests/cp/cp-mv-enotsup-xattr.sh @@ -69,19 +69,19 @@ grep -F "$xattr_pair" out_a >/dev/null \ # This should pass without diagnostics cp -a xattr/a noxattr/ 2>err || fail=1 test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output +compare /dev/null err || fail=1 rm -f err noxattr/a # This should pass without diagnostics (new file) cp --preserve=all xattr/a noxattr/ 2>err || fail=1 test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output +compare /dev/null err || fail=1 # This should pass without diagnostics (existing file) cp --preserve=all xattr/a noxattr/ 2>err || fail=1 test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output +compare /dev/null err || fail=1 rm -f err noxattr/a @@ -104,7 +104,7 @@ rm -f err noxattr/a # This should pass without diagnostics mv xattr/a noxattr/ 2>err || fail=1 test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output +compare /dev/null err || fail=1 # This should pass and copy xattrs of the symlink # since they're not in the 'user.' namespace. diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh index bb4748c..f877fdd 100755 --- a/tests/dd/misc.sh +++ b/tests/dd/misc.sh @@ -32,12 +32,12 @@ ln -s $tmp_in $tmp_sym || framework_failure_ # check status=none suppresses all output to stderr dd status=none if=$tmp_in of=/dev/null 2> err || fail=1 -test -s err && { cat err; fail=1; } +compare /dev/null err || fail=1 dd status=none if=$tmp_in skip=2 of=/dev/null 2> err || fail=1 -test -s err && { cat err; fail=1; } +compare /dev/null err || fail=1 # check status=none is cumulative with status=noxfer dd status=none status=noxfer if=$tmp_in of=/dev/null 2> err || fail=1 -test -s err && { cat err; fail=1; } +compare /dev/null err || fail=1 dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 compare $tmp_in $tmp_out || fail=1 diff --git a/tests/misc/nice.sh b/tests/misc/nice.sh index 8efb7d8..d6910c7 100755 --- a/tests/misc/nice.sh +++ b/tests/misc/nice.sh @@ -86,7 +86,7 @@ if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then else # superuser - change succeeds nice -n -1 nice 2> err || fail=1 - test -s err && fail=1 + compare /dev/null err || fail=1 test x$(nice -n -1 nice) = x-1 || fail=1 test x$(nice --1 nice) = x-1 || fail=1 fi diff --git a/tests/misc/xattr.sh b/tests/misc/xattr.sh index 2694246..f208090 100755 --- a/tests/misc/xattr.sh +++ b/tests/misc/xattr.sh @@ -66,7 +66,7 @@ getfattr -d c >out_c || skip_ "failed to get xattr of file" grep -F "$xattr_pair" out_c || fail=1 # cp's -a option must produce no diagnostics. -cp -a a d 2>err && test -s err && fail=1 +cp -a a d 2>err && { compare /dev/null err || fail=1; } getfattr -d d >out_d || skip_ "failed to get xattr of file" grep -F "$xattr_pair" out_d || fail=1 diff --git a/tests/mv/update.sh b/tests/mv/update.sh index 688a8f2..4c0553a 100755 --- a/tests/mv/update.sh +++ b/tests/mv/update.sh @@ -30,7 +30,7 @@ for interactive in '' -i; do # With coreutils-6.9 and earlier, using --update with -i would # mistakenly elicit a prompt. $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1 - test -s out && fail=1 + compare /dev/null out || fail=1 case "$(cat new)" in new) ;; *) fail=1 ;; esac case "$(cat old)" in old) ;; *) fail=1 ;; esac done diff --git a/tests/rm/deep-2.sh b/tests/rm/deep-2.sh index 24415ed..c3ea085 100755 --- a/tests/rm/deep-2.sh +++ b/tests/rm/deep-2.sh @@ -46,7 +46,7 @@ echo n > no || framework_failure_ rm ---presume-input-tty -r x < no > out || fail=1 # expect empty output -test -s out && fail=1 +compare /dev/null out || fail=1 # the directory must have been removed test -d x && fail=1 diff --git a/tests/rm/read-only.sh b/tests/rm/read-only.sh index 1ac8f27..377305c 100755 --- a/tests/rm/read-only.sh +++ b/tests/rm/read-only.sh @@ -42,7 +42,7 @@ test $skip = 1 \ # Applying rm -f to a nonexistent file on a read-only file system must succeed. rm -f mnt/no-such > out 2>&1 || fail=1 # It must produce no diagnostic. -test -s out && fail=1 +compare /dev/null out || fail=1 # However, trying to remove an existing file must fail. rm -f mnt/f > out 2>&1 && fail=1 diff --git a/tests/split/r-chunk.sh b/tests/split/r-chunk.sh index e84dfa5..8a5f221 100755 --- a/tests/split/r-chunk.sh +++ b/tests/split/r-chunk.sh @@ -32,7 +32,7 @@ stat x?? 2>/dev/null && fail=1 printf '1\n2\n3\n4\n5\n' > in || framework_failure_ split -n r/3 in > out || fail=1 -test -s out && fail=1 +compare /dev/null out || fail=1 split -n r/1/3 in > r1 || fail=1 split -n r/2/3 in > r2 || fail=1 diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh index 8ca10d6..1769ee2 100755 --- a/tests/tail-2/follow-stdin.sh +++ b/tests/tail-2/follow-stdin.sh @@ -28,7 +28,7 @@ timeout 1 tail -f < in > out 2> err test $? = 124 || fail=1 # Ensure there was no error output. -test -s err && fail=1 +compare /dev/null err || fail=1 # Ensure there was compare exp out || fail=1 diff --git a/tests/tail-2/wait.sh b/tests/tail-2/wait.sh index 13898ac..3dec55c 100755 --- a/tests/tail-2/wait.sh +++ b/tests/tail-2/wait.sh @@ -51,7 +51,7 @@ for inotify in ---disable-inotify ''; do grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x mv x tail.err - test -s tail.err && fail=1 + compare /dev/null tail.err || fail=1 >tail.err tail_F() diff --git a/tests/touch/no-dereference.sh b/tests/touch/no-dereference.sh index 718fea7..1d012a1 100755 --- a/tests/touch/no-dereference.sh +++ b/tests/touch/no-dereference.sh @@ -29,7 +29,7 @@ ln -s file link || framework_failure_ touch -h no-file 2> err && fail=1 test -s err || fail=1 touch -h -c no-file 2> err || fail=1 -test -s err && fail=1 +compare /dev/null err || fail=1 # -h works on regular files touch -h file || fail=1 @@ -49,7 +49,7 @@ grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || touch -h dangling 2> err case $? in 0) test -f nowhere && fail=1 - test -s err && fail=1;; + compare /dev/null err || fail=1;; 1) grep 'Function not implemented' err \ && skip_ 'this system lacks the utimensat function' fail=1;; -- 1.7.7.6