]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: use tail --debug to determine inotify support
authorPádraig Brady <P@draigBrady.com>
Fri, 14 Nov 2025 17:03:38 +0000 (17:03 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 17 Nov 2025 14:50:04 +0000 (14:50 +0000)
* init.cfg (require_inotify_supported_): A new function that
indicates inotify support for a file in the current directory,
using tail --debug, rather than awkward strace checks etc.
* tests/tail/inotify-dir-recreate.sh: Call require_inotify_supported_.
 tests/tail/inotify-only-regular.sh: Likewise.
 tests/tail/inotify-race.sh: Likewise.
 tests/tail/inotify-race2.sh: Likewise.

init.cfg
tests/tail/inotify-dir-recreate.sh
tests/tail/inotify-only-regular.sh
tests/tail/inotify-race.sh
tests/tail/inotify-race2.sh

index 9824189005c1d75260994ed592a97650665d12aa..f0fd9e4bbc274ff802496e1762e41b43829988d4 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -765,9 +765,6 @@ working_umask_or_skip_()
 # This example will call the dd_reblock_1 function with
 # an initial delay of .1 second and call it at most 6 times
 # with a max delay of 3.2s (doubled each time), or a total of 6.3s
-# Note ensure you do _not_ quote the parameter to GNU sleep in
-# your function, as it may contain separate values that sleep
-# needs to accumulate.
 # Further function arguments will be forwarded to the test function.
 retry_delay_()
 {
@@ -789,6 +786,28 @@ retry_delay_()
   test "$time_fail" = 0
 }
 
+detect_tail_mode_()
+{
+  touch tail.debug || framework_failure_
+  returns_ 124 timeout "$1" tail -n0 -F --debug tail.debug 2>tail.mode ||
+    framework_failure_
+  grep 'using .* mode' tail.mode >/dev/null
+}
+
+require_inotify_supported_()
+{
+  require_built_ tail timeout
+
+  retry_delay_ detect_tail_mode_ .1 4
+
+  # This may skip because:
+  #   inotify is not available in this build
+  #   inotify is not supported on this file system
+  #   tail didn't print the debug info within 1.5s (unlikely)
+  grep 'using notification mode' tail.mode >/dev/null ||
+    skip_ 'inotify not detected'
+}
+
 # Call this with a list of programs under test immediately after
 # sourcing init.sh.
 print_ver_()
index 569a3b1aa77480efc852178fb255a307e9a24694..f961c334631ac3cfc987c12466691d0ccd1b12c9 100755 (executable)
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tail
-
-grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null && is_local_dir_ . \
-  || skip_ 'inotify is not supported'
-
-# There may be a mismatch between is_local_dir_ (gnulib's remoteness check),
-# and coreutils' is_local_fs_type(), so double check we're using inotify.
-touch file.strace
-require_strace_ 'inotify_add_watch'
-returns_ 124 timeout .1 strace -e inotify_add_watch -o strace.out \
-  tail -F file.strace || fail=1
-grep 'inotify' strace.out || skip_ 'inotify not detected'
+require_inotify_supported_
 
 # Terminate any background tail process
 cleanup_() { kill $pid 2>/dev/null && wait $pid; }
index f1b63b3d83cc977c745c21146bde6da2d7590067..69f6ec0d206462fd564bd3af5ef1079809d50a86 100755 (executable)
@@ -19,8 +19,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tail
 
-grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null \
-  || skip_ 'inotify support required'
+require_inotify_supported_
 
 require_strace_ 'inotify_add_watch'
 
index bb7df48f95551cb60aaf8345c95e0b59cca6a2eb..bec20d35d4f7664495def559b1fe4ebcbfac43b4 100755 (executable)
@@ -22,9 +22,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tail sleep
-
-grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null && is_local_dir_ . \
-  || skip_ 'inotify is not supported'
+require_inotify_supported_
 
 # Terminate any background gdb/tail process
 cleanup_() {
index 3db0cc74c60d3e3503c48359f5164ed7ae255d15..2a066b830ddc13b824f2e91738b4e175d8efa3c9 100755 (executable)
@@ -21,9 +21,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tail sleep
-
-grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null && is_local_dir_ . \
-  || skip_ 'inotify is not supported'
+require_inotify_supported_
 
 # Terminate any background gdb/tail process
 cleanup_() {