* 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 | 16 ++++++++++++++++
tests/tail/inotify-dir-recreate.sh | 12 +-----------
tests/tail/inotify-only-regular.sh | 3 +--
tests/tail/inotify-race.sh | 4 +---
tests/tail/inotify-race2.sh | 4 +---
5 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/init.cfg b/init.cfg
index 982418900..f17fd1041 100644
--- a/init.cfg
+++ b/init.cfg
@@ -107,6 +107,22 @@ require_local_dir_()
skip_ "This test must be run on a local file system."
}
+require_inotify_supported_()
+{
+ require_built_ tail timeout
+
+ touch file.debug
+ returns_ 124 timeout .1 tail -F --debug file.debug 2>debug.out ||
+ framework_failure_
+
+ # 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 .1s (unlikely)
+ grep 'using notification mode' debug.out >/dev/null ||
+ skip_ 'inotify not detected'
+}
+
require_selinux_()
{
# When in a chroot of an SELinux-enabled system, but with a mock-simulated
diff --git a/tests/tail/inotify-dir-recreate.sh
b/tests/tail/inotify-dir-recreate.sh
index 569a3b1aa..f961c3346 100755
--- a/tests/tail/inotify-dir-recreate.sh
+++ b/tests/tail/inotify-dir-recreate.sh
@@ -20,17 +20,7 @@
. "${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; }
diff --git a/tests/tail/inotify-only-regular.sh
b/tests/tail/inotify-only-regular.sh
index f1b63b3d8..69f6ec0d2 100755
--- a/tests/tail/inotify-only-regular.sh
+++ b/tests/tail/inotify-only-regular.sh
@@ -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'
diff --git a/tests/tail/inotify-race.sh b/tests/tail/inotify-race.sh
index bb7df48f9..bec20d35d 100755
--- a/tests/tail/inotify-race.sh
+++ b/tests/tail/inotify-race.sh
@@ -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_() {
diff --git a/tests/tail/inotify-race2.sh b/tests/tail/inotify-race2.sh
index 3db0cc74c..2a066b830 100755
--- a/tests/tail/inotify-race2.sh
+++ b/tests/tail/inotify-race2.sh
@@ -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_() {
--
2.51.1