diff options
author | Masatake YAMATO <yamato@redhat.com> | 2024-04-15 02:18:19 +0900 |
---|---|---|
committer | Masatake YAMATO <yamato@redhat.com> | 2024-04-15 03:34:07 +0900 |
commit | dbfd5efe46b9cea13c3703b12e14cee377859b92 (patch) | |
tree | 7888470e2bcd50c9e5dbba0be7f14f72d9167acc | |
parent | 0a7a8fbc7a82dfbd9e925d1b4d4936bf4e011bc1 (diff) | |
download | util-linux-dbfd5efe46b9cea13c3703b12e14cee377859b92.tar.gz |
tests: (lsns::filedesc) skip if NS_GET_NSTYPE ioctl cmd not available
Currently, Qemu userspace emulation doesn't support the ioctl cmd.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
-rw-r--r-- | tests/helpers/test_sysinfo.c | 21 | ||||
-rwxr-xr-x | tests/ts/lsns/filedesc | 5 |
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c index c36aca2b5c..058afc24f9 100644 --- a/tests/helpers/test_sysinfo.c +++ b/tests/helpers/test_sysinfo.c @@ -31,6 +31,13 @@ #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); } - diff --git a/tests/ts/lsns/filedesc b/tests/ts/lsns/filedesc index 334984784f..1427dee0da 100755 --- a/tests/ts/lsns/filedesc +++ b/tests/ts/lsns/filedesc @@ -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 |