From 056d6de78fcf11a0f404f25faf8cecc9f9ee9c1c Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Wed, 5 Mar 2014 18:41:16 +0000 Subject: tests: avoid the :> construct which can hide errors On most shells `:>file || framework_failure_` will not evaluate the framework_failure_ even if there was an error writing the file. shells which do evaluate the failure are ksh 93u+ and bash 4.2, while shells wich don't include bash 4.3, solaris, freebsd, dash. Furthermore this construct is problematic on Solaris 10 sh, which will try to optimize away a `:' command in a loop after the first iteration, even if it is redirected. * tests/cp/link-deref.sh: Remove the leading colon on redirections. * tests/cp/reflink-perm.sh: Likewise. * tests/id/zero.sh: Likewise. * tests/install/install-C.sh: Likewise. * tests/misc/env.sh: Likewise. * tests/misc/md5sum-bsd.sh: Likewise. * tests/misc/runcon-no-reorder.sh: Likewise. * tests/mv/partition-perm.sh: Likewise. * tests/rm/r-root.sh: Likewise. * tests/split/l-chunk.sh: Likewise. * tests/split/line-bytes.sh: Likewise. * tests/tail-2/inotify-rotate.sh: Likewise. * tests/tail-2/retry.sh: Likewise. * tests/tail-2/symlink.sh: Likewise. * tests/tail-2/wait.sh: Likewise. * tests/touch/read-only.sh: Likewise. + cfg.mk (sc_prohibit_colon_redirection): A new syntax check to avoid further instances of this creeping in. --- tests/tail-2/inotify-rotate.sh | 2 +- tests/tail-2/retry.sh | 2 +- tests/tail-2/symlink.sh | 4 ++-- tests/tail-2/wait.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/tail-2') diff --git a/tests/tail-2/inotify-rotate.sh b/tests/tail-2/inotify-rotate.sh index a95f4eccb..1c942cc3d 100755 --- a/tests/tail-2/inotify-rotate.sh +++ b/tests/tail-2/inotify-rotate.sh @@ -47,7 +47,7 @@ for i in $(seq 50); do # Normally less than a second is required here, but with heavy load # and a lot of disk activity, even 20 seconds is insufficient, which # leads to this timeout killing tail before the "ok" is written below. - :>k && :>x || framework_failure_ failed to initialize files + >k && >x || framework_failure_ failed to initialize files timeout 40 tail -F k > out 2>&1 & pid=$! sleep .1 diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh index 5b74b7402..dbe66a4e1 100755 --- a/tests/tail-2/retry.sh +++ b/tests/tail-2/retry.sh @@ -45,7 +45,7 @@ grep -F 'tail: warning: --retry ignored' out || fail=1 # === Test: # Ensure that "tail --retry --follow=name" waits for the file to appear. # Clear 'out' so that we can check its contents without races -:>out || framework_failure_ +>out || framework_failure_ timeout 10 tail -s.1 --follow=name --retry missing >out 2>&1 & pid=$! retry_delay_ wait4lines_ .1 6 1 || fail=1 # Wait for "cannot open" error. echo "X" > missing || fail=1 diff --git a/tests/tail-2/symlink.sh b/tests/tail-2/symlink.sh index 362cb6353..b21f9e15c 100755 --- a/tests/tail-2/symlink.sh +++ b/tests/tail-2/symlink.sh @@ -32,7 +32,7 @@ wait4lines_ () # Ensure changing targets of cli specified symlinks are handled. # Prior to v8.22, inotify would fail to recognize changes in the targets. # Clear 'out' so that we can check its contents without races. -:>out || framework_failure_ +>out || framework_failure_ ln -nsf target symlink || framework_failure_ timeout 10 tail -s.1 -F symlink >out 2>&1 & pid=$! retry_delay_ wait4lines_ .1 6 1 || fail=1 # Wait for "cannot open..." @@ -50,7 +50,7 @@ rm -f target out || framework_failure_ # Ensure we correctly handle the source symlink itself changing. # I.E. that we don't operate solely on the targets. # Clear 'out' so that we can check its contents without races. -:>out || framework_failure_ +>out || framework_failure_ echo "X1" > target1 || framework_failure_ ln -nsf target1 symlink || framework_failure_ timeout 10 tail -s.1 -F symlink >out 2>&1 & pid=$! diff --git a/tests/tail-2/wait.sh b/tests/tail-2/wait.sh index 42a93bfe6..13898acf1 100755 --- a/tests/tail-2/wait.sh +++ b/tests/tail-2/wait.sh @@ -52,7 +52,7 @@ for inotify in ---disable-inotify ''; do grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x mv x tail.err test -s tail.err && fail=1 - :>tail.err + >tail.err tail_F() { -- cgit v1.2.3-70-g09d2