From 84b5844d21e6958c94096f14cf75e90930e88feb Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 3 Sep 2009 00:39:17 +0100 Subject: 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. --- tests/tail-2/pid | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'tests/tail-2/pid') diff --git a/tests/tail-2/pid b/tests/tail-2/pid index 86e3d60c0..a797666fe 100755 --- a/tests/tail-2/pid +++ b/tests/tail-2/pid @@ -23,48 +23,21 @@ fi . $srcdir/test-lib.sh -require_proc_pid_status_ - touch here || framework_failure - fail=0 -# Use tail itself to create a background process. - +# Use tail itself to create a background process to monitor. tail -f here & bg_pid=$! -tail -s0.1 -f here --pid=$bg_pid & - -pid=$! - -sleep 0.5 - -state=$(get_process_status_ $pid) - -if test -n "$state"; then - case $state in - S*) ;; - *) echo "$0: process dead? (state=$state)" 1>&2; fail=1 ;; - esac - kill $pid -fi +# Ensure that tail --pid=PID does not exit when PID is alive. +timeout 1 tail -s.1 -f here --pid=$bg_pid +test $? = 124 || fail=1 +# Cleanup background process kill $bg_pid -sleep 0.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 - # Ensure that tail --pid=PID exits successfully when PID is dead. # Use an unlikely-to-be-live PID getlimits_ -- cgit v1.2.3-70-g09d2