]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: use compare-vs-/dev/null instead of 'test -s'
authorBernhard Voelker <mail@bernhard-voelker.de>
Wed, 14 Jan 2015 16:38:12 +0000 (17:38 +0100)
committerBernhard Voelker <mail@bernhard-voelker.de>
Wed, 14 Jan 2015 16:38:12 +0000 (17:38 +0100)
When some program produces unexpected output, that use of
compare-vs-/dev/null will ensure that the surprising output is
printed in the test's output.  With "test -s err" only, one
would have to instrument and rerun in order to see the offending
output.

* cfg.mk (sc_prohibit_and_fail_1): Exempt 'compare' from this check.
* tests/dd/misc.sh: Change "tests -s ... || fail=1" to
"compare /dev/null ... && fail=1".
* tests/misc/nice.sh: Likewise.
* tests/rm/read-only.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.

Suggested by Jim Meyering in
http://lists.gnu.org/archive/html/coreutils/2015-01/msg00042.html

cfg.mk
tests/dd/misc.sh
tests/misc/nice.sh
tests/rm/read-only.sh
tests/tail-2/inotify-race.sh
tests/touch/no-dereference.sh

diff --git a/cfg.mk b/cfg.mk
index 70ca2e5ddb0d76a8ac4c166561fc5221e88be737..321e0e93bb74575a5c5934d639ebb900f62c5d92 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -383,7 +383,7 @@ sc_prohibit_fail_0:
 # independently check its contents and thus detect any crash messages.
 sc_prohibit_and_fail_1:
        @prohibit='&& fail=1'                                           \
-       exclude='(stat|kill|test |EGREP|grep|env|2> *[^/])'             \
+       exclude='(stat|kill|test |EGREP|grep|env|compare|2> *[^/])'     \
        halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
        in_vc_files='^tests/'                                           \
          $(_sc_search_regexp)
index 2a536e8d724c826e3e83993ae78e0e52f401eacc..bc5fb37e134a2c6db8af9edff691b4a9c34d0d36 100755 (executable)
@@ -40,7 +40,7 @@ dd status=noxfer status=none if=$tmp_in of=/dev/null 2> err || fail=1
 compare /dev/null err || fail=1
 # check later status=noxfer overrides earlier status=none
 dd status=none status=noxfer if=$tmp_in of=/dev/null 2> err || fail=1
-test -s 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
index 973bc5acc4b7ed2a85f78c9f076359970add4cee..59316ec5a0386d76399159de7f3b399843317211 100755 (executable)
@@ -73,7 +73,7 @@ done
 if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then
   # unprivileged user - warn about failure to change
   nice -n -1 true 2> err || fail=1
-  test -s err || fail=1
+  compare /dev/null err && fail=1
   mv err exp || framework_failure_
   nice --1 true 2> err || fail=1
   compare exp err || fail=1
index 4edc2fab24fd35d2f9d40a7b3e26332b71110390..4375f1bc94c9aedf55f1ad4159c055019b98ae7e 100755 (executable)
@@ -47,6 +47,6 @@ compare /dev/null out || fail=1
 # However, trying to remove an existing file must fail.
 rm -f mnt/f > out 2>&1 && fail=1
 # with a diagnostic.
-test -s out || fail=1
+compare /dev/null out && fail=1
 
 Exit $fail
index 576a652182dd00d2c86c289a561650d62a65dc02..2b1655c48fc87dd42a0aefe4eb375599f88c5707 100755 (executable)
@@ -68,6 +68,6 @@ pid=$!
 
 tail --pid=$pid -f tail.out | (read; kill $pid)
 
-test -s tail.out || fail=1
+compare /dev/null tail.out && fail=1
 
 Exit $fail
index 776c255f2eb948d98c7b2498c34b41c76a685e60..fc0c72378a5a8867b2b091e8d7c8acf7ce1b1f8d 100755 (executable)
@@ -27,7 +27,7 @@ ln -s file link || framework_failure_
 # These first tests should work on every platform.
 # -h does not create files, but it warns.  Use -c to silence warning.
 returns_ 1 touch -h no-file 2> err || fail=1
-test -s err || fail=1
+compare /dev/null err && fail=1
 touch -h -c no-file 2> err || fail=1
 compare /dev/null err || fail=1