diff options
Diffstat (limited to 'tests')
92 files changed, 296 insertions, 259 deletions
diff --git a/tests/chmod/octal.sh b/tests/chmod/octal.sh index 6f47a076c..23d0542f7 100755 --- a/tests/chmod/octal.sh +++ b/tests/chmod/octal.sh @@ -22,8 +22,8 @@ print_ver_ chmod # Before coreutils-5.92, this would mistakenly succeed, # and act like 'chmod 0 .'. -chmod 0-followed-by-anything . 2> /dev/null && fail=1 -chmod 7-followed-by-anything . 2> /dev/null && fail=1 -chmod 8 . 2> /dev/null && fail=1 +for mode in '0-anything' '7-anything' '8'; do + returns_ 1 chmod "$mode" . 2>/dev/null || fail=1 +done Exit $fail diff --git a/tests/chmod/umask-x.sh b/tests/chmod/umask-x.sh index 85b087d05..f31452a3c 100755 --- a/tests/chmod/umask-x.sh +++ b/tests/chmod/umask-x.sh @@ -21,6 +21,6 @@ print_ver_ chmod touch file chmod 755 file -(umask 77 && chmod -x file) 2>/dev/null && fail=1 +(umask 77 && returns_ 1 chmod -x file) 2>/dev/null || fail=1 Exit $fail diff --git a/tests/chmod/usage.sh b/tests/chmod/usage.sh index 133115233..ac6d635ab 100755 --- a/tests/chmod/usage.sh +++ b/tests/chmod/usage.sh @@ -67,7 +67,7 @@ for case in $cases; do case $files in '') touch -- $all_files || framework_failure_ - chmod $args 2>/dev/null && fail=1 + returns_ 1 chmod $args 2>/dev/null || fail=1 ;; ?*) touch -- $files || framework_failure_ @@ -77,7 +77,7 @@ for case in $cases; do # chmod has a bug if it succeeds even though $file is absent. rm -f -- $all_files && touch -- $files && rm -- $file \ || framework_failure_ - chmod $args 2>/dev/null && fail=1 + returns_ 1 chmod $args 2>/dev/null || fail=1 done ;; esac diff --git a/tests/chown/basic.sh b/tests/chown/basic.sh index 3eee15694..e57b9c890 100755 --- a/tests/chown/basic.sh +++ b/tests/chown/basic.sh @@ -34,7 +34,7 @@ printf "ownership of 'f' retained as $(id -nu)\n" > exp compare exp out || fail=1 # Ensure diagnostics work for non existent files. -chown -v 0 nf > out && fail=1 +returns_ 1 chown -v 0 nf > out || fail=1 printf "failed to change ownership of 'nf' to 0\n" > exp compare exp out || fail=1 diff --git a/tests/chown/separator.sh b/tests/chown/separator.sh index 815533036..642b00238 100755 --- a/tests/chown/separator.sh +++ b/tests/chown/separator.sh @@ -59,7 +59,7 @@ for u in $id_u "$id_un" ''; do esac for sep in $seps; do case $u$sep$g in - [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;; + [0-9]*$sep) returns_ 1 chown "$u$sep$g" . 2>/dev/null || fail=1 ;; *) chown "$u$sep$g" . || fail=1 ;; esac done diff --git a/tests/cp/cp-HL.sh b/tests/cp/cp-HL.sh index fa9832537..08a72b13a 100755 --- a/tests/cp/cp-HL.sh +++ b/tests/cp/cp-HL.sh @@ -33,7 +33,7 @@ test -d dest-dir/src-dir || fail=1 cat dest-dir/slink > /dev/null 2>&1 || fail=1 # Expect this to fail since *this* slink is a dangling symlink. -cat dest-dir/src-dir/slink > /dev/null 2>&1 && fail=1 +returns_ 1 cat dest-dir/src-dir/slink >/dev/null 2>&1 || fail=1 # FIXME: test -L, too. diff --git a/tests/cp/cp-a-selinux.sh b/tests/cp/cp-a-selinux.sh index 2ecbd2386..d000ee8f1 100755 --- a/tests/cp/cp-a-selinux.sh +++ b/tests/cp/cp-a-selinux.sh @@ -49,14 +49,16 @@ rm -f f # in the destination, so SELinux contexts should be updated too. chmod o+rw restore/existing_dir mkdir -p backup/existing_dir/ || framework_failure_ -ls -Zd backup/existing_dir | grep $ctx && framework_failure_ +ls -Zd backup/existing_dir > ed_ctx || fail=1 +grep $ctx ed_ctx && framework_failure_ touch backup/existing_dir/file || framework_failure_ chcon $ctx backup/existing_dir/file || framework_failure_ # Set the dir context to ensure it is reset mkdir -p --context="$ctx" restore/existing_dir || framework_failure_ # Copy and ensure existing directories updated cp -a backup/. restore/ -ls -Zd restore/existing_dir | grep $ctx && +ls -Zd restore/existing_dir > ed_ctx || fail=1 +grep $ctx ed_ctx && { ls -lZd restore/existing_dir; fail=1; } # Check restorecon (-Z) functionality for file and directory @@ -175,6 +177,7 @@ for no_g_cmd in '' 'rm -f g'; do # restorecon equivalent. Note even though the context # returned from matchpathcon() will not match $ctx # the resulting ENOTSUP warning will be suppressed. + # With absolute path $no_g_cmd cp -Z ../f $(realpath g) || fail=1 @@ -186,7 +189,7 @@ for no_g_cmd in '' 'rm -f g'; do cp -Z -a ../f g || fail=1 # -Z doesn't take an arg $no_g_cmd - cp -Z "$ctx" ../f g && fail=1 + returns_ 1 cp -Z "$ctx" ../f g || fail=1 # Explicit context $no_g_cmd @@ -198,8 +201,8 @@ for no_g_cmd in '' 'rm -f g'; do done # Mutually exclusive options -cp -Z --preserve=context ../f g && fail=1 -cp --preserve=context -Z ../f g && fail=1 -cp --preserve=context --context="$ctx" ../f g && fail=1 +returns_ 1 cp -Z --preserve=context ../f g || fail=1 +returns_ 1 cp --preserve=context -Z ../f g || fail=1 +returns_ 1 cp --preserve=context --context="$ctx" ../f g || fail=1 Exit $fail diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh index d9d805116..e74141307 100755 --- a/tests/cp/cp-i.sh +++ b/tests/cp/cp-i.sh @@ -60,6 +60,6 @@ echo n | cp -vnf c d 2>/dev/null > out7 || fail=1 compare out7 out_empty || fail=1 # options --backup and --no-clobber are mutually exclusive -cp -bn c d 2>/dev/null && fail=1 +returns_ 1 cp -bn c d 2>/dev/null || fail=1 Exit $fail diff --git a/tests/cp/cp-parents.sh b/tests/cp/cp-parents.sh index 4814d6557..f0454f714 100755 --- a/tests/cp/cp-parents.sh +++ b/tests/cp/cp-parents.sh @@ -42,7 +42,7 @@ test -d d/a/b/c || fail=1 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a # directory d/f, even though f is a regular file. -cp --parents f/g d 2>/dev/null && fail=1 +returns_ 1 cp --parents f/g d 2>/dev/null || fail=1 test -d d/f && fail=1 # Check that re_protect works. diff --git a/tests/cp/dir-vs-file.sh b/tests/cp/dir-vs-file.sh index 826d9bce0..8ac159c04 100755 --- a/tests/cp/dir-vs-file.sh +++ b/tests/cp/dir-vs-file.sh @@ -24,7 +24,7 @@ touch file || framework_failure_ # In 4.0.35, this cp invocation silently succeeded. -cp -R dir file 2>/dev/null && fail=1 +returns_ 1 cp -R dir file 2>/dev/null || fail=1 # Make sure file is not replaced with a directory. # In 4.0.35, it was. diff --git a/tests/cp/fail-perm.sh b/tests/cp/fail-perm.sh index abc5e4ebe..6a9cc8804 100755 --- a/tests/cp/fail-perm.sh +++ b/tests/cp/fail-perm.sh @@ -27,7 +27,7 @@ chmod u=rx,go=,-st D || framework_failure_ # This is expected to exit non-zero, because it can't read D/a. -cp -pR D DD > /dev/null 2>&1 && fail=1 +returns_ 1 cp -pR D DD > /dev/null 2>&1 || fail=1 # Permissions on DD must be 'dr-x------' diff --git a/tests/cp/no-ctx.sh b/tests/cp/no-ctx.sh index 3cae58314..19d68b8ff 100755 --- a/tests/cp/no-ctx.sh +++ b/tests/cp/no-ctx.sh @@ -57,7 +57,7 @@ LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1 # ENODATA should give an immediate error when required to preserve ctx # This is debatable, and maybe we should not fail when no context available? -LD_PRELOAD=./k.so cp --preserve=context file_src file_dst && fail=1 +LD_PRELOAD=./k.so returns_ 1 cp --preserve=context file_src file_dst || fail=1 test -e preloaded || skip_ 'LD_PRELOAD interception failed' diff --git a/tests/cp/reflink-auto.sh b/tests/cp/reflink-auto.sh index 666620879..b0464a2eb 100755 --- a/tests/cp/reflink-auto.sh +++ b/tests/cp/reflink-auto.sh @@ -27,7 +27,7 @@ rm -f "$a_other" || framework_failure_ echo non_zero_size > "$a_other" || framework_failure_ # we shouldn't be able to reflink() files on separate partitions -cp --reflink "$a_other" b && fail=1 +returns_ 1 cp --reflink "$a_other" b || fail=1 # --reflink=auto should fall back to a normal copy cp --reflink=auto "$a_other" b || fail=1 diff --git a/tests/cp/sparse.sh b/tests/cp/sparse.sh index 3d6fb5876..958de8306 100755 --- a/tests/cp/sparse.sh +++ b/tests/cp/sparse.sh @@ -34,8 +34,8 @@ cp --sparse=always sparse copy || fail=1 test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1 # Ensure that --sparse={always,never} with --reflink fail. -cp --sparse=always --reflink sparse copy && fail=1 -cp --sparse=never --reflink sparse copy && fail=1 +returns_ 1 cp --sparse=always --reflink sparse copy || fail=1 +returns_ 1 cp --sparse=never --reflink sparse copy || fail=1 # Ensure we handle sparse/non-sparse transitions correctly diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh index 59f0f50a7..2a536e8d7 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 -compare /dev/null err && fail=1 +test -s err || fail=1 dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 compare $tmp_in $tmp_out || fail=1 @@ -61,12 +61,12 @@ case $(cat /dev/stdin <$tmp_in 2>/dev/null) in esac if dd iflag=nofollow if=$tmp_in count=0 2> /dev/null; then - dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null && fail=1 + returns_ 1 dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null || fail=1 fi if dd iflag=directory if=. count=0 2> /dev/null; then dd iflag=directory count=0 <. 2> /dev/null || fail=1 - dd iflag=directory count=0 <$tmp_in 2> /dev/null && fail=1 + returns_ 1 dd iflag=directory count=0 <$tmp_in 2> /dev/null || fail=1 fi old_ls=$(ls -u --full-time $tmp_in) @@ -87,8 +87,8 @@ EOF fi if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then - dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 && fail=1 - dd iflag=nolinks < $tmp_in > /dev/null 2>&1 && fail=1 + returns_ 1 dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 || fail=1 + returns_ 1 dd iflag=nolinks < $tmp_in > /dev/null 2>&1 || fail=1 dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1 fi diff --git a/tests/dd/nocache.sh b/tests/dd/nocache.sh index 33421480a..e7fdf4e5e 100755 --- a/tests/dd/nocache.sh +++ b/tests/dd/nocache.sh @@ -23,10 +23,10 @@ print_ver_ dd dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1 # We should get an error for trying to process a pipe -dd count=0 | dd iflag=nocache count=0 && fail=1 +dd count=0 | returns_ 1 dd iflag=nocache count=0 || fail=1 # O_DIRECT is orthogonal to drop cache so mutually exclusive -dd iflag=nocache,direct if=/dev/null && fail=1 +returns_ 1 dd iflag=nocache,direct if=/dev/null || fail=1 # The rest ensure that the documented uses cases # proceed without error diff --git a/tests/dd/stderr.sh b/tests/dd/stderr.sh index ce67a7a9e..82ab08f17 100755 --- a/tests/dd/stderr.sh +++ b/tests/dd/stderr.sh @@ -32,12 +32,12 @@ dd --help >/dev/null 2>&- || fail=1 # This exposes a failure present in 6.11 through 7.5. if "$p/src/test" -w /dev/stderr 2>/dev/null && "$p/src/test" ! -w /dev/stderr 2>&-; then - : | dd 2>&- && fail=1 + : | returns_ 1 dd 2>&- || fail=1 fi # Likewise for /dev/full, if /dev/full works. if test -w /dev/full && test -c /dev/full; then - : | dd 2>/dev/full && fail=1 + : | returns_ 1 dd 2>/dev/full || fail=1 fi Exit $fail diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh index d9899c4ad..0c1bec8ef 100755 --- a/tests/df/no-mtab-status.sh +++ b/tests/df/no-mtab-status.sh @@ -77,22 +77,22 @@ LD_PRELOAD=./k.so df -Ti '.' || fail=1 LD_PRELOAD=./k.so df --total '.' || fail=1 # These tests are supposed to fail: -LD_PRELOAD=./k.so df && fail=1 -LD_PRELOAD=./k.so df -i && fail=1 -LD_PRELOAD=./k.so df -T && fail=1 -LD_PRELOAD=./k.so df -Ti && fail=1 -LD_PRELOAD=./k.so df --total && fail=1 +LD_PRELOAD=./k.so returns_ 1 df || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -i || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -T || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -Ti || fail=1 +LD_PRELOAD=./k.so returns_ 1 df --total || fail=1 -LD_PRELOAD=./k.so df -a && fail=1 -LD_PRELOAD=./k.so df -a '.' && fail=1 +LD_PRELOAD=./k.so returns_ 1 df -a || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -a '.' || fail=1 -LD_PRELOAD=./k.so df -l && fail=1 -LD_PRELOAD=./k.so df -l '.' && fail=1 +LD_PRELOAD=./k.so returns_ 1 df -l || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -l '.' || fail=1 -LD_PRELOAD=./k.so df -t hello && fail=1 -LD_PRELOAD=./k.so df -t hello '.' && fail=1 +LD_PRELOAD=./k.so returns_ 1 df -t hello || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -t hello '.' || fail=1 -LD_PRELOAD=./k.so df -x hello && fail=1 -LD_PRELOAD=./k.so df -x hello '.' && fail=1 +LD_PRELOAD=./k.so returns_ 1 df -x hello || fail=1 +LD_PRELOAD=./k.so returns_ 1 df -x hello '.' || fail=1 Exit $fail diff --git a/tests/df/skip-rootfs.sh b/tests/df/skip-rootfs.sh index ed5364eb3..c42253dc3 100755 --- a/tests/df/skip-rootfs.sh +++ b/tests/df/skip-rootfs.sh @@ -34,7 +34,7 @@ grep '^rootfs' out && { fail=1; cat out; } # Ensure that rootfs is yet skipped when explicitly specifying "-t rootfs". # As df emits "no file systems processed" in this case, it would be a failure # if df exited with status Zero. -df -t rootfs >out && fail=1 +returns_ 1 df -t rootfs >out || fail=1 grep '^rootfs' out && { fail=1; cat out; } # Ensure that the rootfs is shown when explicitly both specifying "-t rootfs" diff --git a/tests/du/deref.sh b/tests/du/deref.sh index 670ee5cc6..6c2a47241 100755 --- a/tests/du/deref.sh +++ b/tests/du/deref.sh @@ -34,7 +34,7 @@ ln -s nowhere dangle || framework_failure_ du -sD slink b > /dev/null 2>&1 || fail=1 # This used to fail to report the dangling symlink. -du -L dangle > /dev/null 2>&1 && fail=1 +returns_ 1 du -L dangle > /dev/null 2>&1 || fail=1 # du -L used to mess up, either by counting the symlink's disk space itself # (-L should follow symlinks, not count their space) diff --git a/tests/id/context.sh b/tests/id/context.sh index 754d0c3ba..b1aefe73f 100755 --- a/tests/id/context.sh +++ b/tests/id/context.sh @@ -26,7 +26,10 @@ id | grep context= >/dev/null || fail=1 # Check with specified user, no context string should be present. # But if the current user is nameless, skip this part. -id -nu > /dev/null \ - && id $(id -nu) | grep context= >/dev/null && fail=1 +name=$(id -nu) || { test $? -ne 1 && fail=1; } +if test "$name"; then + id "$name" > id_name || fail=1 + grep context= id_name >/dev/null && fail=1 +fi Exit $fail diff --git a/tests/id/gnu-zero-uids.sh b/tests/id/gnu-zero-uids.sh index edd74f7dd..c2ee6cfb3 100755 --- a/tests/id/gnu-zero-uids.sh +++ b/tests/id/gnu-zero-uids.sh @@ -24,6 +24,6 @@ require_gnu_ sush - true || skip_ "the 'sush' command does not work" # Run 'id' with zero UIDs. It should exit with a non-zero status. -sush - id > out && fail=1 +returns_ 1 sush - id > out || fail=1 Exit $fail diff --git a/tests/id/uid.sh b/tests/id/uid.sh index c0766b321..e7a838586 100755 --- a/tests/id/uid.sh +++ b/tests/id/uid.sh @@ -22,7 +22,7 @@ uid=$(id -u) || fail=1 user=$(id -nu) || fail=1 # Ensure the empty user spec is discarded -id '' && fail=1 +returns_ 1 id '' || fail=1 for mode in '' '-G' '-g'; do id $mode $user > user_out || fail=1 # lookup name for comparison diff --git a/tests/id/zero.sh b/tests/id/zero.sh index a67a789e2..7bee3a644 100755 --- a/tests/id/zero.sh +++ b/tests/id/zero.sh @@ -51,8 +51,10 @@ while read u ; do printf '\n%s: ' "id -${o}${n}[z] $u" >> out || framework_failure_ # There may be no name corresponding to an id, so don't check # exit status when in name lookup mode - id -${o}${n} $u >> exp || { test -z "$n" && fail=1; } - id -${o}${n}z $u > tmp || { test -z "$n" && fail=1; } + id -${o}${n} $u >> exp || + { test $? -ne 1 || test -z "$n" && fail=1; } + id -${o}${n}z $u > tmp || + { test $? -ne 1 || test -z "$n" && fail=1; } head -c-1 < tmp >> out || framework_failure_ done done diff --git a/tests/init.sh b/tests/init.sh index 37fc7b62e..added1760 100755 --- a/tests/init.sh +++ b/tests/init.sh @@ -93,6 +93,19 @@ skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } +# This is used to simplify checking of the return value +# which is useful when ensuring a command fails as desired. +# I.E. just doing `command ... &&fail=1` will not catch +# a segfault in command for example. With this helper you +# instead check an explicit exit code like +# returns_ 1 command ... || fail +returns_ () { + local exp_exit="$1" + shift + "$@" + test $? -eq $exp_exit +} + # Sanitize this shell to POSIX mode, if possible. DUALCASE=1; export DUALCASE if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh index 3a1bfae8d..db3b3c31d 100755 --- a/tests/install/basic-1.sh +++ b/tests/install/basic-1.sh @@ -80,8 +80,8 @@ iwd=$(pwd) mkdir sub || fail=1 (cd sub && chmod 0 . && - ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null -) && fail=1 + returns_ 1 ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null +) || fail=1 chmod 755 sub # Ensure that the first argument-dir has been created. diff --git a/tests/install/install-C.sh b/tests/install/install-C.sh index 214e3ae14..630005c89 100755 --- a/tests/install/install-C.sh +++ b/tests/install/install-C.sh @@ -107,9 +107,9 @@ ginstall -Cv -m$mode2 a b > out || fail=1 compare out out_empty || fail=1 # options -C and --preserve-timestamps are mutually exclusive -ginstall -C --preserve-timestamps a b && fail=1 +returns_ 1 ginstall -C --preserve-timestamps a b || fail=1 # options -C and --strip are mutually exclusive -ginstall -C --strip --strip-program=echo a b && fail=1 +returns_ 1 ginstall -C --strip --strip-program=echo a b || fail=1 Exit $fail diff --git a/tests/install/strip-program.sh b/tests/install/strip-program.sh index 1350e30d2..7ac2165ea 100755 --- a/tests/install/strip-program.sh +++ b/tests/install/strip-program.sh @@ -34,7 +34,7 @@ ginstall src dest -s --strip-program=./b || fail=1 compare exp dest || fail=1 # Check that install cleans up properly if strip fails. -ginstall src dest2 -s --strip-program=./FOO && fail=1 +returns_ 1 ginstall src dest2 -s --strip-program=./FOO || fail=1 test -e dest2 && fail=1 Exit $fail diff --git a/tests/ln/misc.sh b/tests/ln/misc.sh index 9b23fdab4..68756309a 100755 --- a/tests/ln/misc.sh +++ b/tests/ln/misc.sh @@ -52,20 +52,20 @@ rm -rf $d $f touch $f || framework_failure_ rm -rf $d || framework_failure_ mkdir $d $d/$f || framework_failure_ -ln $f $d/ 2> /dev/null && fail=1 -ln -s $f $d/ 2> /dev/null && fail=1 +returns_ 1 ln $f $d/ 2> /dev/null || fail=1 +returns_ 1 ln -s $f $d/ 2> /dev/null || fail=1 rm -rf $d $f # Make sure we get a failure with existing dest without -f option touch $t || framework_failure_ # FIXME: don't ignore the error message but rather test # it to make sure it's the right one. -ln -s $t $t 2> /dev/null && fail=1 +returns_ 1 ln -s $t $t 2> /dev/null || fail=1 rm $t # Make sure -sf fails when src and dest are the same touch $t || framework_failure_ -ln -sf $t $t 2> /dev/null && fail=1 +returns_ 1 ln -sf $t $t 2> /dev/null || fail=1 rm $t # Create a symlink with source file and no explicit directory diff --git a/tests/ln/slash-decorated-nonexistent-dest.sh b/tests/ln/slash-decorated-nonexistent-dest.sh index dc5b18994..7a0696f2f 100755 --- a/tests/ln/slash-decorated-nonexistent-dest.sh +++ b/tests/ln/slash-decorated-nonexistent-dest.sh @@ -23,7 +23,7 @@ touch f || framework_failure_ # Before coreutils-7.6, this would succeed on Solaris 10 -ln -T f no-such-file/ && fail=1 +returns_ 1 ln -T f no-such-file/ || fail=1 test -e no-such-file && fail=1 Exit $fail diff --git a/tests/ls/dangle.sh b/tests/ls/dangle.sh index 1f1849d2b..d27f03fe5 100755 --- a/tests/ls/dangle.sh +++ b/tests/ls/dangle.sh @@ -19,6 +19,9 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ ls +LS_MINOR_PROBLEM=1 +LS_FAILURE=2 + ln -s no-such-file dangle || framework_failure_ mkdir -p dir/sub || framework_failure_ ln -s dir slink-to-dir || framework_failure_ @@ -27,11 +30,10 @@ ln -s no-such d/dangle || framework_failure_ printf '? dangle\n' > subdir_Li_exp || framework_failure_ printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure_ - # This must exit nonzero. -ls -L dangle > /dev/null 2>&1 && fail=1 +returns_ $LS_FAILURE ls -L dangle > /dev/null 2>&1 || fail=1 # So must this. -ls -H dangle > /dev/null 2>&1 && fail=1 +returns_ $LS_FAILURE ls -H dangle > /dev/null 2>&1 || fail=1 # This must exit successfully. ls dangle >> out || fail=1 @@ -51,12 +53,12 @@ compare exp out || fail=1 # Ensure that ls -Li prints "?" as the inode of a dangling symlink. rm -f out -ls -Li d > out 2>/dev/null && fail=1 +returns_ $LS_MINOR_PROBLEM ls -Li d > out 2>/dev/null || fail=1 compare subdir_Li_exp out || fail=1 # Ensure that ls -Ls prints "?" as the allocation of a dangling symlink. rm -f out -ls -Ls d > out 2>/dev/null && fail=1 +returns_ $LS_MINOR_PROBLEM ls -Ls d > out 2>/dev/null || fail=1 compare subdir_Ls_exp out || fail=1 Exit $fail diff --git a/tests/ls/follow-slink.sh b/tests/ls/follow-slink.sh index 58d77fba4..edf6a4810 100755 --- a/tests/ls/follow-slink.sh +++ b/tests/ls/follow-slink.sh @@ -19,6 +19,8 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ ls +LS_FAILURE=2 + # Isolate output files from directory being listed mkdir dir dir/sub dir1 || framework_failure_ cd dir || framework_failure_ @@ -32,7 +34,7 @@ ls -F link > /dev/null || framework_failure_ # When explicitly listing a broken link, the command must fail. -ls -L link 2> /dev/null && fail=1 +returns_ $LS_FAILURE ls -L link 2> /dev/null || fail=1 # When encountering a broken link implicitly, Solaris 9 and OpenBSD 3.4 # list the link, provided no further information about the link needed diff --git a/tests/ls/stat-failed.sh b/tests/ls/stat-failed.sh index cb8b3bd26..002b71cf4 100755 --- a/tests/ls/stat-failed.sh +++ b/tests/ls/stat-failed.sh @@ -21,6 +21,8 @@ print_ver_ ls skip_if_root_ +LS_MINOR_PROBLEM=1 + mkdir d || framework_failure_ ln -s / d/s || framework_failure_ chmod 600 d || framework_failure_ @@ -38,7 +40,7 @@ sed 's/^l/?/' out | compare exp - || fail=1 # Ensure that the offsets in --dired output are accurate. rm -f out exp -ls --dired -l d > out && fail=1 +returns_ $LS_MINOR_PROBLEM ls --dired -l d > out || fail=1 cat <<\EOF > exp || fail=1 total 0 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 diff --git a/tests/mkdir/p-3.sh b/tests/mkdir/p-3.sh index 6ffa533a2..199e7e1de 100755 --- a/tests/mkdir/p-3.sh +++ b/tests/mkdir/p-3.sh @@ -27,7 +27,8 @@ mkdir no-acce2s || framework_failure_ mkdir -p no-acce3s/d || framework_failure_ p=$(pwd) -(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1 +(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null +test $? -eq 1 || fail=1 test -d "$p/a/b" || fail=1 # Same as above, but with a following *absolute* name, it should succeed diff --git a/tests/mkdir/parents.sh b/tests/mkdir/parents.sh index 2bc5419ba..ebdb52713 100755 --- a/tests/mkdir/parents.sh +++ b/tests/mkdir/parents.sh @@ -26,7 +26,7 @@ mkdir -m 700 e-dir || framework_failure_ # Make sure 'mkdir -p existing-dir' succeeds # and that 'mkdir existing-dir' fails. mkdir -p e-dir || fail=1 -mkdir e-dir > /dev/null 2>&1 && fail=1 +returns_ 1 mkdir e-dir > /dev/null 2>&1 || fail=1 # Create an existing directory. umask 077 diff --git a/tests/mkdir/perm.sh b/tests/mkdir/perm.sh index ab78f1f89..ff0a57dce 100755 --- a/tests/mkdir/perm.sh +++ b/tests/mkdir/perm.sh @@ -59,7 +59,7 @@ for p in empty -p; do # If we're not using -p, then create the parent manually, # and adjust expectations accordingly. - test x$p = x && \ + test x$p = x && { mkdir -m =,u=rwx parent || fail=1 parent_perms=drwx------ diff --git a/tests/mkdir/special-1.sh b/tests/mkdir/special-1.sh index 94b6f8c34..a6ba642f8 100755 --- a/tests/mkdir/special-1.sh +++ b/tests/mkdir/special-1.sh @@ -36,7 +36,7 @@ rmdir $tmp || fail=1 tmp2=$tmp/sub # This should fail. -mkdir -m$set_mode_string $tmp2 2> /dev/null && fail=1 +returns_ 1 mkdir -m$set_mode_string $tmp2 2> /dev/null || fail=1 # Now test the --parents option. mkdir --parents -m$set_mode_string $tmp2 || fail=1 diff --git a/tests/mv/childproof.sh b/tests/mv/childproof.sh index bb7e661c3..cc879ff19 100755 --- a/tests/mv/childproof.sh +++ b/tests/mv/childproof.sh @@ -28,7 +28,7 @@ echo a > a/f || framework_failure_ echo b > b/f || framework_failure_ -cp a/f b/f c 2> /dev/null && fail=1 +returns_ 1 cp a/f b/f c 2> /dev/null || fail=1 test -f a/f || fail=1 test -f b/f || fail=1 test -f c/f || fail=1 @@ -43,7 +43,7 @@ test -f c/f || fail=1 test -f c/f.~1~ || fail=1 rm -f c/f* -mv a/f b/f c 2> /dev/null && fail=1 +returns_ 1 mv a/f b/f c 2> /dev/null || fail=1 test -f a/f && fail=1 test -f b/f || fail=1 test -f c/f || fail=1 @@ -62,7 +62,7 @@ test -f c/f || fail=1 test -f c/g || fail=1 touch a/f b/f b/g -mv a/f b/f b/g c 2> /dev/null && fail=1 +returns_ 1 mv a/f b/f b/g c 2> /dev/null || fail=1 test -f a/f && fail=1 # a/f should have been moved test -f b/f || fail=1 # b/f should remain test -f b/g && fail=1 # b/g should have been moved @@ -74,7 +74,7 @@ test -f c/g || fail=1 rm -f a/f b/f c/f echo a > a/f || fail=1 echo b > b/f || fail=1 -ln -f a/f b/f c 2> /dev/null && fail=1 +returns_ 1 ln -f a/f b/f c 2> /dev/null || fail=1 # a/f and c/f must be linked test $(stat --format %i a/f) = $(stat --format %i c/f) || fail=1 # b/f and c/f must not be linked diff --git a/tests/mv/dir-file.sh b/tests/mv/dir-file.sh index 36b1a7dcf..7b798ed6f 100755 --- a/tests/mv/dir-file.sh +++ b/tests/mv/dir-file.sh @@ -24,7 +24,7 @@ mkdir -p dir/file || framework_failure_ # These should both fail, but until fileutils-4.0q only the second one did. -mv dir file > /dev/null 2>&1 && fail=1 -mv file dir > /dev/null 2>&1 && fail=1 +returns_ 1 mv dir file > /dev/null 2>&1 || fail=1 +returns_ 1 mv file dir > /dev/null 2>&1 || fail=1 Exit $fail diff --git a/tests/mv/hardlink-case.sh b/tests/mv/hardlink-case.sh index 4a0b2a54f..3e51c38a5 100755 --- a/tests/mv/hardlink-case.sh +++ b/tests/mv/hardlink-case.sh @@ -31,7 +31,7 @@ mount hfs.img mnt || skip_ 'failed to mount hfs file system' cd mnt touch foo ln foo whatever -mv foo Foo && fail=1 +returns_ 1 mv foo Foo || fail=1 test -r foo || fail=1 Exit $fail diff --git a/tests/mv/into-self-4.sh b/tests/mv/into-self-4.sh index fe0322ea5..2ae0468fd 100755 --- a/tests/mv/into-self-4.sh +++ b/tests/mv/into-self-4.sh @@ -25,7 +25,7 @@ ln -s file s || framework_failure_ # This must fail. -mv s s 2> /dev/null && fail=1 +returns_ 1 mv s s 2> /dev/null || fail=1 # But the symlink, s, must not be removed. # Before 4.0.36, 's' would have been removed. diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh index 97133339c..8c3fedb81 100755 --- a/tests/mv/mv-n.sh +++ b/tests/mv/mv-n.sh @@ -52,6 +52,6 @@ compare out5 out_empty || fail=1 # options --backup and --no-clobber are mutually exclusive touch a || framework_failure_ -mv -bn a b 2>/dev/null && fail=1 +returns_ 1 mv -bn a b 2>/dev/null || fail=1 Exit $fail diff --git a/tests/mv/no-target-dir.sh b/tests/mv/no-target-dir.sh index 9f8ece0a1..d7bca59b1 100755 --- a/tests/mv/no-target-dir.sh +++ b/tests/mv/no-target-dir.sh @@ -20,6 +20,8 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ mv +LS_FAILURE=2 + mkdir -p d/sub empty src d2/sub e2 || framework_failure_ touch f || framework_failure_ @@ -35,15 +37,15 @@ mv a b || mv -fT d empty || fail=1 # Ensure that the source, d, is gone. -ls -d d > /dev/null 2>&1 && fail=1 +returns_ $LS_FAILURE ls -d d > /dev/null 2>&1 || fail=1 # Ensure that the dest dir now has a subdirectory. test -d empty/sub || fail=1 # rename must fail, since the dest is non-empty. -mv -fT src d2 2> /dev/null && fail=1 +returns_ 1 mv -fT src d2 2> /dev/null || fail=1 # rename must fail, since the src is not a directory. -mv -fT f e2 2> /dev/null && fail=1 +returns_ 1 mv -fT f e2 2> /dev/null || fail=1 Exit $fail diff --git a/tests/mv/part-rename.sh b/tests/mv/part-rename.sh index da88260a8..b84f68864 100755 --- a/tests/mv/part-rename.sh +++ b/tests/mv/part-rename.sh @@ -31,13 +31,13 @@ mv foo/ "$other_partition_tmpdir/bar" || fail=1 # Moving a non directory from source shouldn't replace empty dir in dest touch bar || framework_failure_ -mv bar "$other_partition_tmpdir/" && fail=1 +returns_ 1 mv bar "$other_partition_tmpdir/" || fail=1 # Moving a directory from source shouldn't replace non directory in dest mkdir bar2 touch "$other_partition_tmpdir/bar2" -mv bar2 "$other_partition_tmpdir/" && fail=1 +returns_ 1 mv bar2 "$other_partition_tmpdir/" || fail=1 # As per POSIX moving directory from source should replace empty dir in dest @@ -51,7 +51,7 @@ test -e "$other_partition_tmpdir/bar3/file" || fail=1 # As per POSIX moving directory from source shouldn't update dir in dest mkdir bar3 touch bar3/file2 -mv bar3 "$other_partition_tmpdir/" && fail=1 +returns_ 1 mv bar3 "$other_partition_tmpdir/" || fail=1 test -e "$other_partition_tmpdir/bar3/file2" && fail=1 Exit $fail diff --git a/tests/mv/trailing-slash.sh b/tests/mv/trailing-slash.sh index da2d95d1a..47335d3ca 100755 --- a/tests/mv/trailing-slash.sh +++ b/tests/mv/trailing-slash.sh @@ -48,14 +48,14 @@ done # underlying rename syscall handles the trailing slash. # It does fail, as desired, on recent Linux and Solaris systems. #touch a a2 -#mv a a2/ && fail=1 +#returns_ 1 mv a a2/ || fail=1 # Test for a cp-specific diagnostic introduced after coreutils-8.7: printf '%s\n' \ "cp: cannot create regular file 'no-such/': Not a directory" \ > expected-err touch b -cp b no-such/ 2> err && fail=1 +cp b no-such/ 2> err # Map "No such file..." diagnostic to the expected "Not a directory" sed 's/No such file or directory/Not a directory/' err > k && mv k err diff --git a/tests/readlink/can-e.sh b/tests/readlink/can-e.sh index 91bea7807..05f297b7c 100755 --- a/tests/readlink/can-e.sh +++ b/tests/readlink/can-e.sh @@ -38,7 +38,7 @@ cd "$pwd/$tmp/removed" || framework_failure_ # Skip this test if the system doesn't let you remove the working directory. if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 + v=$(returns_ 1 readlink -e .) || fail=1 test -z "$v" || fail=1 fi @@ -49,7 +49,7 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -e "${p}regfile") || fail=1 test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - v=$(readlink -e "${p}./regfile/") && fail=1 + v=$(returns_ 1 readlink -e "${p}./regfile/") || fail=1 test -z "$v" || fail=1 v=$(readlink -e "${p}subdir") || fail=1 @@ -58,19 +58,19 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -e "${p}./subdir/") || fail=1 test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - v=$(readlink -e "${p}missing") && fail=1 + v=$(returns_ 1 readlink -e "${p}missing") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}./missing/") && fail=1 + v=$(returns_ 1 readlink -e "${p}./missing/") || fail=1 test -z "$v" || fail=1 v=$(readlink -e "${p}link1") || fail=1 test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - v=$(readlink -e "${p}./link1/") && fail=1 + v=$(returns_ 1 readlink -e "${p}./link1/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}link1/more") && fail=1 + v=$(returns_ 1 readlink -e "${p}link1/more") || fail=1 test -z "$v" || fail=1 v=$(readlink -e "${p}link2") || fail=1 @@ -79,25 +79,25 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -e "${p}./link2/") || fail=1 test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - v=$(readlink -e "${p}link2/more") && fail=1 + v=$(returns_ 1 readlink -e "${p}link2/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}link3") && fail=1 + v=$(returns_ 1 readlink -e "${p}link3") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}./link3/") && fail=1 + v=$(returns_ 1 readlink -e "${p}./link3/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}link3/more") && fail=1 + v=$(returns_ 1 readlink -e "${p}link3/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}link4") && fail=1 + v=$(returns_ 1 readlink -e "${p}link4") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}./link4/") && fail=1 + v=$(returns_ 1 readlink -e "${p}./link4/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -e "${p}link4/more") && fail=1 + v=$(returns_ 1 readlink -e "${p}link4/more") || fail=1 test -z "$v" || fail=1 done diff --git a/tests/readlink/can-f.sh b/tests/readlink/can-f.sh index 44697225e..4b25fc63d 100755 --- a/tests/readlink/can-f.sh +++ b/tests/readlink/can-f.sh @@ -39,7 +39,7 @@ cd "$pwd/$tmp/removed" || framework_failure_ # Skip this test if the system doesn't let you remove the working directory. if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 + v=$(returns_ 1 readlink -e .) || fail=1 test -z "$v" || fail=1 fi @@ -50,13 +50,13 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -f "${p}regfile") || fail=1 test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - v=$(readlink -f "${p}./regfile/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./regfile/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}regfile/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}regfile/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./regfile/more/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./regfile/more/") || fail=1 test -z "$v" || fail=1 v=$(readlink -f "${p}subdir") || fail=1 @@ -77,22 +77,22 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -f "${p}./missing/") || fail=1 test "$v" = "$my_pwd/$tmp/missing" || fail=1 - v=$(readlink -f "${p}missing/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}missing/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./missing/more/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./missing/more/") || fail=1 test -z "$v" || fail=1 v=$(readlink -f "${p}link1") || fail=1 test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - v=$(readlink -f "${p}./link1/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link1/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}link1/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}link1/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link1/more/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link1/more/") || fail=1 test -z "$v" || fail=1 v=$(readlink -f "${p}link2") || fail=1 @@ -107,10 +107,10 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -f "${p}./link2/more/") || fail=1 test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - v=$(readlink -f "${p}link2/more/more2") && fail=1 + v=$(returns_ 1 readlink -f "${p}link2/more/more2") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link2/more/more2/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link2/more/more2/") || fail=1 test -z "$v" || fail=1 v=$(readlink -f "${p}link3") || fail=1 @@ -119,10 +119,10 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -f "${p}./link3/") || fail=1 test "$v" = "$my_pwd/$tmp/missing" || fail=1 - v=$(readlink -f "${p}link3/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}link3/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link3/more/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link3/more/") || fail=1 test -z "$v" || fail=1 v=$(readlink -f "${p}link4") || fail=1 @@ -131,22 +131,22 @@ for p in "" "$pwd/$tmp/"; do v=$(readlink -f "${p}./link4/") || fail=1 test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 - v=$(readlink -f "${p}link4/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}link4/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link4/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link4/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}link5") && fail=1 + v=$(returns_ 1 readlink -f "${p}link5") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link5/") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link5/") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}link5/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}link5/more") || fail=1 test -z "$v" || fail=1 - v=$(readlink -f "${p}./link5/more") && fail=1 + v=$(returns_ 1 readlink -f "${p}./link5/more") || fail=1 test -z "$v" || fail=1 done diff --git a/tests/readlink/can-m.sh b/tests/readlink/can-m.sh index 6d8ca8197..2eb13565a 100755 --- a/tests/readlink/can-m.sh +++ b/tests/readlink/can-m.sh @@ -38,7 +38,7 @@ cd "$pwd/$tmp/removed" || framework_failure_ # Skip this test if the system doesn't let you remove the working directory. if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 + v=$(returns_ 1 readlink -e .) || fail=1 test -z "$v" || fail=1 fi diff --git a/tests/readlink/multi.sh b/tests/readlink/multi.sh index 17aab4059..c7c2ef711 100755 --- a/tests/readlink/multi.sh +++ b/tests/readlink/multi.sh @@ -23,8 +23,8 @@ touch regfile || framework_failure_ ln -s regfile link1 || framework_failure_ readlink link1 link1 || fail=1 -readlink link1 link2 && fail=1 -readlink link1 link2 link1 && fail=1 +returns_ 1 readlink link1 link2 || fail=1 +returns_ 1 readlink link1 link2 link1 || fail=1 readlink -m link1 link2 || fail=1 printf '/1\0/1\0' > exp || framework_failure_ diff --git a/tests/readlink/rl-1.sh b/tests/readlink/rl-1.sh index a6b92c747..5b429edec 100755 --- a/tests/readlink/rl-1.sh +++ b/tests/readlink/rl-1.sh @@ -31,13 +31,13 @@ test "$v" = regfile || fail=1 v=$(readlink link2) || fail=1 test "$v" = missing || fail=1 -v=$(readlink subdir) && fail=1 +v=$(returns_ 1 readlink subdir) || fail=1 test -z "$v" || fail=1 -v=$(readlink regfile) && fail=1 +v=$(returns_ 1 readlink regfile) || fail=1 test -z "$v" || fail=1 -v=$(readlink missing) && fail=1 +v=$(returns_ 1 readlink missing) || fail=1 test -z "$v" || fail=1 Exit $fail diff --git a/tests/rm/i-no-r.sh b/tests/rm/i-no-r.sh index e7f7196aa..22819ab6f 100755 --- a/tests/rm/i-no-r.sh +++ b/tests/rm/i-no-r.sh @@ -26,7 +26,7 @@ echo y > y || framework_failure_ # This must fail. -rm -i dir < y > /dev/null 2>&1 && fail=1 +returns_ 1 rm -i dir < y > /dev/null 2>&1 || fail=1 # The directory must remain. test -d dir || fail=1 diff --git a/tests/rm/no-give-up.sh b/tests/rm/no-give-up.sh index b7b5b0eda..a5134d760 100755 --- a/tests/rm/no-give-up.sh +++ b/tests/rm/no-give-up.sh @@ -30,8 +30,8 @@ chmod go=x . || framework_failure_ # This must fail, since '.' is not writable by $NON_ROOT_USERNAME. -chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ - rm -rf d 2>/dev/null && fail=1 +returns_ 1 chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ + rm -rf d 2>/dev/null || fail=1 # d must remain. test -d d || fail=1 diff --git a/tests/rm/r-4.sh b/tests/rm/r-4.sh index de3da0cf7..91a8b58aa 100755 --- a/tests/rm/r-4.sh +++ b/tests/rm/r-4.sh @@ -43,8 +43,8 @@ rmtest 'd/..' || fail=1 rmtest 'd/../' || fail=1 -# This test is too dangerous -- if there's a bug you're wiped out! -# rm -fr / 2>/dev/null && fail=1 +# This test is handled more carefully in r-root.sh +# returns_ 1 rm -fr / 2>/dev/null || fail=1 test -f d/a || fail=1 diff --git a/tests/rm/r-root.sh b/tests/rm/r-root.sh index 179edf6ff..e8fe714af 100755 --- a/tests/rm/r-root.sh +++ b/tests/rm/r-root.sh @@ -143,8 +143,7 @@ for opts in \ 'rootlink2/' \ 'rootlink3/' ; do - exercise_rm_r_root $opts \ - && fail=1 + returns_ 1 exercise_rm_r_root $opts || fail=1 # For some of the synonyms, the error diagnostic slightly differs from that # of the basic "/" case (see gnulib's fts_open' and ROOT_DEV_INO_WARN): @@ -178,8 +177,7 @@ done # by setting the following variable. CU_TEST_SKIP_EXIT=1 -exercise_rm_r_root --preserve-root file1 '/' file2 \ - && fail=1 +returns_ 1 exercise_rm_r_root --preserve-root file1 '/' file2 || fail=1 unset CU_TEST_SKIP_EXIT @@ -219,8 +217,7 @@ for file in \ test -d "$file" || continue # if e.g. /etc does not exist. - exercise_rm_r_root --preserve-root "$file" \ - && fail=1 + returns_ 1 exercise_rm_r_root --preserve-root "$file" || fail=1 grep "^rm: refusing to remove '\.' or '\.\.' directory: skipping" err \ || fail=1 @@ -244,8 +241,7 @@ exercise_rm_r_root --interactive=never --no-preserve-root '/' \ || fail=1 # The 'err' file should not contain the above error diagnostic. -grep "^rm: it is dangerous to operate recursively on '/'" err \ - && fail=1 +grep "^rm: it is dangerous to operate recursively on '/'" err && fail=1 # Instead, rm(1) should have called the intercepted unlinkat() function, # i.e. the evidence file "x" should exist. diff --git a/tests/rm/rm4.sh b/tests/rm/rm4.sh index 28ff20bdf..e0f141fd4 100755 --- a/tests/rm/rm4.sh +++ b/tests/rm/rm4.sh @@ -24,7 +24,7 @@ mkdir dir || framework_failure_ # This should fail. -rm dir > /dev/null 2>&1 && fail=1 +returns_ 1 rm dir > /dev/null 2>&1 || fail=1 test -d dir || fail=1 diff --git a/tests/rm/sunos-1.sh b/tests/rm/sunos-1.sh index d2468217b..db4221f03 100755 --- a/tests/rm/sunos-1.sh +++ b/tests/rm/sunos-1.sh @@ -24,6 +24,6 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ rm -rm -r '' > /dev/null 2>&1 && fail=1 +returns_ 1 rm -r '' > /dev/null 2>&1 || fail=1 Exit $fail diff --git a/tests/rmdir/fail-perm.sh b/tests/rmdir/fail-perm.sh index 4026201e3..985cb23bb 100755 --- a/tests/rmdir/fail-perm.sh +++ b/tests/rmdir/fail-perm.sh @@ -27,6 +27,6 @@ chmod a-w d || framework_failure_ # This rmdir command outputs two diagnostics. # Before coreutils-5.1.2, it would mistakenly exit successfully. # As of coreutils-5.1.2, it fails, as required. -rmdir -p d d/e/f 2> /dev/null && fail=1 +returns_ 1 rmdir -p d d/e/f 2> /dev/null || fail=1 Exit $fail diff --git a/tests/split/additional-suffix.sh b/tests/split/additional-suffix.sh index 9195915fa..79a3f9727 100755 --- a/tests/split/additional-suffix.sh +++ b/tests/split/additional-suffix.sh @@ -39,6 +39,6 @@ compare exp-2 xab.txt || fail=1 compare exp-3 xac.txt || fail=1 # Additional suffix must not contain slash -split --lines=2 --additional-suffix=a/b in 2>/dev/null > out && fail=1 +returns_ 1 split --lines=2 --additional-suffix=a/b in 2>/dev/null >out || fail=1 Exit $fail diff --git a/tests/split/fail.sh b/tests/split/fail.sh index 67259956c..e8f7bc3cf 100755 --- a/tests/split/fail.sh +++ b/tests/split/fail.sh @@ -24,13 +24,13 @@ touch in || framework_failure_ split -a 0 in 2> /dev/null || fail=1 -split -b 0 in 2> /dev/null && fail=1 -split -C 0 in 2> /dev/null && fail=1 -split -l 0 in 2> /dev/null && fail=1 -split -n 0 in 2> /dev/null && fail=1 -split -n 1/0 in 2> /dev/null && fail=1 -split -n 0/1 in 2> /dev/null && fail=1 -split -n 2/1 in 2> /dev/null && fail=1 +returns_ 1 split -b 0 in 2> /dev/null || fail=1 +returns_ 1 split -C 0 in 2> /dev/null || fail=1 +returns_ 1 split -l 0 in 2> /dev/null || fail=1 +returns_ 1 split -n 0 in 2> /dev/null || fail=1 +returns_ 1 split -n 1/0 in 2> /dev/null || fail=1 +returns_ 1 split -n 0/1 in 2> /dev/null || fail=1 +returns_ 1 split -n 2/1 in 2> /dev/null || fail=1 # Make sure -C doesn't create empty files. rm -f x?? || fail=1 @@ -42,21 +42,21 @@ test -f xac && fail=1 split -1 in 2> /dev/null || fail=1 # Then make sure that -0 evokes a failure. -split -0 in 2> /dev/null && fail=1 +returns_ 1 split -0 in 2> /dev/null || fail=1 split --lines=$UINTMAX_MAX in || fail=1 split --bytes=$OFF_T_MAX in || fail=1 -split --line-bytes=$OFF_T_OFLOW 2> /dev/null in && fail=1 -split --line-bytes=$SIZE_OFLOW 2> /dev/null in && fail=1 +returns_ 1 split --line-bytes=$OFF_T_OFLOW 2> /dev/null in || fail=1 +returns_ 1 split --line-bytes=$SIZE_OFLOW 2> /dev/null in || fail=1 if truncate -s$SIZE_OFLOW large; then # Ensure we can split chunks of a large file on 32 bit hosts split --number=$SIZE_OFLOW/$SIZE_OFLOW large >/dev/null || fail=1 fi split --number=r/$UINTMAX_MAX/$UINTMAX_MAX </dev/null >/dev/null || fail=1 -split --number=r/$UINTMAX_OFLOW </dev/null 2>/dev/null && fail=1 +returns_ 1 split --number=r/$UINTMAX_OFLOW </dev/null 2>/dev/null || fail=1 # Make sure that a huge obsolete option evokes the right failure. -split -99999999999999999991 2> out && fail=1 +split -99999999999999999991 2> out # On losing systems (x86 Solaris 5.9 c89), we get a message like this: # split: line count option -9999999999... is too large @@ -75,7 +75,7 @@ compare exp out || fail=1 # (the current directory in this case) if ! cat . >/dev/null; then # can't read() directories - split . && fail=1 + returns_ 1 split . || fail=1 fi Exit $fail diff --git a/tests/split/filter.sh b/tests/split/filter.sh index 93a1bebbe..55610e417 100755 --- a/tests/split/filter.sh +++ b/tests/split/filter.sh @@ -44,7 +44,7 @@ split -e -n 10 --filter='xz > $FILE.xz' /dev/null || fail=1 stat x?? 2>/dev/null && fail=1 # Ensure this invalid combination is flagged -split -n 1/2 --filter='true' /dev/null 2>/dev/null && fail=1 +returns_ 1 split -n 1/2 --filter='true' /dev/null 2>&1 || fail=1 # Ensure SIGPIPEs sent by the children don't propagate back # where they would result in a non zero exit from split. diff --git a/tests/split/guard-input.sh b/tests/split/guard-input.sh index cc413606a..1213ab04c 100755 --- a/tests/split/guard-input.sh +++ b/tests/split/guard-input.sh @@ -23,10 +23,10 @@ seq 10 | tee exp-1 > xaa ln -s xaa in2 ln xaa in3 -split -C 6 xaa && fail=1 -split -C 6 in2 && fail=1 -split -C 6 in3 && fail=1 -split -C 6 - < xaa && fail=1 +returns_ 1 split -C 6 xaa || fail=1 +returns_ 1 split -C 6 in2 || fail=1 +returns_ 1 split -C 6 in3 || fail=1 +returns_ 1 split -C 6 - < xaa || fail=1 compare exp-1 xaa || fail=1 diff --git a/tests/split/numeric.sh b/tests/split/numeric.sh index e40430563..9c4e1c55d 100755 --- a/tests/split/numeric.sh +++ b/tests/split/numeric.sh @@ -56,10 +56,10 @@ compare exp-3 x03 || fail=1 # Check that split failed when suffix length is not large enough for # the numerical suffix start value -split -a 3 --numeric-suffixes=1000 in 2> /dev/null && fail=1 +returns_ 1 split -a 3 --numeric-suffixes=1000 in 2>/dev/null || fail=1 # check invalid --numeric-suffixes start values are flagged -split --numeric-suffixes=-1 in 2> /dev/null && fail=1 -split --numeric-suffixes=one in 2> /dev/null && fail=1 +returns_ 1 split --numeric-suffixes=-1 in 2> /dev/null || fail=1 +returns_ 1 split --numeric-suffixes=one in 2> /dev/null || fail=1 Exit $fail diff --git a/tests/split/suffix-auto-length.sh b/tests/split/suffix-auto-length.sh index a50bd23b4..6ee220066 100755 --- a/tests/split/suffix-auto-length.sh +++ b/tests/split/suffix-auto-length.sh @@ -22,7 +22,7 @@ print_ver_ split # ensure this feature is off when start number specified truncate -s12 file.in -split file.in -b1 --numeric=89 && fail=1 +returns_ 1 split file.in -b1 --numeric=89 || fail=1 test "$(ls -1 x* | wc -l)" = 11 || fail=1 rm -f x* diff --git a/tests/split/suffix-length.sh b/tests/split/suffix-length.sh index 48f83eb82..0be3e9bc4 100755 --- a/tests/split/suffix-length.sh +++ b/tests/split/suffix-length.sh @@ -70,7 +70,7 @@ split -a2 -C1000 < /dev/null || fail=1 # Ensure that -a fails early with a -n that is too large rm -f x* -split -a2 -n1000 < /dev/null && fail=1 +returns_ 1 split -a2 -n1000 < /dev/null || fail=1 test -f xaa && fail=1 Exit $fail diff --git a/tests/touch/no-dereference.sh b/tests/touch/no-dereference.sh index a4c85c2af..776c255f2 100755 --- a/tests/touch/no-dereference.sh +++ b/tests/touch/no-dereference.sh @@ -26,7 +26,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. -touch -h no-file 2> err && fail=1 +returns_ 1 touch -h no-file 2> err || fail=1 test -s err || fail=1 touch -h -c no-file 2> err || fail=1 compare /dev/null err || fail=1 @@ -75,7 +75,7 @@ touch -h - > file || fail=1 # If stdout is open, it is not a symlink. if env test -w /dev/stdout >/dev/null && env test ! -w /dev/stdout >&-; then - touch -h - >&- && fail=1 + returns_ 1 touch -h - >&- || fail=1 touch -h -c - >&- || fail=1 fi diff --git a/tests/touch/trailing-slash.sh b/tests/touch/trailing-slash.sh index a6463fa60..2d57007ba 100755 --- a/tests/touch/trailing-slash.sh +++ b/tests/touch/trailing-slash.sh @@ -29,22 +29,22 @@ ln -s dir link2 || framework_failure_ # Trailing slash can only appear on directory or symlink-to-directory. # Up through coreutils 8.0, Solaris 9 failed these tests. -touch no-file/ && fail=1 -touch file/ && fail=1 -touch dangling/ && fail=1 -touch loop/ && fail=1 -touch link1/ && fail=1 +returns_ 1 touch no-file/ || fail=1 +returns_ 1 touch file/ || fail=1 +returns_ 1 touch dangling/ || fail=1 +returns_ 1 touch loop/ || fail=1 +returns_ 1 touch link1/ || fail=1 touch dir/ || fail=1 # -c silences ENOENT, but not ENOTDIR or ELOOP touch -c no-file/ || fail=1 -touch -c file/ && fail=1 +returns_ 1 touch -c file/ || fail=1 touch -c dangling/ || fail=1 -touch -c loop/ && fail=1 -touch -c link1/ && fail=1 +returns_ 1 touch -c loop/ || fail=1 +returns_ 1 touch -c link1/ || fail=1 touch -c dir/ || fail=1 -test -f no-file && fail=1 -test -f nowhere && fail=1 +returns_ 1 test -f no-file || fail=1 +returns_ 1 test -f nowhere || fail=1 # Trailing slash dereferences a symlink, even with -h. # mtime is sufficient to show pass (besides, lstat changes atime of |