]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: tail/overlay-headers.sh: fix various issues
authorPádraig Brady <P@draigBrady.com>
Wed, 7 Jan 2026 20:29:54 +0000 (20:29 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 8 Jan 2026 12:08:14 +0000 (12:08 +0000)
* 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

tests/tail/overlay-headers.sh

index ea105379fe73bd78836a57e29a129fd5ced2bccd..be9b6a7df392527b1d56e5cc4bbae9b2988550ae 100755 (executable)
@@ -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