]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsns::filedesc) skip if NS_GET_NSTYPE ioctl cmd not available
authorMasatake YAMATO <yamato@redhat.com>
Sun, 14 Apr 2024 17:18:19 +0000 (02:18 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 14 Apr 2024 18:34:07 +0000 (03:34 +0900)
Currently, Qemu userspace emulation doesn't support the ioctl cmd.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_sysinfo.c
tests/ts/lsns/filedesc

index c36aca2b5c3a9edae034a06ae1d59d1e9f02c64c..058afc24f9c76093230cdd2a344be7612c9ace2a 100644 (file)
 
 #include "mount-api-utils.h"
 
+#ifdef HAVE_LINUX_NSFS_H
+# include <linux/nsfs.h>
+# if defined(NS_GET_NSTYPE) && defined(NS_GET_OWNER_UID)
+#  define USE_NS_GET_API       1
+# endif
+#endif
+
 typedef struct {
        const char      *name;
        int             (*fnc)(void);
@@ -132,6 +139,18 @@ static int hlp_sz_time(void)
        return 0;
 }
 
+static int hlp_get_nstype_ok(void)
+{
+#ifdef USE_NS_GET_API
+       errno = 0;
+       ioctl(STDOUT_FILENO, NS_GET_NSTYPE);
+#else
+       errno = ENOSYS;
+#endif
+       printf("%d\n", errno != ENOSYS);
+       return 0;
+}
+
 static const mntHlpfnc hlps[] =
 {
        { "WORDSIZE",   hlp_wordsize    },
@@ -147,6 +166,7 @@ static const mntHlpfnc hlps[] =
        { "enotty-ok",  hlp_enotty_ok   },
        { "fsopen-ok",  hlp_fsopen_ok   },
        { "sz(time_t)", hlp_sz_time     },
+       { "ns-gettype-ok", hlp_get_nstype_ok },
        { NULL, NULL }
 };
 
@@ -181,4 +201,3 @@ int main(int argc, char **argv)
 
        exit(re ? EXIT_FAILURE : EXIT_SUCCESS);
 }
-
index 334984784ff5259ca6fe8f42dd956ce03fb831b1..1427dee0dabd2ec447aef59847b5b3c4180fcd90 100755 (executable)
@@ -25,11 +25,16 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_LSNS"
 ts_check_test_command "$TS_CMD_LSFD"
 ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_test_command "$TS_HELPER_SYSINFO"
 
 ts_check_prog "ip"
 
 ts_skip_nonroot
 
+if [ "$($TS_HELPER_SYSINFO ns-gettype-ok)" == "0" ]; then
+    ts_skip "NS_GET_NSTYPE ioctl cmd not available"
+fi
+
 FD=4
 NS=LSNS-TEST-FILEDESC-NS
 FILE=/run/netns/$NS