diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2015-01-14 17:38:12 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2015-01-14 17:38:12 +0100 |
commit | e84046dbe6dd26bfcea7edf6fb419bea274635ab (patch) | |
tree | 50160bef015be6a261b0986762e23a449657fe0b /tests | |
parent | 58cff8a009ed9b8280c5f35074cef97231286023 (diff) | |
download | coreutils-e84046dbe6dd26bfcea7edf6fb419bea274635ab.tar.xz |
tests: use compare-vs-/dev/null instead of 'test -s'
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
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/dd/misc.sh | 2 | ||||
-rwxr-xr-x | tests/misc/nice.sh | 2 | ||||
-rwxr-xr-x | tests/rm/read-only.sh | 2 | ||||
-rwxr-xr-x | tests/tail-2/inotify-race.sh | 2 | ||||
-rwxr-xr-x | tests/touch/no-dereference.sh | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh index 2a536e8d7..bc5fb37e1 100755 --- a/tests/dd/misc.sh +++ b/tests/dd/misc.sh @@ -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 diff --git a/tests/misc/nice.sh b/tests/misc/nice.sh index 973bc5acc..59316ec5a 100755 --- a/tests/misc/nice.sh +++ b/tests/misc/nice.sh @@ -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 diff --git a/tests/rm/read-only.sh b/tests/rm/read-only.sh index 4edc2fab2..4375f1bc9 100755 --- a/tests/rm/read-only.sh +++ b/tests/rm/read-only.sh @@ -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 diff --git a/tests/tail-2/inotify-race.sh b/tests/tail-2/inotify-race.sh index 576a65218..2b1655c48 100755 --- a/tests/tail-2/inotify-race.sh +++ b/tests/tail-2/inotify-race.sh @@ -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 diff --git a/tests/touch/no-dereference.sh b/tests/touch/no-dereference.sh index 776c255f2..fc0c72378 100755 --- a/tests/touch/no-dereference.sh +++ b/tests/touch/no-dereference.sh @@ -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 |