mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 03:12:48 +02:00
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
This commit is contained in:
2
cfg.mk
2
cfg.mk
@@ -383,7 +383,7 @@ sc_prohibit_fail_0:
|
|||||||
# independently check its contents and thus detect any crash messages.
|
# independently check its contents and thus detect any crash messages.
|
||||||
sc_prohibit_and_fail_1:
|
sc_prohibit_and_fail_1:
|
||||||
@prohibit='&& 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' \
|
halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
|
||||||
in_vc_files='^tests/' \
|
in_vc_files='^tests/' \
|
||||||
$(_sc_search_regexp)
|
$(_sc_search_regexp)
|
||||||
|
|||||||
@@ -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
|
compare /dev/null err || fail=1
|
||||||
# check later status=noxfer overrides earlier status=none
|
# check later status=noxfer overrides earlier status=none
|
||||||
dd status=none status=noxfer if=$tmp_in of=/dev/null 2> err || fail=1
|
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
|
dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1
|
||||||
compare $tmp_in $tmp_out || fail=1
|
compare $tmp_in $tmp_out || fail=1
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ done
|
|||||||
if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then
|
if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then
|
||||||
# unprivileged user - warn about failure to change
|
# unprivileged user - warn about failure to change
|
||||||
nice -n -1 true 2> err || fail=1
|
nice -n -1 true 2> err || fail=1
|
||||||
test -s err || fail=1
|
compare /dev/null err && fail=1
|
||||||
mv err exp || framework_failure_
|
mv err exp || framework_failure_
|
||||||
nice --1 true 2> err || fail=1
|
nice --1 true 2> err || fail=1
|
||||||
compare exp err || fail=1
|
compare exp err || fail=1
|
||||||
|
|||||||
@@ -47,6 +47,6 @@ compare /dev/null out || fail=1
|
|||||||
# However, trying to remove an existing file must fail.
|
# However, trying to remove an existing file must fail.
|
||||||
rm -f mnt/f > out 2>&1 && fail=1
|
rm -f mnt/f > out 2>&1 && fail=1
|
||||||
# with a diagnostic.
|
# with a diagnostic.
|
||||||
test -s out || fail=1
|
compare /dev/null out && fail=1
|
||||||
|
|
||||||
Exit $fail
|
Exit $fail
|
||||||
|
|||||||
@@ -68,6 +68,6 @@ pid=$!
|
|||||||
|
|
||||||
tail --pid=$pid -f tail.out | (read; kill $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
|
Exit $fail
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ ln -s file link || framework_failure_
|
|||||||
# These first tests should work on every platform.
|
# These first tests should work on every platform.
|
||||||
# -h does not create files, but it warns. Use -c to silence warning.
|
# -h does not create files, but it warns. Use -c to silence warning.
|
||||||
returns_ 1 touch -h no-file 2> err || fail=1
|
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
|
touch -h -c no-file 2> err || fail=1
|
||||||
compare /dev/null err || fail=1
|
compare /dev/null err || fail=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user