diff options
author | Pádraig Brady <P@draigBrady.com> | 2009-09-03 00:39:17 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2009-09-03 10:08:06 +0100 |
commit | 84b5844d21e6958c94096f14cf75e90930e88feb (patch) | |
tree | 9b798f18a44e5adc821718cfa179de6dd26ece22 /tests/tail-2/wait | |
parent | 1a94ac4a0524a760c1c3ea7a5ca9032e994785c2 (diff) | |
download | coreutils-84b5844d21e6958c94096f14cf75e90930e88feb.tar.xz |
tests: simplify and fix a race in 2 tail --follow tests
* tests/tail-2/pid: Use the timeout command to determine process
longevity, rather than querying /proc/$pid/status.
The latter was racy in any case when inotify is used, as then
tail wakes up periodically even for unchanging files therefore
causing the check for "S (sleeping)" state to fail intermittently.
* tests/tail-2/wait: Likewise.
Diffstat (limited to 'tests/tail-2/wait')
-rwxr-xr-x | tests/tail-2/wait | 93 |
1 files changed, 14 insertions, 79 deletions
diff --git a/tests/tail-2/wait b/tests/tail-2/wait index a902b54bb..eb04ac230 100755 --- a/tests/tail-2/wait +++ b/tests/tail-2/wait @@ -24,97 +24,32 @@ fi . $srcdir/test-lib.sh -require_proc_pid_status_ - touch here || framework_failure touch k || framework_failure -(touch unreadable && chmod a-r unreadable) || framework_failure +{ touch unreadable && chmod a-r unreadable; } || framework_failure +cat unreadable && framework_failure fail=0 -tail -s0.1 -f not_here & -pid=$! -sleep .5 -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) echo $0: process still active 1>&2; fail=1 ;; - *) ;; - esac - kill $pid -fi +timeout 1 tail -s0.1 -f not_here +test $? = 124 && fail=1 -# Check if the file is really not accessible before use it. -if ! cat unreadable; then - tail -s0.1 -f unreadable & - pid=$! - sleep .5 - state=$(get_process_status_ $pid) - - if test -n "$state"; then - case $state in - S*) echo $0: process still active 1>&2; fail=1 ;; - *) ;; - esac - kill $pid - fi -fi - -(tail -s0.1 -f here 2>tail.err) & -pid=$! -sleep .5 -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) ;; - *) echo $0: process died 1>&2; fail=1 ;; - esac - kill $pid -fi +timeout 1 tail -s0.1 -f unreadable +test $? = 124 && fail=1 +timeout 1 tail -s0.1 -f here 2>tail.err +test $? = 124 || fail=1 # `tail -F' must wait in any case. -(tail -s0.1 -F here 2>>tail.err) & -pid=$! -sleep .5 -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) ;; - *) echo $0: process died 1>&2; fail=1 ;; - esac - kill $pid -fi +timeout 1 tail -s0.1 -F here 2>>tail.err +test $? = 124 || fail=1 -tail -s0.1 -F unreadable & -pid=$! -sleep .5 -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) ;; - *) echo $0: process died 1>&2; fail=1 ;; - esac - kill $pid -fi +timeout 1 tail -s0.1 -F unreadable +test $? = 124 || fail=1 -tail -s0.1 -F not_here & -pid=$! -sleep .5 -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) ;; - *) echo $0: process died 1>&2; fail=1 ;; - esac - kill $pid -fi +timeout 1 tail -s0.1 -F not_here +test $? = 124 || fail=1 test -s tail.err && fail=1 |