diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-01-13 03:30:33 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-01-14 12:20:32 +0000 |
commit | 58cff8a009ed9b8280c5f35074cef97231286023 (patch) | |
tree | 771e8b3fa70fab99b548790931803b75dd272603 /tests/misc | |
parent | 924b1cadff3f2782475516d7eca9aabe856dbf0f (diff) | |
download | coreutils-58cff8a009ed9b8280c5f35074cef97231286023.tar.xz |
tests: add extra protection against unexpected exits
Many tests use `program ... && fail=1` to ensure expected
error situations are indicated. However that would mask
an unexpected exit (like a crash). Therefore explicitly
check the expected exit code.
Note where error messages are also verified, the extra
protection is not added.
* tests/init.sh (returns_): A new helper function to
check the return code of a command, and used
throughout the tests.
* cfg.mk (sc_prohibit_and_fail_1): Add a syntax check
to avoid new instances of this issue.
Diffstat (limited to 'tests/misc')
-rwxr-xr-x | tests/misc/cat-self.sh | 2 | ||||
-rwxr-xr-x | tests/misc/chcon-fail.sh | 8 | ||||
-rwxr-xr-x | tests/misc/chroot-credentials.sh | 7 | ||||
-rwxr-xr-x | tests/misc/close-stdout.sh | 16 | ||||
-rwxr-xr-x | tests/misc/cut-huge-range.sh | 4 | ||||
-rwxr-xr-x | tests/misc/env.sh | 2 | ||||
-rwxr-xr-x | tests/misc/false-status.sh | 8 | ||||
-rwxr-xr-x | tests/misc/md5sum-bsd.sh | 6 | ||||
-rwxr-xr-x | tests/misc/nproc-positive.sh | 2 | ||||
-rwxr-xr-x | tests/misc/pathchk1.sh | 10 | ||||
-rwxr-xr-x | tests/misc/printf.sh | 14 | ||||
-rwxr-xr-x | tests/misc/realpath.sh | 12 | ||||
-rwxr-xr-x | tests/misc/selinux.sh | 2 | ||||
-rwxr-xr-x | tests/misc/shred-remove.sh | 4 | ||||
-rwxr-xr-x | tests/misc/sort-compress-proc.sh | 5 | ||||
-rwxr-xr-x | tests/misc/sort-exit-early.sh | 8 | ||||
-rwxr-xr-x | tests/misc/stat-hyphen.sh | 2 | ||||
-rwxr-xr-x | tests/misc/stat-slash.sh | 2 | ||||
-rwxr-xr-x | tests/misc/stty-invalid.sh | 6 | ||||
-rwxr-xr-x | tests/misc/stty.sh | 6 | ||||
-rwxr-xr-x | tests/misc/tr-case-class.sh | 10 | ||||
-rwxr-xr-x | tests/misc/truncate-dir-fail.sh | 2 | ||||
-rwxr-xr-x | tests/misc/truncate-overflow.sh | 6 | ||||
-rwxr-xr-x | tests/misc/truncate-parameters.sh | 12 | ||||
-rwxr-xr-x | tests/misc/truncate-relative.sh | 8 | ||||
-rwxr-xr-x | tests/misc/wc-parallel.sh | 3 |
26 files changed, 89 insertions, 78 deletions
diff --git a/tests/misc/cat-self.sh b/tests/misc/cat-self.sh index 555177b1f..57777e537 100755 --- a/tests/misc/cat-self.sh +++ b/tests/misc/cat-self.sh @@ -21,7 +21,7 @@ print_ver_ cat echo x >out || framework_failure_ echo x >out1 || framework_failure_ -cat out >>out && fail=1 +returns_ 1 cat out >>out || fail=1 compare out out1 || fail=1 # This example is taken from the POSIX spec for 'cat'. diff --git a/tests/misc/chcon-fail.sh b/tests/misc/chcon-fail.sh index 48c3fcdfc..5265fa011 100755 --- a/tests/misc/chcon-fail.sh +++ b/tests/misc/chcon-fail.sh @@ -22,16 +22,16 @@ print_ver_ chcon # neither context nor file -chcon 2> /dev/null && fail=1 +returns_ 1 chcon 2> /dev/null || fail=1 # No file -chcon CON 2> /dev/null && fail=1 +returns_ 1 chcon CON 2> /dev/null || fail=1 # No file touch f -chcon --reference=f 2> /dev/null && fail=1 +returns_ 1 chcon --reference=f 2> /dev/null || fail=1 # No file -chcon -u anyone 2> /dev/null && fail=1 +returns_ 1 chcon -u anyone 2> /dev/null || fail=1 Exit $fail diff --git a/tests/misc/chroot-credentials.sh b/tests/misc/chroot-credentials.sh index d33fe97b1..8b6771000 100755 --- a/tests/misc/chroot-credentials.sh +++ b/tests/misc/chroot-credentials.sh @@ -22,6 +22,8 @@ print_ver_ chroot require_root_ +EXIT_CANCELED=125 + grep '^#define HAVE_SETGROUPS 1' "$CONFIG_HEADER" >/dev/null \ && HAVE_SETGROUPS=1 @@ -36,7 +38,8 @@ chroot --userspec=$NON_ROOT_UID: / true || fail=1 # verify that invalid groups are diagnosed for g in ' ' ',' '0trail'; do - test "$(chroot --groups="$g" / id -G)" && fail=1 + returns_ $EXIT_CANCELED chroot --groups="$g" / id -G >invalid || fail=1 + compare /dev/null invalid || fail=1 done # Verify that root credentials are kept. @@ -111,7 +114,7 @@ if ! id -u +12342; then test "$(chroot --userspec=+12342:+5678 / id -G)" = '5678' || fail=1 # Ensure we fail when we don't know what groups to set for an unknown ID - chroot --userspec=+12342 / true && fail=1 + returns_ $EXIT_CANCELED chroot --userspec=+12342 / true || fail=1 fi Exit $fail diff --git a/tests/misc/close-stdout.sh b/tests/misc/close-stdout.sh index 0210678db..6714ec0f3 100755 --- a/tests/misc/close-stdout.sh +++ b/tests/misc/close-stdout.sh @@ -44,21 +44,21 @@ sleep 0 >&- || fail=1 # This test is ineffective unless /dev/stdout also works. if "$p/src/test" -w /dev/stdout >/dev/null && "$p/src/test" ! -w /dev/stdout >&-; then - "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1 - cp --verbose a b >&- 2>/dev/null && fail=1 + returns_ 1 "$p/src/printf" 'foo' >&- 2>/dev/null || fail=1 + returns_ 1 cp --verbose a b >&- 2>/dev/null || fail=1 rm -Rf tmpfile-?????? || fail=1 - mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1 - mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1 + returns_ 1 mktemp tmpfile-XXXXXX >&- 2>/dev/null || fail=1 + returns_ 1 mktemp tmpfile-XXXXXX -q >&- 2>/dev/null || fail=1 case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac fi # Likewise for /dev/full, if /dev/full works. if test -w /dev/full && test -c /dev/full; then - "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 - cp --verbose a b >/dev/full 2>/dev/null && fail=1 + returns_ 1 "$p/src/printf" 'foo' >/dev/full 2>/dev/null || fail=1 + returns_ 1 cp --verbose a b >/dev/full 2>/dev/null || fail=1 rm -Rf tmpdir-?????? || fail=1 - mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 - mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 + returns_ 1 mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null || fail=1 + returns_ 1 mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null || fail=1 case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac fi diff --git a/tests/misc/cut-huge-range.sh b/tests/misc/cut-huge-range.sh index f0713d05a..035d8d087 100755 --- a/tests/misc/cut-huge-range.sh +++ b/tests/misc/cut-huge-range.sh @@ -56,8 +56,8 @@ CUT_MAX=$(echo $SIZE_MAX | sed "$subtract_one") (ulimit -v 20000; : | cut -b1-$CUT_MAX >> err 2>&1) || fail=1 # Explicitly disallow values above CUT_MAX -(ulimit -v 20000; : | cut -b$SIZE_MAX 2>/dev/null) && fail=1 -(ulimit -v 20000; : | cut -b$SIZE_OFLOW 2>/dev/null) && fail=1 +(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_MAX 2>/dev/null) || fail=1 +(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_OFLOW 2>/dev/null) || fail=1 compare /dev/null err || fail=1 diff --git a/tests/misc/env.sh b/tests/misc/env.sh index 6994738f0..d7c5a099a 100755 --- a/tests/misc/env.sh +++ b/tests/misc/env.sh @@ -102,7 +102,7 @@ cat <<EOF > unlikely_name/also_unlikely || framework_failure_ echo pass EOF chmod +x unlikely_name/also_unlikely || framework_failure_ -env also_unlikely && fail=1 +returns_ 127 env also_unlikely || fail=1 test x$(PATH=$PATH:unlikely_name env also_unlikely) = xpass || fail=1 test x$(env PATH="$PATH":unlikely_name also_unlikely) = xpass || fail=1 diff --git a/tests/misc/false-status.sh b/tests/misc/false-status.sh index 0b72c6aad..03fe98c2e 100755 --- a/tests/misc/false-status.sh +++ b/tests/misc/false-status.sh @@ -20,12 +20,12 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ false true -env false --version > /dev/null && fail=1 -env false --help > /dev/null && fail=1 +returns_ 1 env false --version > /dev/null || fail=1 +returns_ 1 env false --help > /dev/null || fail=1 if test -w /dev/full && test -c /dev/full; then - env true --version > /dev/full && fail=1 - env true --help > /dev/full && fail=1 + returns_ 1 env true --version > /dev/full || fail=1 + returns_ 1 env true --help > /dev/full || fail=1 fi Exit $fail diff --git a/tests/misc/md5sum-bsd.sh b/tests/misc/md5sum-bsd.sh index 9031c1901..a092894b5 100755 --- a/tests/misc/md5sum-bsd.sh +++ b/tests/misc/md5sum-bsd.sh @@ -40,20 +40,20 @@ md5sum --strict -c check.md5 || fail=1 # then it'll be detected as standard format and error. # This unlikely caveat was thought better than mandating # an option to avoid the ambiguity. -tail -n+2 check.md5 | md5sum --strict -c && fail=1 +tail -n+2 check.md5 | returns_ 1 md5sum --strict -c || fail=1 ## BSD traditional format tests (--tag option) ## # Ensure --tag and --check are mutually exclusive -md5sum --tag --check /dev/null && fail=1 +returns_ 1 md5sum --tag --check /dev/null || fail=1 # Ensure --tag and --text are mutually exclusive # We don't support --text with BSD tradition format, # as that would complicate the output format, # while providing little benefit over --text processing # available with the default md5sum output format. -md5sum --tag --text /dev/null && fail=1 +returns_ 1 md5sum --tag --text /dev/null || fail=1 # Ensure we can --check BSD traditional format we produce rm check.md5 diff --git a/tests/misc/nproc-positive.sh b/tests/misc/nproc-positive.sh index a001d8049..fb825facb 100755 --- a/tests/misc/nproc-positive.sh +++ b/tests/misc/nproc-positive.sh @@ -35,7 +35,7 @@ for i in 0 ' 1' 1000; do done for i in -1 N; do - nproc --ignore=$i && fail=1 + returns_ 1 nproc --ignore=$i || fail=1 done procs=$(OMP_NUM_THREADS=42 nproc --ignore=40) diff --git a/tests/misc/pathchk1.sh b/tests/misc/pathchk1.sh index 74a1c850c..6c8a50883 100755 --- a/tests/misc/pathchk1.sh +++ b/tests/misc/pathchk1.sh @@ -25,14 +25,14 @@ touch file || framework_failure_ # This should exit nonzero. Before 2.0.13, it gave a diagnostic, # but exited successfully. -pathchk file/x > /dev/null 2>&1 && fail=1 +returns_ 1 pathchk file/x > /dev/null 2>&1 || fail=1 # This should exit nonzero. Through 5.3.0 it exited with status zero. -pathchk -p '' > /dev/null 2>&1 && fail=1 +returns_ 1 pathchk -p '' > /dev/null 2>&1 || fail=1 # This tests the new -P option. -pathchk -P '' > /dev/null 2>&1 && fail=1 -pathchk -P -- - > /dev/null 2>&1 && fail=1 -pathchk -p -P x/- > /dev/null 2>&1 && fail=1 +returns_ 1 pathchk -P '' > /dev/null 2>&1 || fail=1 +returns_ 1 pathchk -P -- - > /dev/null 2>&1 || fail=1 +returns_ 1 pathchk -p -P x/- > /dev/null 2>&1 || fail=1 Exit $fail diff --git a/tests/misc/printf.sh b/tests/misc/printf.sh index 142328595..87ca489f2 100755 --- a/tests/misc/printf.sh +++ b/tests/misc/printf.sh @@ -25,7 +25,9 @@ getlimits_ # Verify the 3 methods of specifying "Escape": -test $($prog "\x1b\n\33\n\e\n" | uniq -u) && fail=1 +printf '%s\n' . . . | tr . '\033' > exp +$prog '\x1b\n\33\n\e\n' > out || fail=1 +compare exp out || fail=1 # This would fail (by printing the '--') for printf in sh-utils # and in coreutils 4.5.1. @@ -68,17 +70,17 @@ $prog '8 %b %b %b %b\n' '\1y' '\01y' '\001y' '\0001y'|tr '\1' = >> out $prog '9 %*dx\n' -2 0 >>out || fail=1 $prog '10 %.*dx\n' $INT_UFLOW 0 >>out || fail=1 -$prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null && fail=1 +returns_ 1 $prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null || fail=1 $prog '11 %*c\n' 2 x >>out || fail=1 -$prog '%#d\n' 0 >>out 2> /dev/null && fail=1 +returns_ 1 $prog '%#d\n' 0 >>out 2> /dev/null || fail=1 -$prog '%0s\n' 0 >>out 2> /dev/null && fail=1 +returns_ 1 $prog '%0s\n' 0 >>out 2> /dev/null || fail=1 -$prog '%.9c\n' 0 >>out 2> /dev/null && fail=1 +returns_ 1 $prog '%.9c\n' 0 >>out 2> /dev/null || fail=1 -$prog '%'\''s\n' 0 >>out 2> /dev/null && fail=1 +returns_ 1 $prog '%'\''s\n' 0 >>out 2> /dev/null || fail=1 cat <<\EOF > exp 1 x y diff --git a/tests/misc/realpath.sh b/tests/misc/realpath.sh index 1d1d3ed75..ed4be3962 100755 --- a/tests/misc/realpath.sh +++ b/tests/misc/realpath.sh @@ -42,17 +42,17 @@ ln -s /// three || framework_failure_ # Basic operation realpath -Pqz . >/dev/null || fail=1 # Operand is required -realpath >/dev/null && fail=1 -realpath --relative-base . --relative-to . && fail=1 -realpath --relative-base . && fail=1 +returns_ 1 realpath >/dev/null || fail=1 +returns_ 1 realpath --relative-base . --relative-to . || fail=1 +returns_ 1 realpath --relative-base . || fail=1 # -e --relative-* require directories -realpath -e --relative-to=dir1/f --relative-base=. . && fail=1 +returns_ 1 realpath -e --relative-to=dir1/f --relative-base=. . || fail=1 realpath -e --relative-to=dir1/ --relative-base=. . || fail=1 # Note NUL params are unconditionally rejected by canonicalize_filename_mode -realpath -m '' && fail=1 -realpath --relative-base= --relative-to=. . && fail=1 +returns_ 1 realpath -m '' || fail=1 +returns_ 1 realpath --relative-base= --relative-to=. . || fail=1 # symlink resolution this=$(realpath .) diff --git a/tests/misc/selinux.sh b/tests/misc/selinux.sh index 0914f50dd..1f906dde9 100755 --- a/tests/misc/selinux.sh +++ b/tests/misc/selinux.sh @@ -47,7 +47,7 @@ c=$(ls -l f|cut -c11); test "$c" = . || fail=1 # Copy with an invalid context and ensure it fails # Note this may succeed when root and selinux is in permissive mode if test "$(getenforce)" = Enforcing; then - cp --context='invalid-selinux-context' f f.cp && fail=1 + returns_ 1 cp --context='invalid-selinux-context' f f.cp || fail=1 fi # Copy each to a new directory and ensure that context is preserved. diff --git a/tests/misc/shred-remove.sh b/tests/misc/shred-remove.sh index 8c04c26a3..cb27c1caf 100755 --- a/tests/misc/shred-remove.sh +++ b/tests/misc/shred-remove.sh @@ -30,7 +30,7 @@ chmod u-w $file || framework_failure_ # This would take so long that it appears to infloop # when using version from fileutils-4.0k. # When the command completes, expect it to fail. -shred -u $file > /dev/null 2>&1 && fail=1 +returns_ 1 shred -u $file > /dev/null 2>&1 || fail=1 rm -f $file || framework_failure_ # Ensure all --remove methods at least unlink the file @@ -42,6 +42,6 @@ done # Ensure incorrect params are diagnosed touch $file || framework_failure_ -shred -n0 --remove=none $file 2>/dev/null && fail=1 +returns_ 1 shred -n0 --remove=none $file 2>/dev/null || fail=1 Exit $fail diff --git a/tests/misc/sort-compress-proc.sh b/tests/misc/sort-compress-proc.sh index 719dfc6ca..a191a3c51 100755 --- a/tests/misc/sort-compress-proc.sh +++ b/tests/misc/sort-compress-proc.sh @@ -20,6 +20,8 @@ print_ver_ sort expensive_ +SORT_FAILURE=2 + seq -w 2000 > exp || fail=1 tac exp > in || fail=1 insize=$(stat -c %s - <in) || fail=1 @@ -52,7 +54,8 @@ do exec >/dev/null 2>&1 <&1 || exit expr $size "<" '"$insize"' / 2 || { sleep 1; exit 1; } } - ' sort --compress-program=./compress -S 1k --batch-size=2 in > out && fail=1 + ' sort --compress-program=./compress -S 1k --batch-size=2 in > out + test $? -eq $SORT_FAILURE || fail=1 done # "Pre-exec child" test diff --git a/tests/misc/sort-exit-early.sh b/tests/misc/sort-exit-early.sh index c2bc9949d..c675503c4 100755 --- a/tests/misc/sort-exit-early.sh +++ b/tests/misc/sort-exit-early.sh @@ -20,18 +20,18 @@ print_ver_ sort skip_if_root_ +SORT_FAILURE=2 + # Check output is writable before starting to sort touch input chmod a-w input -timeout 10 sort -o input && fail=1 -test $? = 124 && fail=1 +returns_ $SORT_FAILURE timeout 10 sort -o input || fail=1 # Check all inputs are readable before starting to sort # Also ensure the output isn't created in this case touch output chmod a-r output -timeout 10 sort -o typo - output && fail=1 -test $? = 124 && fail=1 +returns_ $SORT_FAILURE timeout 10 sort -o typo - output || fail=1 test -e typo && fail=1 Exit $fail diff --git a/tests/misc/stat-hyphen.sh b/tests/misc/stat-hyphen.sh index 2896bcb5b..a2e0a3fbd 100755 --- a/tests/misc/stat-hyphen.sh +++ b/tests/misc/stat-hyphen.sh @@ -23,7 +23,7 @@ printf -- '-\n' > exp || framework_failure_ touch f || framework_failure_ stat --format=%n - < f > out || fail=1 -stat -f - < f && fail=1 +returns_ 1 stat -f - < f || fail=1 compare exp out || fail=1 diff --git a/tests/misc/stat-slash.sh b/tests/misc/stat-slash.sh index 39cce2d75..fecb7b695 100755 --- a/tests/misc/stat-slash.sh +++ b/tests/misc/stat-slash.sh @@ -33,7 +33,7 @@ EOF # This failed on Solaris 9 for coreutils 8.0. stat --format=%n link1 > out || fail=1 -stat --format=%n link1/ >> out && fail=1 +returns_ 1 stat --format=%n link1/ >> out || fail=1 stat --format=%F link2 >> out || fail=1 stat -L --format=%F link2 >> out || fail=1 diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh index f14af840d..881146f65 100755 --- a/tests/misc/stty-invalid.sh +++ b/tests/misc/stty-invalid.sh @@ -34,8 +34,10 @@ stty $saved_state || fail=1 # For each of the following, with coreutils-6.9 and earlier, # stty would fail to diagnose the error on at least Solaris 10. hex_2_64=10000000000000000 -stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) 2>/dev/null && fail=1 -stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) 2>/dev/null && fail=1 +returns_ 1 stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) \ + 2>/dev/null || fail=1 +returns_ 1 stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) \ + 2>/dev/null || fail=1 # Just in case either of the above mistakenly succeeds (and changes # the state of our tty), try to restore the initial state. diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh index 787915b87..5c2575522 100755 --- a/tests/misc/stty.sh +++ b/tests/misc/stty.sh @@ -34,9 +34,9 @@ stty $(cat $saved_state) || fail=1 stty erase - || fail=1 # These would improperly ignore invalid options through coreutils 5.2.1. -stty -F 2>/dev/null && fail=1 -stty -raw -F no/such/file 2>/dev/null && fail=1 -stty -raw -a 2>/dev/null && fail=1 +returns_ 1 stty -F 2>/dev/null || fail=1 +returns_ 1 stty -raw -F no/such/file 2>/dev/null || fail=1 +returns_ 1 stty -raw -a 2>/dev/null || fail=1 # Build a list of all boolean options stty accepts on this system. # Don't depend on terminal width. Put each option on its own line, diff --git a/tests/misc/tr-case-class.sh b/tests/misc/tr-case-class.sh index 162b74f3a..07c376077 100755 --- a/tests/misc/tr-case-class.sh +++ b/tests/misc/tr-case-class.sh @@ -29,11 +29,11 @@ tr '[:lower:][:lower:]' '[:upper:]0-9' > out || fail=1 compare exp out || fail=1 # Validate the alignment of case classes -tr 'A-Z[:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 -tr '[:upper:][:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 -tr 'A-Y[:lower:]' 'a-z[:upper:]' < /dev/null && fail=1 -tr 'A-Z[:lower:]' '[:lower:][:upper:]' < /dev/null && fail=1 -tr 'A-Z[:lower:]' '[:lower:]A-Z' < /dev/null && fail=1 +returns_ 1 tr 'A-Z[:lower:]' 'a-y[:upper:]' </dev/null || fail=1 +returns_ 1 tr '[:upper:][:lower:]' 'a-y[:upper:]' </dev/null || fail=1 +returns_ 1 tr 'A-Y[:lower:]' 'a-z[:upper:]' </dev/null || fail=1 +returns_ 1 tr 'A-Z[:lower:]' '[:lower:][:upper:]' </dev/null || fail=1 +returns_ 1 tr 'A-Z[:lower:]' '[:lower:]A-Z' </dev/null || fail=1 tr '[:upper:][:lower:]' 'a-z[:upper:]' < /dev/null || fail=1 tr '[:upper:][:lower:]' '[:upper:]a-z' < /dev/null || fail=1 diff --git a/tests/misc/truncate-dir-fail.sh b/tests/misc/truncate-dir-fail.sh index b2e76772f..7787381ee 100755 --- a/tests/misc/truncate-dir-fail.sh +++ b/tests/misc/truncate-dir-fail.sh @@ -20,6 +20,6 @@ print_ver_ truncate # truncate on dir not allowed -truncate -s+0 . && fail=1 +returns_ 1 truncate -s+0 . || fail=1 Exit $fail diff --git a/tests/misc/truncate-overflow.sh b/tests/misc/truncate-overflow.sh index a4a513cf0..c690c4068 100755 --- a/tests/misc/truncate-overflow.sh +++ b/tests/misc/truncate-overflow.sh @@ -27,13 +27,13 @@ truncate -s-1 create-zero-len-file || fail=1 echo > non-empty-file # signed overflow -truncate -s$OFF_T_OFLOW file && fail=1 +returns_ 1 truncate -s$OFF_T_OFLOW file || fail=1 # += signed overflow -truncate -s+$OFF_T_MAX non-empty-file && fail=1 +returns_ 1 truncate -s+$OFF_T_MAX non-empty-file || fail=1 # *= signed overflow IO_BLOCK_OFLOW=$(expr $OFF_T_MAX / $(stat -f -c%s .) + 1) -truncate --io-blocks --size=$IO_BLOCK_OFLOW file && fail=1 +returns_ 1 truncate --io-blocks --size=$IO_BLOCK_OFLOW file || fail=1 Exit $fail diff --git a/tests/misc/truncate-parameters.sh b/tests/misc/truncate-parameters.sh index 62eb2c18f..d3cf59400 100755 --- a/tests/misc/truncate-parameters.sh +++ b/tests/misc/truncate-parameters.sh @@ -21,22 +21,22 @@ print_ver_ truncate # must specify at least 1 file -truncate --size=0 && fail=1 +returns_ 1 truncate --size=0 || fail=1 # must specify size. don't default to 0 -truncate file && fail=1 +returns_ 1 truncate file || fail=1 # mixture of absolute size & reference not allowed -truncate --size=0 --reference=file file && fail=1 +returns_ 1 truncate --size=0 --reference=file file || fail=1 # blocks without size is not valid -truncate --io-blocks --reference=file file && fail=1 +returns_ 1 truncate --io-blocks --reference=file file || fail=1 # must specify valid numbers -truncate --size="invalid" file && fail=1 +returns_ 1 truncate --size="invalid" file || fail=1 # spaces not significant around size -truncate --size="> -1" file && fail=1 +returns_ 1 truncate --size="> -1" file || fail=1 truncate --size=" >1" file || fail=1 #file now 1 truncate --size=" +1" file || fail=1 #file now 2 test $(stat --format %s file) = 2 || fail=1 diff --git a/tests/misc/truncate-relative.sh b/tests/misc/truncate-relative.sh index 933e76385..97be8cb7d 100755 --- a/tests/misc/truncate-relative.sh +++ b/tests/misc/truncate-relative.sh @@ -21,15 +21,15 @@ print_ver_ truncate # mixture of relative modifiers not allowed -truncate --size="+>0" file && fail=1 +returns_ 1 truncate --size="+>0" file || fail=1 # mixture of relative modifiers not allowed -truncate --size=">+0" file && fail=1 +returns_ 1 truncate --size=">+0" file || fail=1 # division by zero -truncate --size="/0" file && fail=1 +returns_ 1 truncate --size="/0" file || fail=1 # division by zero -truncate --size="%0" file && fail=1 +returns_ 1 truncate --size="%0" file || fail=1 Exit $fail diff --git a/tests/misc/wc-parallel.sh b/tests/misc/wc-parallel.sh index c522ea7d7..2d1e9f405 100755 --- a/tests/misc/wc-parallel.sh +++ b/tests/misc/wc-parallel.sh @@ -25,8 +25,9 @@ print_ver_ wc # This will output at least 16KiB per process # and start 3 processes, with 2 running concurrently, # which triggers often on Fedora 11 at least. -(find tmp tmp tmp -type f | xargs -n2000 -P2 wc) | +(find tmp tmp tmp -type f | xargs -n2000 -P2 wc 2>err) | sed -n '/0 0 0 /!p' | grep . > /dev/null && fail=1 +compare /dev/null err || fail=1 Exit $fail |