From: Pádraig Brady Date: Wed, 7 Jan 2026 20:29:54 +0000 (+0000) Subject: tests: tail/overlay-headers.sh: fix various issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1cbe82cc6131b2cb8441b948f75a0eb28bdcc40;p=thirdparty%2Fcoreutils.git tests: tail/overlay-headers.sh: fix various issues * tests/tail/overlay-headers.sh (cleanup_): Ensure we send SIGCONT to the tail process, otherwise we would hang if the test is terminated while the tail process is in stopped state. (wait4stopped_): A new function to ensure tail is in the stopped state before we start writing to the monitored files. Also remove "---disable-inotify" from $fastpoll so we actually test the inotify code (where supported). Also remove the timeout(1) wrapper, so we actually suspend tail(1). Reported by Bruno Haible on macOS 26 --- diff --git a/tests/tail/overlay-headers.sh b/tests/tail/overlay-headers.sh index ea105379fe..be9b6a7df3 100755 --- a/tests/tail/overlay-headers.sh +++ b/tests/tail/overlay-headers.sh @@ -38,11 +38,12 @@ wait4lines_ () } # Speedup the non inotify case -fastpoll='---dis -s.1 --max-unchanged-stats=1' +fastpoll='-s.1 --max-unchanged-stats=1' # Terminate any background tail process cleanup_() { - kill $pid 2>/dev/null && wait $pid; + kill -CONT $pid 2>/dev/null + kill $pid 2>/dev/null && wait $pid kill $sleep 2>/dev/null && wait $sleep } @@ -52,16 +53,32 @@ echo start > file2 || framework_failure_ # Use this as a way to gracefully terminate tail env sleep 60 & sleep=$! -timeout 60 tail $fastpoll --pid=$sleep -f file1 file2 > out & pid=$! +# Note don't use timeout(1) here as it currently +# does not propagate SIGCONT +tail $fastpoll --pid=$sleep -f file1 file2 > out & pid=$! +# Ensure tail is running kill -0 $pid || fail=1 +# Ensure SIGCONT is supported +kill -CONT $pid || framework_failure_ + # Wait for 5 initial lines retry_delay_ wait4lines_ .1 6 5 || fail=1 # Suspend tail so single read() caters for multiple inotify events kill -STOP $pid || fail=1 +wait4stopped_() { + local delay=$1 + case $(ps -o state= -p "$pid" 2>/dev/null) in + T*) return 0 ;; + *) sleep $delay; return 1 ;; + esac +} + +retry_delay_ wait4stopped_ .1 6 || skip_ 'failed to detect stopped tail' + # Interleave writes to files to generate overlapping inotify events echo line >> file1 || framework_failure_ echo line >> file2 || framework_failure_ @@ -76,6 +93,6 @@ retry_delay_ wait4lines_ .1 6 13 || fail=1 kill $sleep && wait || framework_failure_ -test "$(countlines_)" = 13 || fail=1 +test "$(countlines_)" = 13 || { cat out; fail=1; } Exit $fail