From: Christian Goeschel Ndjomouo Date: Sun, 21 Dec 2025 01:06:18 +0000 (-0500) Subject: tests: add getino tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1516be6f92b0631a1b4d8b4f9d47a7444896cad;p=thirdparty%2Futil-linux.git tests: add getino tests Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/tests/commands.sh b/tests/commands.sh index 19f51529c..8a1c12d44 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -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 index 000000000..9766475a4 --- /dev/null +++ b/tests/expected/getino/getino-invalid-pid @@ -0,0 +1 @@ +ok diff --git a/tests/expected/getino/getino-multiple-pids b/tests/expected/getino/getino-multiple-pids new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/tests/expected/getino/getino-multiple-pids @@ -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 index 000000000..9766475a4 --- /dev/null +++ b/tests/expected/getino/getino-print-pid-option @@ -0,0 +1 @@ +ok diff --git a/tests/expected/getino/getino-single-pid b/tests/expected/getino/getino-single-pid new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/tests/expected/getino/getino-single-pid @@ -0,0 +1 @@ +ok diff --git a/tests/ts/getino/getino b/tests/ts/getino/getino new file mode 100755 index 000000000..0c2991935 --- /dev/null +++ b/tests/ts/getino/getino @@ -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 + +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