]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add getino tests
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Sun, 21 Dec 2025 01:06:18 +0000 (20:06 -0500)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 8 Jan 2026 01:08:23 +0000 (20:08 -0500)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/commands.sh
tests/expected/getino/getino-invalid-pid [new file with mode: 0644]
tests/expected/getino/getino-multiple-pids [new file with mode: 0644]
tests/expected/getino/getino-print-pid-option [new file with mode: 0644]
tests/expected/getino/getino-single-pid [new file with mode: 0644]
tests/ts/getino/getino [new file with mode: 0755]

index 19f51529ca543dbeb93480d1a2aebb152c2d830e..8a1c12d44b3b2ef286b3e0ebd3a39c241db9b512 100644 (file)
@@ -92,6 +92,7 @@ TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"${ts_commandsdir}findmnt"}
 TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"${ts_commandsdir}fsck.cramfs"}
 TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"${ts_commandsdir}fsck.minix"}
 TS_CMD_GETOPT=${TS_CMD_GETOPT-"${ts_commandsdir}getopt"}
+TS_CMD_GETINO=${TS_CMD_GETINO-"${ts_commandsdir}getino"}
 TS_CMD_HARDLINK=${TS_CMD_HARDLINK-"${ts_commandsdir}hardlink"}
 TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"${ts_commandsdir}hexdump"}
 TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"${ts_commandsdir}hwclock"}
diff --git a/tests/expected/getino/getino-invalid-pid b/tests/expected/getino/getino-invalid-pid
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/expected/getino/getino-multiple-pids b/tests/expected/getino/getino-multiple-pids
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/expected/getino/getino-print-pid-option b/tests/expected/getino/getino-print-pid-option
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/expected/getino/getino-single-pid b/tests/expected/getino/getino-single-pid
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/ts/getino/getino b/tests/ts/getino/getino
new file mode 100755 (executable)
index 0000000..0c29919
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# 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.
+#
+# Copyright (C) 2025 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="getino"
+
+. "$TS_TOPDIR/functions.sh"
+ts_init "$*"
+
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+       TS_CMD_KILL="$(which kill)"
+fi
+
+# The pidfs was only introduced in kernel version 6.9,
+# which means we cannot get a valid pidfd from earlier versions,
+# so we can confidently anticipate the test failure.
+if ts_kernel_ver_lt 6 9; then
+       TS_KNOWN_FAIL="yes"
+fi
+
+ts_check_test_command "$TS_CMD_GETINO"
+
+ts_init_subtest "single-pid"
+if "$TS_CMD_GETINO" 1 &>/dev/null; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+ts_init_subtest "multiple-pids"
+if "$TS_CMD_GETINO" 1 1 1 1 1 &>/dev/null; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+ts_init_subtest "invalid-pid"
+if ! "$TS_CMD_GETINO" "invalid-pid" &>/dev/null; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+ts_init_subtest "print-pid-option" 
+res=$("$TS_CMD_GETINO" --print-pid 1 2>/dev/null | grep -Eo '^[[:digit:]]*:[[:digit:]]*$'); 
+if [ -n "$res" ]; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+ts_finalize