]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsfd) add a case for testing timerfd related columns
authorMasatake YAMATO <yamato@redhat.com>
Sat, 3 Jun 2023 04:11:00 +0000 (13:11 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 4 Jun 2023 08:19:34 +0000 (17:19 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/expected/lsfd/mkfds-timerfd [new file with mode: 0644]
tests/expected/lsfd/mkfds-timerfd-alarm [new file with mode: 0644]
tests/expected/lsfd/mkfds-timerfd-boottime-interval-only [new file with mode: 0644]
tests/expected/lsfd/mkfds-timerfd-monotonic-remaining-only [new file with mode: 0644]
tests/expected/lsfd/mkfds-timerfd-realtime-remaining-and-interval [new file with mode: 0644]
tests/ts/lsfd/mkfds-timerfd [new file with mode: 0755]
tests/ts/lsfd/mkfds-timerfd-alarm [new file with mode: 0755]

diff --git a/tests/expected/lsfd/mkfds-timerfd b/tests/expected/lsfd/mkfds-timerfd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/expected/lsfd/mkfds-timerfd-alarm b/tests/expected/lsfd/mkfds-timerfd-alarm
new file mode 100644 (file)
index 0000000..1c37de6
--- /dev/null
@@ -0,0 +1,16 @@
+    3 timerfd clockid=realtime-alarm
+ASSOC,TYPE,NAME: 0
+ realtime-alarm
+CLOCKID: 0
+      0.000000000
+TIMERFD.REMAINING: 0
+     0.000000000
+TIMERFD.INTERVAL: 0
+    3 timerfd clockid=boottime-alarm
+ASSOC,TYPE,NAME: 0
+ boottime-alarm
+CLOCKID: 0
+      0.000000000
+TIMERFD.REMAINING: 0
+     0.000000000
+TIMERFD.INTERVAL: 0
diff --git a/tests/expected/lsfd/mkfds-timerfd-boottime-interval-only b/tests/expected/lsfd/mkfds-timerfd-boottime-interval-only
new file mode 100644 (file)
index 0000000..97a0f6e
--- /dev/null
@@ -0,0 +1,8 @@
+    3 timerfd clockid=boottime interval=10.123456789
+ASSOC,TYPE,NAME: 0
+       boottime
+CLOCKID: 0
+      0.000000000
+TIMERFD.REMAINING: 0
+    10.123456789
+TIMERFD.INTERVAL: 0
diff --git a/tests/expected/lsfd/mkfds-timerfd-monotonic-remaining-only b/tests/expected/lsfd/mkfds-timerfd-monotonic-remaining-only
new file mode 100644 (file)
index 0000000..e9d6702
--- /dev/null
@@ -0,0 +1,8 @@
+    3 timerfd clockid=monotonic remaining=100.987654321
+ASSOC,TYPE,NAME: 0
+      monotonic
+CLOCKID: 0
+100.987654321
+TIMERFD.REMAINING: 0
+     0.000000000
+TIMERFD.INTERVAL: 0
diff --git a/tests/expected/lsfd/mkfds-timerfd-realtime-remaining-and-interval b/tests/expected/lsfd/mkfds-timerfd-realtime-remaining-and-interval
new file mode 100644 (file)
index 0000000..0119d2c
--- /dev/null
@@ -0,0 +1,8 @@
+    3 timerfd clockid=realtime remaining=100.987654321 interval=5.123456789
+ASSOC,TYPE,NAME: 0
+       realtime
+CLOCKID: 0
+100.987654321
+TIMERFD.REMAINING: 0
+     5.123456789
+TIMERFD.INTERVAL: 0
diff --git a/tests/ts/lsfd/mkfds-timerfd b/tests/ts/lsfd/mkfds-timerfd
new file mode 100755 (executable)
index 0000000..4b6e96d
--- /dev/null
@@ -0,0 +1,109 @@
+#!/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="timerfd"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+ts_init_subtest "realtime-remaining-and-interval"
+{
+    clock=realtime
+    coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=5 interval-nanofrac=123456789; }
+    if read -u ${MKFDS[0]} PID; then
+       ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+           sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+       echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+       echo 'CLOCKID': $?
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+           sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+       echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+       echo 'TIMERFD.INTERVAL': $?
+
+       kill -CONT "${PID}"
+    fi
+    wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "monotonic-remaining-only"
+{
+    clock=monotonic
+    coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=0 interval-nanofrac=0; }
+    if read -u ${MKFDS[0]} PID; then
+       EXPR='(FD == '"$FD"')'
+       ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+           sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+       echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+       echo 'CLOCKID': $?
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+           sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+       echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+       echo 'TIMERFD.INTERVAL': $?
+
+       kill -CONT "${PID}"
+    fi
+    wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "boottime-interval-only"
+{
+    clock=boottime
+    coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=10 interval-nanofrac=123456789; }
+    if read -u ${MKFDS[0]} PID; then
+       EXPR='(FD == '"$FD"')'
+       ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+       echo 'ASSOC,TYPE,NAME': $?
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+       echo 'CLOCKID': $?
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+       echo 'TIMERFD.REMAINING': $?
+
+       ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+       echo 'TIMERFD.INTERVAL': $?
+
+       kill -CONT "${PID}"
+    fi
+    wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-timerfd-alarm b/tests/ts/lsfd/mkfds-timerfd-alarm
new file mode 100755 (executable)
index 0000000..ba8d275
--- /dev/null
@@ -0,0 +1,56 @@
+#!/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="timerfd associating alarm"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_skip_capability cap_wake_alarm
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+{
+    for clock in realtime-alarm  boottime-alarm; do
+       coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=0 interval-nanofrac=0; }
+       if read -u ${MKFDS[0]} PID; then
+           ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+           echo 'ASSOC,TYPE,NAME': $?
+
+           ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+           echo 'CLOCKID': $?
+
+           ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+           echo 'TIMERFD.REMAINING': $?
+
+           ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+           echo 'TIMERFD.INTERVAL': $?
+
+           kill -CONT "${PID}"
+       fi
+       wait "${MKFDS_PID}"
+    done
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize