From 09fcf494a10c4b1ad2b037d093f571e7462e08c4 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Mon, 5 Jul 2010 08:53:10 +0100 Subject: tests: make tests requiring a delay to pass, more robust * tests/init.cfg: Introduce a retry_delay_() function to repeatedly call a test function that requires a delay. This delay can now be shorter for the common case on fast systems, but will double until a configurable limit it reached before failing on slower systems. * tests/dd/reblock: Use retry_delay_. * tests/misc/cat-buf: Likewise. * tests/misc/stdbuf: Likewise. * tests/tail-2/F-vs-rename: Likewise. * tests/tail-2/flush-initial: Likewise. * tests/tail-2/tail-n0f: Likewise. * tests/tail-2/wait: Likewise. * test/dd/misc: Comment that delay is needed to trigger failure. --- tests/tail-2/tail-n0f | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tests/tail-2/tail-n0f') diff --git a/tests/tail-2/tail-n0f b/tests/tail-2/tail-n0f index 0ff3a3d01..6a9b59c37 100755 --- a/tests/tail-2/tail-n0f +++ b/tests/tail-2/tail-n0f @@ -39,12 +39,18 @@ for inotify in ---disable-inotify ''; do for c_or_n in c n; do tail --sleep=4 -${c_or_n} 0 -f $inotify $file & pid=$! - sleep .5 - state=$(get_process_status_ $pid) - case $state in - S*) ;; - *) echo $0: process in unexpected state: $state 1>&2; fail=1 ;; - esac + tail_sleeping() + { + local delay="$1"; sleep $delay + state=$(get_process_status_ $pid) + case $state in + S*) ;; + *) return 1;; + esac + } + # Wait up to 1.5s for tail to sleep + retry_delay_ tail_sleeping .1 4 || + { echo $0: process in unexpected state: $state >&2; fail=1; } kill $pid done done -- cgit v1.2.3-70-g09d2