]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsfd) add a case for testing INOTIFY.INODES.RAW column
authorMasatake YAMATO <yamato@redhat.com>
Fri, 9 Jun 2023 10:03:48 +0000 (19:03 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Tue, 13 Jun 2023 10:18:54 +0000 (19:18 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/expected/lsfd/mkfds-inotify [new file with mode: 0644]
tests/ts/lsfd/mkfds-inotify [new file with mode: 0755]

diff --git a/tests/expected/lsfd/mkfds-inotify b/tests/expected/lsfd/mkfds-inotify
new file mode 100644 (file)
index 0000000..8582260
--- /dev/null
@@ -0,0 +1,2 @@
+INOTIFY.INODES.RAW: 0
+INOTIFY.INODES.RAW == FSTAB,ROOT
diff --git a/tests/ts/lsfd/mkfds-inotify b/tests/ts/lsfd/mkfds-inotify
new file mode 100755 (executable)
index 0000000..f6c4518
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="inotify"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_prog "stat"
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+ROOT_DEV=$(stat -c %d /)
+ROOT="$(stat -c %i /)"@"$(((ROOT_DEV >> 8) & 255)):$((ROOT_DEV & 255))"
+FSTAB_DEV=$(stat -c %d /etc/fstab)
+FSTAB="$(stat -c %i /etc/fstab)"@"$(((FSTAB_DEV >> 8) & 255)):$((FSTAB_DEV & 255))"
+{
+    coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD; }
+    if read -u ${MKFDS[0]} PID; then
+       EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
+       INODES_RAW=$(${TS_CMD_LSFD} --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+       echo "INOTIFY.INODES.RAW": $?
+       if [[ "$INODES_RAW" == "$FSTAB","$ROOT" ]]; then
+           echo "INOTIFY.INODES.RAW" == "FSTAB","ROOT"
+       else
+           echo "INOTIFY.INODES.RAW": "$INODES_RAW"
+           echo "FSTAB": "$FSTAB"
+           echo "ROOT": "$ROOT"
+       fi
+       kill -CONT "${PID}"
+    fi
+    wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize