Skip to content

Commit fe97fd9

Browse files
committed
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>
1 parent 0a7a8fb commit fe97fd9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/helpers/test_sysinfo.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131

3232
#include "mount-api-utils.h"
3333

34+
#ifdef HAVE_LINUX_NSFS_H
35+
# include <linux/nsfs.h>
36+
# if defined(NS_GET_NSTYPE) && defined(NS_GET_OWNER_UID)
37+
# define USE_NS_GET_API 1
38+
# endif
39+
#endif
40+
3441
typedef struct {
3542
const char *name;
3643
int (*fnc)(void);
@@ -132,6 +139,18 @@ static int hlp_sz_time(void)
132139
return 0;
133140
}
134141

142+
static int hlp_get_nstype_ok(void)
143+
{
144+
#ifdef USE_NS_GET_API
145+
errno = 0;
146+
ioctl(STDOUT_FILENO, NS_GET_NSTYPE);
147+
#else
148+
errno = ENOSYS;
149+
#endif
150+
printf("%d\n", errno != ENOSYS);
151+
return 0;
152+
}
153+
135154
static const mntHlpfnc hlps[] =
136155
{
137156
{ "WORDSIZE", hlp_wordsize },
@@ -147,6 +166,7 @@ static const mntHlpfnc hlps[] =
147166
{ "enotty-ok", hlp_enotty_ok },
148167
{ "fsopen-ok", hlp_fsopen_ok },
149168
{ "sz(time_t)", hlp_sz_time },
169+
{ "ns-gettype-ok", hlp_get_nstype_ok },
150170
{ NULL, NULL }
151171
};
152172

@@ -181,4 +201,3 @@ int main(int argc, char **argv)
181201

182202
exit(re ? EXIT_FAILURE : EXIT_SUCCESS);
183203
}
184-

tests/ts/lsns/filedesc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ ts_init "$*"
2525
ts_check_test_command "$TS_CMD_LSNS"
2626
ts_check_test_command "$TS_CMD_LSFD"
2727
ts_check_test_command "$TS_HELPER_MKFDS"
28+
ts_check_test_command "$TS_HELPER_SYSINFO"
2829

2930
ts_check_prog "ip"
3031

3132
ts_skip_nonroot
3233

34+
if [ "$($TS_HELPER_SYSINFO ns-gettyep-ok)" == "0" ]; then
35+
ts_skip "NS_GET_NSTYPE ioctl cmd not available"
36+
fi
37+
3338
FD=4
3439
NS=LSNS-TEST-FILEDESC-NS
3540
FILE=/run/netns/$NS

0 commit comments

Comments
 (0)