summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2016-11-08 19:57:41 -0600
committerJim Meyering <meyering@fb.com>2016-11-13 17:09:57 -0800
commit4d4d8bccc341941404dc92d0adc057e67014e2ea (patch)
treefaf04706ebd51a3c7e369110fb23bf80b83cef86 /tests/misc
parenteba871cd3237e8b7dcd9552f544b365934767849 (diff)
downloadcoreutils-4d4d8bccc341941404dc92d0adc057e67014e2ea.tar.xz
tests: use "returns_" rather than explicit comparison with "$?"
The previous "returns_"-using change failed to convert many uses of "$?". Convert all but two of the remaining ones. * tests/ls/stat-vs-dirent.sh: Likewise. * tests/misc/head-write-error.sh: Likewise. * tests/misc/nice.sh: Likewise. * tests/misc/nohup.sh: Likewise. * tests/misc/stdbuf.sh: Likewise. * tests/misc/sync.sh: Likewise. * tests/tail-2/pid.sh: Likewise. * tests/tail-2/wait.sh: Likewise. Thanks to Bernhard Volker for spotting this.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/head-write-error.sh7
-rwxr-xr-xtests/misc/nice.sh3
-rwxr-xr-xtests/misc/nohup.sh9
-rwxr-xr-xtests/misc/stdbuf.sh22
-rwxr-xr-xtests/misc/sync.sh3
5 files changed, 18 insertions, 26 deletions
diff --git a/tests/misc/head-write-error.sh b/tests/misc/head-write-error.sh
index 4c021f520..1e8e566c3 100755
--- a/tests/misc/head-write-error.sh
+++ b/tests/misc/head-write-error.sh
@@ -36,14 +36,13 @@ printf '%s\n' "head: error writing 'standard output'" > exp
for item in lines bytes; do
for N in 0 1; do
# pipe case
- yes | timeout 10s head --$item=-$N > /dev/full 2> errt && fail=1
- test $? = 124 && fail=1
+ yes | returns_ 1 timeout 10s head --$item=-$N > /dev/full 2> errt || fail=1
sed 's/\(head:.*\):.*/\1/' errt > err
compare exp err || fail=1
# seekable case
- timeout 10s head --$item=-$N bigseek > /dev/full 2> errt && fail=1
- test $? = 124 && fail=1
+ returns_ 1 timeout 10s head --$item=-$N bigseek > /dev/full 2> errt \
+ || fail=1
sed 's/\(head:.*\):.*/\1/' errt > err
compare exp err || fail=1
done
diff --git a/tests/misc/nice.sh b/tests/misc/nice.sh
index 85523eb4d..36d6f9189 100755
--- a/tests/misc/nice.sh
+++ b/tests/misc/nice.sh
@@ -79,8 +79,7 @@ if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then
compare exp err || fail=1
# Failure to write advisory message is fatal. Buggy through coreutils 8.0.
if test -w /dev/full && test -c /dev/full; then
- nice -n -1 nice > out 2> /dev/full
- test $? = 125 || fail=1
+ returns_ 125 nice -n -1 nice > out 2> /dev/full || fail=1
compare /dev/null out || fail=1
fi
else
diff --git a/tests/misc/nohup.sh b/tests/misc/nohup.sh
index ad60185b1..e9c8c389a 100755
--- a/tests/misc/nohup.sh
+++ b/tests/misc/nohup.sh
@@ -70,8 +70,7 @@ if test -w /dev/full && test -c /dev/full; then
exec >/dev/tty
test -t 1 || exit 0
- nohup echo hi 2> /dev/full
- test $? = 125 || fail=1
+ returns_ 125 nohup echo hi 2> /dev/full || fail=1
test -f nohup.out || fail=1
compare /dev/null nohup.out || fail=1
rm -f nohup.out
@@ -118,9 +117,7 @@ EOF
# Make sure it fails with exit status of 125 when given too few arguments,
# except that POSIX requires 127 in this case.
-nohup >/dev/null 2>&1
-test $? = 125 || fail=1
-POSIXLY_CORRECT=1 nohup >/dev/null 2>&1
-test $? = 127 || fail=1
+returns_ 125 nohup >/dev/null 2>&1 || fail=1
+POSIXLY_CORRECT=1 returns_ 127 nohup >/dev/null 2>&1 || fail=1
Exit $fail
diff --git a/tests/misc/stdbuf.sh b/tests/misc/stdbuf.sh
index 7b9aed503..31f02b7cc 100755
--- a/tests/misc/stdbuf.sh
+++ b/tests/misc/stdbuf.sh
@@ -43,19 +43,17 @@ stdbuf -o1 true || fail=1 # verify size syntax
stdbuf -oK true || fail=1 # verify size syntax
stdbuf -o0 true || fail=1 # verify unbuffered syntax
stdbuf -oL true || fail=1 # verify line buffered syntax
-stdbuf -ol true # Capital 'L' required
-test $? = 125 || fail=1 # Internal error is a particular status
-stdbuf -o$SIZE_OFLOW true # size too large
-test $? = 125 || fail=1
-stdbuf -iL true # line buffering stdin disallowed
-test $? = 125 || fail=1
-stdbuf true # a buffering mode must be specified
-test $? = 125 || fail=1
+
+# Capital 'L' required
+# Internal error is a particular status
+returns_ 125 stdbuf -ol true || fail=1
+
+returns_ 125 stdbuf -o$SIZE_OFLOW true || fail=1 # size too large
+returns_ 125 stdbuf -iL true || fail=1 # line buffering stdin disallowed
+returns_ 125 stdbuf true || fail=1 # a buffering mode must be specified
stdbuf -i0 -o0 -e0 true || fail=1 #check all files
-stdbuf -o1 . # invalid command
-test $? = 126 || fail=1
-stdbuf -o1 no_such # no such command
-test $? = 127 || fail=1
+returns_ 126 stdbuf -o1 . || fail=1 # invalid command
+returns_ 127 stdbuf -o1 no_such || fail=1 # no such command
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
diff --git a/tests/misc/sync.sh b/tests/misc/sync.sh
index 5bf569c5f..cd89c5bb9 100755
--- a/tests/misc/sync.sh
+++ b/tests/misc/sync.sh
@@ -45,8 +45,7 @@ fi
if test "$fail" != '1'; then
# Ensure a fifo doesn't block
mkfifo_or_skip_ fifo
- timeout 10 sync fifo
- test $? = 124 && fail=1
+ returns_ 124 timeout 10 sync fifo && fail=1
fi
Exit $fail