]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsfd::column-mntid) add a new case
authorMasatake YAMATO <yamato@redhat.com>
Fri, 9 Jan 2026 02:47:25 +0000 (11:47 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 12 Jan 2026 18:39:33 +0000 (03:39 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/expected/lsfd/column-mntid [new file with mode: 0644]
tests/ts/lsfd/column-mntid [new file with mode: 0755]

diff --git a/tests/expected/lsfd/column-mntid b/tests/expected/lsfd/column-mntid
new file mode 100644 (file)
index 0000000..dc47712
--- /dev/null
@@ -0,0 +1,2 @@
+mem:OK
+shm:OK
diff --git a/tests/ts/lsfd/column-mntid b/tests/ts/lsfd/column-mntid
new file mode 100755 (executable)
index 0000000..3765ac6
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+#
+# Copyright (C) 2025 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="MNTID column"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+ts_skip_config HAVE_STRUCT_STATX_STX_MNT_ID "cannot get mnt_id via statx(2)"
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_cd "$TS_OUTDIR"
+
+FILE=/etc/passwd
+ID=$("$TS_CMD_FINDMNT" -n -o ID --target "$FILE" 2>> "$TS_OUTPUT" )
+
+{
+    coproc MKFDS { "$TS_HELPER_MKFDS" mmap file=${FILE}; }
+
+    if read -u ${MKFDS[0]} PID; then
+       MNTID=$("$TS_CMD_LSFD" -n -o MNTID -Q 'NAME == "'"$FILE"'" and ASSOC == "mem"' -p "$PID")
+       if [[ "$MNTID" == "$ID" ]]; then
+           echo mem:OK
+       else
+           echo mem:ERROR: "MNTID:$MNTID" != "ID:$ID"
+       fi
+    fi
+} >> "$TS_OUTPUT" 2>&1
+
+echo DONE >&"${MKFDS[1]}"
+wait "${MKFDS_PID}"
+
+{
+    coproc MKFDS { "$TS_HELPER_MKFDS" mmap file=${FILE} shared=true; }
+
+    if read -u ${MKFDS[0]} PID; then
+       MNTID=$("$TS_CMD_LSFD" -n -o MNTID -Q 'NAME == "'"$FILE"'" and ASSOC == "shm"' -p "$PID")
+       if [[ "$MNTID" == "$ID" ]]; then
+           echo shm:OK
+       else
+           echo shm:ERROR: "MNTID:$MNTID" != "ID:$ID"
+       fi
+    fi
+} >> "$TS_OUTPUT" 2>&1
+
+echo DONE >&"${MKFDS[1]}"
+wait "${MKFDS_PID}"
+
+ts_finalize