From 6b58fb5f4593c5078e4d01068aaeec02641fe605 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Fri, 9 Jun 2023 19:03:48 +0900 Subject: [PATCH] tests: (lsfd) add a case for testing INOTIFY.INODES.RAW column Signed-off-by: Masatake YAMATO --- tests/expected/lsfd/mkfds-inotify | 2 ++ tests/ts/lsfd/mkfds-inotify | 53 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/expected/lsfd/mkfds-inotify create mode 100755 tests/ts/lsfd/mkfds-inotify diff --git a/tests/expected/lsfd/mkfds-inotify b/tests/expected/lsfd/mkfds-inotify new file mode 100644 index 0000000000..85822605a7 --- /dev/null +++ b/tests/expected/lsfd/mkfds-inotify @@ -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 index 0000000000..f6c45185c5 --- /dev/null +++ b/tests/ts/lsfd/mkfds-inotify @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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 -- 2.47.2