Add new LTP tests related to fsmount family of syscalls
cover Add new LTP tests related to fsmount family of syscalls
Hello,
This series adds a bunch of LTP tests related to fsmount family of syscalls.
Thanks
--
viresh
Viresh Kumar (7):
lapi/fsmount: Add definitions for fsmount related syscalls syscalls/fsopen: New tests
syscalls/fsconfig: New tests
syscalls/fsmount: New tests
syscalls/move_mount: New tests
syscalls/fspick: New tests
syscalls/open_tree: New tests
configure.ac | 6 + include/lapi/fsmount.h | 134 ++++++++++++++++++ runtest/syscalls | 18 +++ testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 77 ++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 97 +++++++++++++ testcases/kernel/syscalls/fsmount/.gitignore | 2 + testcases/kernel/syscalls/fsmount/Makefile | 6 + testcases/kernel/syscalls/fsmount/fsmount01.c | 71 ++++++++++ testcases/kernel/syscalls/fsmount/fsmount02.c | 83 +++++++++++ testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 + testcases/kernel/syscalls/fsopen/fsopen01.c | 71 ++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++ testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 + testcases/kernel/syscalls/fspick/fspick01.c | 104 ++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 110 ++++++++++++++ .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 + .../kernel/syscalls/move_mount/move_mount01.c | 82 +++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 102 +++++++++++++ .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 +++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 110 ++++++++++++++ 27 files changed, 1284 insertions(+) create mode 100644 include/lapi/fsmount.h create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore create mode 100644 testcases/kernel/syscalls/fsmount/Makefile create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 1/7 lapi/fsmount: Add definitions for fsmount related syscalls
This adds definitions for all fsmount related syscalls which will be used by multiple syscall tests.
--- include/lapi/fsmount.h | 134 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 include/lapi/fsmount.h
include/lapi/fsmount.h new file +134 -0
@@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Linaro Limited. All rights reserved. +* Author: Viresh Kumar <[email protected]> +*/ + +#ifndef FSMOUNT_H +#define FSMOUNT_H + +#include <fcntl.h> +#include <sys/mount.h> +#include <sys/syscall.h> +#include <sys/types.h> + +#include "config.h" +#include "lapi/syscalls.h" + +#ifndef HAVE_FSOPEN +int fsopen (const char *fsname,unsigned int flags) +{ +return tst_syscall (__NR_fsopen, fsname, flags); +} +#endif /* HAVE_FSOPEN */ + +#ifndef HAVE_FSCONFIG +int fsconfig (int fd,unsigned int cmd,const char *key, +const void *value,int aux) +{ +return tst_syscall (__NR_fsconfig, fd, cmd, key, value, aux); +} +#endif /* HAVE_FSCONFIG */ + +#ifndef HAVE_FSMOUNT +int fsmount (int fd,unsigned int flags,unsigned int mount_attrs) +{ +return tst_syscall (__NR_fsmount, fd, flags, mount_attrs); +} +#endif /* HAVE_FSMOUNT */ + +#ifndef HAVE_FSPICK +int fspick (int dirfd,const char *pathname,unsigned int flags) +{ +return tst_syscall (__NR_fspick, dirfd, pathname, flags); +} +#endif /* HAVE_FSPICK */ + +#ifndef HAVE_MOVE_MOUNT +int move_mount (int from_dirfd,const char *from_pathname,int to_dirfd, +const char *to_pathname,unsigned int flags) +{ +return tst_syscall (__NR_move_mount, from_dirfd, from_pathname, to_dirfd, + to_pathname, flags); +} +#endif /* HAVE_MOVE_MOUNT */ + +#ifndef HAVE_OPEN_TREE +int open_tree (int dirfd,const char *pathname,unsigned int flags) +{ +return tst_syscall (__NR_open_tree, dirfd, pathname, flags); +} +#endif /* HAVE_OPEN_TREE */ + +/* +* New headers added in kernel after 5.2 release, create them for old userspace. +*/ + +#ifndef OPEN_TREE_CLONE + +/* +* open_tree() flags. +*/ +#define OPEN_TREE_CLONE 1/* Clone the target tree and attach the clone */ +#define OPEN_TREE_CLOEXEC O_CLOEXEC/* Close the file on execve() */ + +/* +* move_mount() flags. +*/ +#define MOVE_MOUNT_F_SYMLINKS 0x00000001/* Follow symlinks on from path */ +#define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002/* Follow automounts on from path */ +#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004/* Empty from path permitted */ +#define MOVE_MOUNT_T_SYMLINKS 0x00000010/* Follow symlinks on to path */ +#define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020/* Follow automounts on to path */ +#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040/* Empty to path permitted */ +#define MOVE_MOUNT__MASK 0x00000077 + +/* +* fsopen() flags. +*/ +#define FSOPEN_CLOEXEC 0x00000001 + +/* +* fspick() flags. +*/ +#define FSPICK_CLOEXEC 0x00000001 +#define FSPICK_SYMLINK_NOFOLLOW 0x00000002 +#define FSPICK_NO_AUTOMOUNT 0x00000004 +#define FSPICK_EMPTY_PATH 0x00000008 + +/* +* The type of fsconfig() call made. +*/ +enum fsconfig_command { +FSCONFIG_SET_FLAG =0 ,/* Set parameter, supplying no value */ +FSCONFIG_SET_STRING =1 ,/* Set parameter, supplying a string value */ +FSCONFIG_SET_BINARY =2 ,/* Set parameter, supplying a binary blob value */ +FSCONFIG_SET_PATH =3 ,/* Set parameter, supplying an object by path */ +FSCONFIG_SET_PATH_EMPTY =4 ,/* Set parameter, supplying an object by (empty) path */ +FSCONFIG_SET_FD =5 ,/* Set parameter, supplying an object by fd */ +FSCONFIG_CMD_CREATE =6 ,/* Invoke superblock creation */ +FSCONFIG_CMD_RECONFIGURE =7 ,/* Invoke superblock reconfiguration */ +}; + +/* +* fsmount() flags. +*/ +#define FSMOUNT_CLOEXEC 0x00000001 + +/* +* Mount attributes. +*/ +#define MOUNT_ATTR_RDONLY 0x00000001/* Mount read-only */ +#define MOUNT_ATTR_NOSUID 0x00000002/* Ignore suid and sgid bits */ +#define MOUNT_ATTR_NODEV 0x00000004/* Disallow access to device special files */ +#define MOUNT_ATTR_NOEXEC 0x00000008/* Disallow program execution */ +#define MOUNT_ATTR__ATIME 0x00000070/* Setting on how atime should be updated */ +#define MOUNT_ATTR_RELATIME 0x00000000/* - Update atime relative to mtime/ctime. */ +#define MOUNT_ATTR_NOATIME 0x00000010/* - Do not update access times. */ +#define MOUNT_ATTR_STRICTATIME 0x00000020/* - Always perform atime updates */ +#define MOUNT_ATTR_NODIRATIME 0x00000080/* Do not update directory access times */ + +#endif /* OPEN_TREE_CLONE */ + + +#endif /* FSMOUNT_H */
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 1/7 lapi/fsmount: Add definitions for fsmount related syscalls
Hi Viresh,
Thank you for creating new tests for LTP.
Unfortunately, this 1/7 patch has overlap with zlang@'s patch[1]. It probably can not be merged if the patch[1] applies first. But the remaining part is valuable to LTP, you can drop some of this and rebase your code to make use of the header file again.
[1] http://lists.linux.it/pipermail/ltp/2020-February/015336.html
[CC zlang, pvorel] to have a look at this.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200216/e4dfdd77/attachment-0001.htm>
PATCH 1/7 lapi/fsmount: Add definitions for fsmount related syscalls
Quoted 8 lines · Li Wang
Hi Viresh,
Thank you for creating new tests for LTP.
Unfortunately, this 1/7 patch has overlap with zlang@'s patch[1]. It probably can not be merged if the patch[1] applies first. But the remaining part is valuable to LTP, you can drop some of this and rebase your code to make use of the header file again.
Thanks for pointing that out Li. I will rebase over zlang's patch once it gets merged.
Signature · 1 line
viresh
PATCH 2/7 syscalls/fsopen: New tests
In reply to Viresh KumarAdd tests to check working of fsopen() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 71 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
configure.ac +1 -0
@@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \ execveat \ fallocate \ fchownat \ + fsopen \ fstatat \ getdents \ getdents64 \
runtest/syscalls +3 -0
@@ -542,6 +542,9 @@ fanotify13 fanotify13 fanotify14 fanotify14 fanotify15 fanotify15 +fsopen01 fsopen01 +fsopen02 fsopen02 + ioperm01 ioperm01 ioperm02 ioperm02
testcases/kernel/syscalls/fsopen/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +fsopen01 +fsopen02
testcases/kernel/syscalls/fsopen/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsopen/fsopen01.c new file +71 -0
71 lines not on this page · raw message
testcases/kernel/syscalls/fsopen/fsopen02.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 2/7 syscalls/fsopen: New tests
Quoted 129 lines · Viresh Kumar
Add tests to check working of
fsopen()syscall.Signed-off-by Viresh Kumar <[email protected]>--- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 71 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.cconfigure.ac +1
-0@@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \ execveat \ fallocate \ fchownat \ + fsopen \ fstatat \ getdents \ getdents64 \runtest/syscalls +3
-0@@ -542,6 +542,9 @@ fanotify13 fanotify13 fanotify14 fanotify14 fanotify15 fanotify15 +fsopen01 fsopen01 +fsopen02 fsopen02 + ioperm01 ioperm01 ioperm02 ioperm02testcases/kernel/syscalls/fsopen/.gitignore new file +2
-0@@ -0,0 +1,2 @@ +fsopen01 +fsopen02testcases/kernel/syscalls/fsopen/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/syscalls/fsopen/fsopen01.c new file +6
-0@@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsopen() test which tries to configure and mount the filesystem as
+ * well.
+ */testcases/kernel/syscalls/fsopen/fsopen01.c new file +16
-0+#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void run (void ) +{ +int fd, fsmfd; + +TEST (fsopen (tst_device->fs_type,0 )); + fd =TST_RET ; + +if (fd ==-1 ) +tst_brk (TFAIL |TERRNO ,"fsopen() failed" ); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev,0));
testcases/kernel/syscalls/fsopen/fsopen01.c new file +31
-0+if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"fsconfig() failed" ); + goto out; + } + +TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); +if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"fsconfig() failed" ); + goto out; + } + +TEST (fsmount (fd,0 ,0 )); +if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"fsmount() failed" ); + goto out; + } + + fsmfd =TST_RET ; + +TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); + +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"move_mount() failed" ); + goto out; + } + +SAFE_CLOSE (TST_RET ); +
testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +10
-0+TEST (umount (MNTPOINT )); + +tst_res (TPASS ,"fsopen() passed" ); + +out: +SAFE_CLOSE (fd); +} + +static struct tst_test test = { + .min_kver ="5.2" ,
I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
+ .test_all = run,
testcases/kernel/syscalls/fsopen/fsopen01.c line 68
Quoted 3 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +2
-0+ .needs_root = 1, + .needs_tmpdir = 1,
.needs_tmpdir is not necessary because tst_test->mntpoint helps create that too.
testcases/kernel/syscalls/fsopen/fsopen01.c line 70
Quoted 3 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +2
-0+ .format_device = 1, + .mntpoint = MNTPOINT,
Maybe to test more filesystems and skip on FUSE? Just like the way in zlang@'s patch.
+ .all_filesystems = 1,
+ .dev_fs_flags = TST_FS_SKIP_FUSE,
+};
Quoted 57 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +37
-0@@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsopen() failure tests. +*/ +#include "tst_test.h" +#include "lapi/fsmount.h" + +const char *invalid_fs ="invalid" ; +const char *valid_fs; + +static struct tcase { +char *name; +const char **fs; +unsigned int flags; +int exp_errno; +} tcases[] = { + {"invalid-fs" , &invalid_fs,0 ,ENODEV }, + {"invalid-flags" , &valid_fs,0x10 ,EINVAL }, +}; + +static void setup (void ) +{ + valid_fs = tst_device->fs_type; +} + +static void run (unsigned int n) +{ +struct tcase *tc = &tcases[n]; + +TEST (fsopen (*tc->fs, tc->flags)); + +if (TST_RET !=-1 ) { +SAFE_CLOSE (TST_RET ); + tst_brk(TFAIL, "%s: fsopen() succeeded unexpectedly(index: %d)",
testcases/kernel/syscalls/fsopen/fsopen02.c new file +5
-0+ tc->name, n); + } + +if (tc->exp_errno !=TST_ERR ) { + tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with%s",
testcases/kernel/syscalls/fsopen/fsopen02.c new file +4
-0+ tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected",
tc->name);
testcases/kernel/syscalls/fsopen/fsopen02.c
Quoted 4 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +4
-0+} + +static struct tst_test test = { + .min_kver ="5.2" ,
To delete .min_kver.
Quoted 14 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +6
-1+ .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .needs_device = 1, +}; --2.21.0.rc0.269.g1a574e7a288b
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200216/427b4b5f/attachment.htm>
PATCH 2/7 syscalls/fsopen: New tests
Quoted 6 lines · Li Wang
Review
Quoted 3 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
I never thought about that earlier, good point. All other comments look fine as well. Thanks.
Signature · 1 line
viresh
PATCH 2/7 syscalls/fsopen: New tests
In reply to Li WangHi!
Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +8
-0+SAFE_CLOSE (TST_RET ); + +TEST (umount (MNTPOINT )); + +tst_res (TPASS ,"fsopen() passed" ); + +out: +SAFE_CLOSE (fd);
Quoted 8 lines
testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 5 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +4
-0+} + +static struct tst_test test = { + .min_kver ="5.2" ,I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the tst_syscall() that checks for it.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/7 syscalls/fsopen: New tests
Quoted 5 lines · Cyril Hrubis
...
Quoted 4 lines
Quoted 3 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",
Quoted 8 lines
Quoted 2 lines
I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.
+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/fb9b666c/attachment.htm>
PATCH 2/7 syscalls/fsopen: New tests
Quoted 10 lines · Li Wang
Quoted 8 lines · Cyril Hrubis
...
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
Quoted 8 lines
Quoted 5 lines
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Not sure if I understood it very clearly and don't want to spam everyone with an incorrect patchset still missing this point and so asking here :)
How exactly would the setup() routine look like? Something like this ?
syscall(#NR, ##__VA_ARGS__);
Signature · 1 line
viresh
PATCH 2/7 syscalls/fsopen: New tests
Quoted 21 lines · Viresh Kumar
Quoted 8 lines · Li Wang
Quoted 6 lines · Cyril Hrubis
...
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they
can be
Quoted 10 lines
Quoted 7 lines
Quoted 1 line
running on many distributions(which backport the features).
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Quoted 8 lines
Not sure if I understood it very clearly and don't want to spam everyone with an
incorrect patchset still missing this point and so asking here :)How exactly would the
setup()routine look like? Something like this ?syscall(#NR, ##__VA_ARGS__);
I suggest to use tst_syscall(...);.
A dummy call in setup() just helps check the ENOSYS errno, something like:
$ cat testcases/cve/cve-2016-7117.c |grep setup -A 10
static void setup(void)
{
...
tst_syscall(__NR_recvmmsg, 0, 0, 0, 0, 0);
}Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/b865a981/attachment.htm>
PATCH 2/7 syscalls/fsopen: New tests
Quoted 35 lines · Li Wang
Quoted 21 lines · Viresh Kumar
Quoted 8 lines · Li Wang
Quoted 6 lines · Cyril Hrubis
...
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they
can be
Quoted 10 lines
Quoted 7 lines
Quoted 1 line
running on many distributions(which backport the features).
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Quoted 8 lines
Not sure if I understood it very clearly and don't want to spam everyone with an
incorrect patchset still missing this point and so asking here :)How exactly would the
setup()routine look like? Something like this ?syscall(#NR, ##__VA_ARGS__);I suggest to use
tst_syscall(...);.
Quoted 8 lines
A dummy call in
setup()just helps check the ENOSYS errno, something like:$ cat testcases/cve/cve-2016-7117.c |grep setup -A 10 static void setup(void) { ... tst_syscall(__NR_recvmmsg, 0, 0, 0, 0, 0); }
Okay, thanks.
Signature · 1 line
viresh
PATCH 2/7 syscalls/fsopen: New tests
In reply to Li WangHi Viresh,
as somebody (probably Li) pointed out fsopen/fsopen01.c is similar to fsmount/fsmount01.c, so please during rebase drop it. BTW for this dropped test I'd use different approach (close fd in cleanup function and use tst_brk(TFAIL instead of tst_res(TBROK and goto):
static void cleanup(void)
{
if (fd > 0)
SAFE_CLOSE(fd);
}...
if (fd == -1) tst_brk(TFAIL | TERRNO, "fsopen() failed");
Also you added autotools check for functions (e.g. fsopen) during commits, but I move them to the first (together with lapi header).
Kind regards,
Petr
PATCH 2/7 syscalls/fsopen: New tests
Quoted 8 lines · Petr Vorel
Hi Viresh,
as somebody (probably Li) pointed out
fsopen/fsopen01.cis similar tofsmount/fsmount01.c, so please during rebase drop it. BTW for this dropped test I'd use different approach (close fd in cleanup function and use tst_brk(TFAIL instead oftst_res(TBROK and goto):static void cleanup(void)
Quoted 8 lines
{ if (fd > 0) SAFE_CLOSE(fd); }...
if (fd == -1) tst_brk(TFAIL | TERRNO, "fsopen() failed");
Lets review this comment after my V2 series is posted today. It may be better to keep separate tests.
Quoted 2 lines
Also you added autotools check for functions (e.g. fsopen) during commits, but I move them to the first (together with lapi header).
Yeah, I already saw that. Thanks for that, you did the right thing :)
Signature · 1 line
viresh
PATCH 2/7 syscalls/fsopen: New tests
In reply to Li WangHi,
Quoted 10 lines · Cyril Hrubis
Quoted 8 lines
...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
Quoted 8 lines
Quoted 4 lines
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Could anybody add it to fsmount/fsmount01.c instead?
If anybody don't mind, I'll rename fsopen02.c to fsopen01.c,
remove .min_kver = "5.2" and replace tst_brk with tst_res + return, and merge it:
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2020 Viresh Kumar <[email protected]> *
* Description:
* Basic fsopen() failure tests.
*/
#include "tst_test.h"
#include "lapi/fsmount.h"
const char *invalid_fs = "invalid";
const char *valid_fs;
static struct tcase {
char *name;
const char **fs;
unsigned int flags;
int exp_errno;
} tcases[] = {
{"invalid-fs", &invalid_fs, 0, ENODEV},
{"invalid-flags", &valid_fs, 0x10, EINVAL},
};static void setup(void)
{
valid_fs = tst_device->fs_type;
}static void run(unsigned int n)
{
struct tcase *tc = &tcases[n];
TEST(fsopen(*tc->fs, tc->flags));
if (TST_RET != -1) {
SAFE_CLOSE(TST_RET);
tst_res(TFAIL, "%s: fsopen() succeeded unexpectedly (index: %d)",
tc->name, n);
return;
}
if (tc->exp_errno != TST_ERR) {
tst_res(TFAIL | TTERRNO, "%s: fsopen() should fail with %s",
tc->name, tst_strerrno(tc->exp_errno));
return;
}
tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected", tc->name);
}static struct tst_test test = {
.tcnt = ARRAY_SIZE(tcases),
.test = run,
.setup = setup,
.needs_root = 1,
.needs_device = 1,
};
PATCH 2/7 syscalls/fsopen: New tests
Quoted 18 lines · Petr Vorel
Hi,
Quoted 14 lines · Cyril Hrubis
Quoted 13 lines
...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static struct tst_test test = { + .min_kver = "5.2",I suggest removing .min_kver check in all of the tests to let they can be running on many distributions(which backport the features).
If we do that we have to explicitely check for ENOSYS errno in each test, quite possibly with a dummy call to the tested syscall in test setup, because once these calls gets libc wrappers we will no longer call the
tst_syscall()that checks for it.
Quoted 3 lines
Quoted 2 lines
+1 add dummy call to the tested syscall in the setup. Agree, thanks for point out this.
Could anybody add it to
fsmount/fsmount01.cinstead?
I am doing it.
Signature · 1 line
viresh
PATCH 3/7 syscalls/fsconfig: New tests
In reply to Viresh KumarAdd tests to check working of fsconfig() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 ++ .../kernel/syscalls/fsconfig/fsconfig01.c | 77 +++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 97 +++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c
configure.ac +1 -0
@@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \ execveat \ fallocate \ fchownat \ + fsconfig \ fsopen \ fstatat \ getdents \
runtest/syscalls +3 -0
@@ -542,6 +542,9 @@ fanotify13 fanotify13 fanotify14 fanotify14 fanotify15 fanotify15 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsopen01 fsopen01 fsopen02 fsopen02
testcases/kernel/syscalls/fsconfig/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +fsconfig01 +fsconfig02
testcases/kernel/syscalls/fsconfig/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +77 -0
77 lines not on this page · raw message
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +97 -0
97 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 4/7 syscalls/fsmount: New tests
In reply to Viresh KumarAdd tests to check working of fsmount() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fsmount/.gitignore | 2 + testcases/kernel/syscalls/fsmount/Makefile | 6 ++ testcases/kernel/syscalls/fsmount/fsmount01.c | 71 ++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount02.c | 83 +++++++++++++++++++ 6 files changed, 166 insertions(+) create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore create mode 100644 testcases/kernel/syscalls/fsmount/Makefile create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c
configure.ac +1 -0
@@ -81,6 +81,7 @@ AC_CHECK_FUNCS([ \ fallocate \ fchownat \ fsconfig \ + fsmount \ fsopen \ fstatat \ getdents \
runtest/syscalls +3 -0
@@ -545,6 +545,9 @@ fanotify15 fanotify15 fsconfig01 fsconfig01 fsconfig02 fsconfig02 +fsmount01 fsmount01 +fsmount02 fsmount02 + fsopen01 fsopen01 fsopen02 fsopen02
testcases/kernel/syscalls/fsmount/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +fsmount01 +fsmount02
testcases/kernel/syscalls/fsmount/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsmount/fsmount01.c new file +71 -0
71 lines not on this page · raw message
testcases/kernel/syscalls/fsmount/fsmount02.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 4/7 syscalls/fsmount: New tests
Viresh Kumar <[email protected]> wrote:
....
testcases/kernel/syscalls/fsmount/fsmount01.c line 9
Quoted 9 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +8
-0+/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsmount() test. +*/ +#include "tst_test.h" +#include "lapi/fsmount.h"
Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems we have to do this for all the tests involves ?AT_FDCWD?.
+
testcases/kernel/syscalls/fsmount/fsmount01.c line 43
Quoted 6 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +4
-0+static void run (void ) +{ + +TEST (fsmount (fd,0 ,0 ));
As this fsmount01.c is duplicated with zlang@'s patch, I suggest rewriting an enhancement version maybe name fsmount02.c to cover more fsmount attributes. Since it is named basic fsmount() test, it shouldn't only test fsmount(fd, 0, 0), right?
+#define MOUNT_ATTR_RDONLY 0x00000001 /* Mount read-only */ +#define MOUNT_ATTR_NOSUID 0x00000002 /* Ignore suid and sgid bits */ +#define MOUNT_ATTR_NODEV 0x00000004 /* Disallow access to device
special files */
+#define MOUNT_ATTR_NOEXEC 0x00000008 /* Disallow program execution */
+#define MOUNT_ATTR__ATIME 0x00000070 /* Setting on how atime should
be updated */
+#define MOUNT_ATTR_RELATIME 0x00000000 /* - Update atime relative to
mtime/ctime. */
+#define MOUNT_ATTR_NOATIME 0x00000010 /* - Do not update access times.
*/
+#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
+#define MOUNT_ATTR_NODIRATIME 0x00000080 /* Do not update directory access times */
testcases/kernel/syscalls/fsmount/fsmount01.c line 51
Quoted 9 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +8
-0+if (TST_RET ==-1 ) +tst_brk (TFAIL |TERRNO ,"fsmount() failed" ); + + fsmfd =TST_RET ; + +TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); +SAFE_CLOSE (fsmfd);
I guess we probably need a way to verify the move_mount() does work. The function ismount() in zlang@'s patch could be extracted into the library as tst_ismount() for all of these tests.
@Petr Vorel <[email protected]> WDT?
testcases/kernel/syscalls/fsmount/fsmount01.c line 57
Quoted 7 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +6
-0+ +if (TST_RET ==-1 ) +tst_brk (TBROK |TERRNO ,"move_mount() failed" ); + +SAFE_CLOSE (TST_RET ); +TEST (umount (MNTPOINT ));
SAFE_UMOUNT(MNTPOINT);
+
testcases/kernel/syscalls/fsmount/fsmount01.c line 62
Quoted 5 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +4
-0+tst_res (TPASS ,"fsmount() passed" ); +} + +static struct tst_test test = {
Suggest referring to my previous comments for this part.
+ .min_kver = "5.2",
Quoted 9 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +8
-0+ .test_all = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .needs_tmpdir = 1, + .format_device = 1, + .mntpoint = MNTPOINT, +};
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/0678ec1f/attachment.htm>
PATCH 4/7 syscalls/fsmount: New tests
Quoted 15 lines · Li Wang
Viresh Kumar <[email protected]> wrote:
....
testcases/kernel/syscalls/fsmount/fsmount01.c line 9
Quoted 9 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +8
-0+/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsmount() test. +*/ +#include "tst_test.h" +#include "lapi/fsmount.h" Adding #include "
lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems we have to do this for all the tests involves ?AT_FDCWD?.
my fsmount.h header includes <fcntl.h>, won't that be enough ?
Quoted 20 lines
+
testcases/kernel/syscalls/fsmount/fsmount01.c line 43
Quoted 6 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +4
-0+static void run (void ) +{ + +TEST (fsmount (fd,0 ,0 ));As this
fsmount01.cis duplicated with zlang@'s patch, I suggest rewriting an enhancement version maybe namefsmount02.cto cover more fsmount attributes. Since it is named basicfsmount()test, it shouldn't only testfsmount(fd, 0, 0), right?(quoted diff) +3
-0+#define MOUNT_ATTR_RDONLY 0x00000001 /* Mount read-only */ +#define MOUNT_ATTR_NOSUID 0x00000002 /* Ignore suid and sgid bits */ +#define MOUNT_ATTR_NODEV 0x00000004 /* Disallow access to devicespecial files */
(quoted diff) +2
-0+#define MOUNT_ATTR_NOEXEC 0x00000008 /* Disallow program execution */ +#define MOUNT_ATTR__ATIME 0x00000070 /* Setting on how atime shouldbe updated */
Quoted 8 lines
+#define
MOUNT_ATTR_RELATIME0x00000000/* - Update atime relative to
mtime/ctime. */
+#defineMOUNT_ATTR_NOATIME0x00000010/* - Do not update access times.
*/
+#defineMOUNT_ATTR_STRICTATIME0x00000020/* - Always perform atime updates */
+#defineMOUNT_ATTR_NODIRATIME0x00000080/* Do not update directory access times */
Okay, I will give it a try.
Quoted 6 lines
Quoted 6 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +6
-0+if (TST_RET ==-1 ) +tst_brk (TFAIL |TERRNO ,"fsmount() failed" ); + + fsmfd =TST_RET ; + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
Quoted 8 lines
testcases/kernel/syscalls/fsmount/fsmount01.c line 51
Quoted 3 lines
testcases/kernel/syscalls/fsmount/fsmount01.c new file +2
-0+ MOVE_MOUNT_F_EMPTY_PATH)); +SAFE_CLOSE (fsmfd);I guess we probably need a way to verify the
move_mount()does work. The functionismount()in zlang@'s patch could be extracted into the library astst_ismount()for all of these tests.
@Petr Vorel <[email protected]> WDT?
Yeah, I will do that.
Signature · 1 line
viresh
PATCH 4/7 syscalls/fsmount: New tests
Quoted 6 lines · Viresh Kumar
...
Quoted 2 lines
Adding #include "
lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems we have to do this for all the tests involves ?AT_FDCWD?.my
fsmount.hheader includes <fcntl.h>, won't that be enough ?
I'm afraid it's not enough.
After having a closer look, the reason is that the AT_FDCWD is defined with condition __USE_ATFILE, the __USE_ATFILE depends on _ATFILE_SOURCE defined, and _ATFILE_SOURCE needs enable _GNU_SOURCE.
So another effective way is to add '#define _GNU_SOURCE' in front of your test then that <fcntl.h> will be work for you.
# rpm -qa glibc-headers glibc-headers-2.5-123
# cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2
#ifdef __USE_ATFILE
# define AT_FDCWD -100 /* Special value used to indicate
the *at functions should
use the
current working directory.
*/Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/cccc37ee/attachment.htm>
PATCH 4/7 syscalls/fsmount: New tests
Hi Li,
Quoted 10 lines
Quoted 5 lines · Viresh Kumar
...
Quoted 2 lines
Adding #include "
lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems we have to do this for all the tests involves ?AT_FDCWD?.my
fsmount.hheader includes <fcntl.h>, won't that be enough ?
Quoted 8 lines
I'm afraid it's not enough.
After having a closer look, the reason is that the
AT_FDCWDis defined with condition__USE_ATFILE, the__USE_ATFILEdepends on_ATFILE_SOURCEdefined, and_ATFILE_SOURCEneeds enable_GNU_SOURCE.So another effective way is to add '#define
_GNU_SOURCE' in front of your test then that <fcntl.h> will be work for you.
OK, we can add #define _GNU_SOURCE to fsmount01.c, which actually needs it
+ keep <fcntl.h> there and load lapi/fsmount.h later (see below). But generally this will be the approach for all uses of <fcntl.h> (and probably some other headers) for old distros. IMHO this change is caused by:
c941736c92 Remove _BSD_SOURCE and _SVID_SOURCE. (glibc-2.20) c688b41960 Add _DEFAULT_SOURCE feature test macro. (glibc-2.19)
So we can either add it to many places or detect this old glibc and compile with -D_GNU_SOURCE (but this might break other things).
But that's another story.
Quoted 10 lines
# rpm -qa glibc-headers glibc-headers-2.5-123# cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2 #ifdef __USE_ATFILE # define AT_FDCWD -100 /* Special value used to indicate the *at functions should use the current working directory. */
So is this diff to v7 better?
Kind regards,
Petr
kernel/syscalls/fsmount/fsmount01.c +2 -1
@@ -7,10 +7,11 @@* to mount a filesystem without any specified mount options. */ +#define _GNU_SOURCE#include <sys/mount.h> +#include <fcntl.h> #include "tst_test.h" -#include "lapi/fcntl.h" #include "lapi/fsmount.h" #include "tst_safe_stdio.h"
PATCH 4/7 syscalls/fsmount: New tests
Quoted 23 lines · Petr Vorel
Hi Li,
Quoted 5 lines
Quoted 2 lines · Viresh Kumar
...
Quoted 1 line
Adding #include "
lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. Itseems
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
we have to do this for all the tests involves ?AT_FDCWD?.
my
fsmount.hheader includes <fcntl.h>, won't that be enough ?I'm afraid it's not enough.
After having a closer look, the reason is that the
AT_FDCWDis definedwith
Quoted 5 lines
condition
__USE_ATFILE, the__USE_ATFILEdepends on_ATFILE_SOURCEdefined, and_ATFILE_SOURCEneeds enable_GNU_SOURCE.So another effective way is to add '#define
_GNU_SOURCE' in front of your test then that <fcntl.h> will be work for you.
Quoted 9 lines
OK, we can add #define
_GNU_SOURCEtofsmount01.c, which actually needs it
+ keep <fcntl.h> there and loadlapi/fsmount.hlater (see below). But generally this will be the approach for all uses of <fcntl.h> (and probably
some other headers) for old distros. IMHO this change is caused by:
c941736c92Remove_BSD_SOURCEand_SVID_SOURCE. (glibc-2.20)c688b41960Add_DEFAULT_SOURCEfeature test macro. (glibc-2.19)
Thanks for figure out this.
Quoted 5 lines
So we can either add it to many places or detect this old glibc and compile with
-D_GNU_SOURCE (but this might break other things).
-1 remove old Glibc is a bad choice.
Quoted 11 lines
But that's another story.
Quoted 9 lines
# rpm -qa glibc-headers glibc-headers-2.5-123# cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2 #ifdef __USE_ATFILE # define AT_FDCWD -100 /* Special value used to indicate the *at functions should use the current working
Quoted 5 lines
directory.
Quoted 1 line
*/
So is this diff to v7 better?
To use "lapi/fcntl.h" in v7 is simpler I guess, sometimes we just need to get compile pass on old distros but not perform it indeed. And that's the purpose why we need lapi/*.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/8ae9c1ca/attachment.htm>
PATCH 4/7 syscalls/fsmount: New tests
Quoted 8 lines · Li Wang
...
Quoted 4 lines
So we can either add it to many places or detect this old glibc and compile with
-D_GNU_SOURCE (but this might break other things).-1 remove old Glibc is a bad choice.
Sorry, that's a typo. I mean detect Glibc version is not a good idea:).
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/e3e0e552/attachment.htm>
PATCH 4/7 syscalls/fsmount: New tests
Hi Li,
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
So we can either add it to many places or detect this old glibc and compile with
-D_GNU_SOURCE (but this might break other things).-1 remove old Glibc is a bad choice.
Sorry, that's a typo. I mean detect Glibc version is not a good idea:).
Agree. IMHO mostly we should use lapi than libc headers (+ put system headers into lapi files), that'd keep old distros working.
Kind regards,
Petr
PATCH 4/7 syscalls/fsmount: New tests
In reply to Viresh KumarQuoted 17 lines · Li Wang
Quoted 15 lines
Viresh Kumar <[email protected]> wrote:
....
Review
Quoted 8 lines
(quoted diff) +8
-0+/* + * Copyright (c) 2020 Viresh Kumar <[email protected]> + * + * Description: + * Basic fsmount() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h"Adding #include "
lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems we have to do this for all the tests involves ?AT_FDCWD?.
Quoted 1 line
my
fsmount.hheader includes <fcntl.h>, won't that be enough ?
Unfortunately it won't be enough. LAPI files are here for adding missing definitions in old distros, which is exactly the case for AT_FDCWD on old RHEL.
I also suggest following change to v7, see diff below (fsmount.h using "lapi/fcntl.h", thus not needed in fsmount01.c).
Quoted 11 lines
Quoted 11 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+static void run(void) +{ + + TEST(fsmount(fd, 0, 0));As this
fsmount01.cis duplicated with zlang@'s patch, I suggest rewriting an enhancement version maybe namefsmount02.cto cover more fsmount attributes. Since it is named basicfsmount()test, it shouldn't only testfsmount(fd, 0, 0), right?
+1.
Quoted 9 lines
Quoted 9 lines
(quoted diff) +3
-0+#define MOUNT_ATTR_RDONLY 0x00000001 /* Mount read-only */ +#define MOUNT_ATTR_NOSUID 0x00000002 /* Ignore suid and sgid bits */ +#define MOUNT_ATTR_NODEV 0x00000004 /* Disallow access to devicespecial files */
(quoted diff) +2
-0+#define MOUNT_ATTR_NOEXEC 0x00000008 /* Disallow program execution */ +#define MOUNT_ATTR__ATIME 0x00000070 /* Setting on how atime shouldbe updated */
+#defineMOUNT_ATTR_RELATIME0x00000000/* - Update atime relative to
mtime/ctime. */
Quoted 8 lines
Quoted 6 lines
+#define
MOUNT_ATTR_NOATIME0x00000010/* - Do not update access times.
*/
+#defineMOUNT_ATTR_STRICTATIME0x00000020/* - Always perform atime updates */
+#defineMOUNT_ATTR_NODIRATIME0x00000080/* Do not update directory access times */Okay, I will give it a try.
Great thanks!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +6
-0+ if (TST_RET == -1) + tst_brk(TFAIL | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd);I guess we probably need a way to verify the
move_mount()does work. The functionismount()in zlang@'s patch could be extracted into the library astst_ismount()for all of these tests.
@Petr Vorel <[email protected]> WDT?
Quoted 1 line
Yeah, I will do that.
+1. But I'd suggest to first merge tests which I sent as v7 [1] (with change below) and then doing this.
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/project/ltp/list/?series=158902&state=*
[2] https://travis-ci.org/pevik/ltp/builds/651390749
lapi/fsmount.h +2 -2
@@ -7,12 +7,12 @@#ifndef FSMOUNT_H__ #define FSMOUNT_H__ -#include <fcntl.h> +#include "config.h" #include <sys/mount.h> #include <sys/syscall.h> #include <sys/types.h> -#include "config.h" +#include "lapi/fcntl.h" #include "lapi/syscalls.h" #ifndef HAVE_FSOPEN
kernel/syscalls/fsmount/fsmount01.c +0 -1
@@ -10,7 +10,6 @@#include <sys/mount.h> #include "tst_test.h" -#include "lapi/fcntl.h" #include "lapi/fsmount.h" #include "tst_safe_stdio.h"
PATCH 5/7 syscalls/move_mount: New tests
In reply to Viresh KumarAdd tests to check working of move_mount() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 ++ .../kernel/syscalls/move_mount/move_mount01.c | 82 ++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 102 ++++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c
configure.ac +1 -0
@@ -91,6 +91,7 @@ AC_CHECK_FUNCS([ \ mkdirat \ mknodat \ modify_ldt \ + move_mount \ name_to_handle_at \ openat \ pidfd_open \
runtest/syscalls +3 -0
@@ -731,6 +731,9 @@ mount04 mount04 mount05 mount05 mount06 mount06 +move_mount01 move_mount01 +move_mount02 move_mount02 + move_pages01 move_pages01 move_pages02 move_pages02 move_pages03 move_pages03
testcases/kernel/syscalls/move_mount/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +move_mount01 +move_mount02
testcases/kernel/syscalls/move_mount/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/move_mount/move_mount01.c new file +82 -0
82 lines not on this page · raw message
testcases/kernel/syscalls/move_mount/move_mount02.c new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 6/7 syscalls/fspick: New tests
In reply to Viresh KumarAdd tests to check working of fspick() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 ++ testcases/kernel/syscalls/fspick/fspick01.c | 104 ++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 110 ++++++++++++++++++++ 6 files changed, 226 insertions(+) create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c
configure.ac +1 -0
@@ -81,6 +81,7 @@ AC_CHECK_FUNCS([ \ fallocate \ fchownat \ fsconfig \ + fspick \ fsmount \ fsopen \ fstatat \
runtest/syscalls +3 -0
@@ -545,6 +545,9 @@ fanotify15 fanotify15 fsconfig01 fsconfig01 fsconfig02 fsconfig02 +fspick01 fspick01 +fspick02 fspick02 + fsmount01 fsmount01 fsmount02 fsmount02
testcases/kernel/syscalls/fspick/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +fspick01 +fspick02
testcases/kernel/syscalls/fspick/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fspick/fspick01.c new file +104 -0
104 lines not on this page · raw message
testcases/kernel/syscalls/fspick/fspick02.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH 7/7 syscalls/open_tree: New tests
In reply to Viresh KumarAdd tests to check working of open_tree() syscall.
--- configure.ac | 1 + runtest/syscalls | 3 + .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 110 +++++++++++++++++ 6 files changed, 237 insertions(+) create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
configure.ac +1 -0
@@ -95,6 +95,7 @@ AC_CHECK_FUNCS([ \ move_mount \ name_to_handle_at \ openat \ + open_tree \ pidfd_open \ pidfd_send_signal \ pkey_mprotect \
runtest/syscalls +3 -0
@@ -844,6 +844,9 @@ openat01 openat01 openat02 openat02 openat03 openat03 +open_tree01 open_tree01 +open_tree02 open_tree02 + mincore01 mincore01 mincore02 mincore02
testcases/kernel/syscalls/open_tree/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +open_tree01 +open_tree02
testcases/kernel/syscalls/open_tree/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/open_tree/open_tree01.c new file +115 -0
115 lines not on this page · raw message
testcases/kernel/syscalls/open_tree/open_tree02.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
cover Add new LTP tests related to fsmount family of syscalls
In reply to Viresh KumarQuoted 4 lines · Viresh Kumar
Hello,
This series adds a bunch of LTP tests related to fsmount family of syscalls.
Hi Viresh,
Thanks for all these cases, that's really helpful.
Although you write cases for each new mount API, each xxxxx01.c case looks nearly do same things.
That's why I only wrote one case for new-mount currently, due to basic mount test already can through most of new APIs(except open_tree and fspick). I don't know if we should write nearly same things in different directories. Actually I prepared open_tree and fspick test cases(planned to name as newmount02 and newmount03. but the newmount01 has been changed to fsmount01 :), but didn't sent out, due to I hope to the first case(which does basic changes) can be merged at first.
All of your xxxxx02.c cases are great! I planned to test more different parameters of fsconfig() later too. Your invalid parameters test are nice. As you've sent these cases, I think these should be reviewed at first, avoid we do same things:) I'll try to help to review V2 patchset too, if I can:-P
Thanks,
Zorro
Quoted 76 lines
Thanks
--
vireshViresh Kumar (7):
lapi/fsmount: Add definitions for fsmount related syscalls syscalls/fsopen: New tests
syscalls/fsconfig: New tests
syscalls/fsmount: New tests
syscalls/move_mount: New tests
syscalls/fspick: New tests
syscalls/open_tree: New testsconfigure.ac | 6 + include/lapi/fsmount.h | 134 ++++++++++++++++++ runtest/syscalls | 18 +++ testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 77 ++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 97 +++++++++++++ testcases/kernel/syscalls/fsmount/.gitignore | 2 + testcases/kernel/syscalls/fsmount/Makefile | 6 + testcases/kernel/syscalls/fsmount/fsmount01.c | 71 ++++++++++ testcases/kernel/syscalls/fsmount/fsmount02.c | 83 +++++++++++ testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 + testcases/kernel/syscalls/fsopen/fsopen01.c | 71 ++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++ testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 + testcases/kernel/syscalls/fspick/fspick01.c | 104 ++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 110 ++++++++++++++ .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 + .../kernel/syscalls/move_mount/move_mount01.c | 82 +++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 102 +++++++++++++ .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 +++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 110 ++++++++++++++ 27 files changed, 1284 insertions(+) create mode 100644 include/lapi/fsmount.h create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore create mode 100644 testcases/kernel/syscalls/fsmount/Makefile create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.cSignature · 5 lines
2.21.0.rc0.269.g1a574e7a288b -- Mailing list info: https://lists.linux.it/listinfo/ltp
cover Add new LTP tests related to fsmount family of syscalls
Quoted 6 lines · Zorro Lang
Quoted 4 lines · Viresh Kumar
Hello,
This series adds a bunch of LTP tests related to fsmount family of syscalls.
Quoted 7 lines
Hi Viresh,
Thanks for all these cases, that's really helpful.
Although you write cases for each new mount API, each
xxxxx01.ccase looks nearly do same things.
Yes, I have the same feelings. Below are my 2 cents:
Probably because the APIs should be used to bind together, but it is best to reflect the focus of each test case. e.g. fsmount01.c as basic test needs to cover more parameters to verify that all the functionality is really working. fsmount02.c more like a test target for all error conditions.
FYI madvise test:
[1]
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise01.c
[2]
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise02.c
Quoted 4 lines
That's why I only wrote one case for new-mount currently, due to basic mount
test already can through most of newAPIs(except open_tree and fspick). I don't
Quoted 9 lines
know if we should write nearly same things in different directories. Actually I prepared
open_treeand fspick test cases(planned to name as newmount02
and newmount03. but the newmount01 has been changed to fsmount01 :), but didn't
sent out, due to I hope to the first case(which does basic changes) can be merged
at first.
It'd be great if those tests can be merged together with Viresh's patch.
Quoted 7 lines
All of your
xxxxx02.ccases are great! I planned to test more different parameters offsconfig()later too. Your invalid parameters test are nice. As you've sent these cases, I think these should be reviewed at first, avoid
we do same things:) I'll try to help to review V2 patchset too, if I can:-P
Thank you in advance, Zorro!
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/414e45c5/attachment-0001.htm>
cover Add new LTP tests related to fsmount family of syscalls
In reply to Zorro LangHi Zorro,
Thanks for taking time and providing your feedback :)
Quoted 5 lines · Zorro Lang
On Fri, Feb 14, 2020 at 05:05:49PM +0530, Viresh Kumar wrote:
Thanks for all these cases, that's really helpful.Although you write cases for each new mount API, each
xxxxx01.ccase looks nearly do same things.
I agree, just that they are all slightly different, and perhaps they can be improved to test different parameters for the success case as well.
I think all the *02.c files are quite different that way, and perhaps *01.c tests should do the same.
Quoted 7 lines
That's why I only wrote one case for new-mount currently, due to basic mount test already can through most of new
APIs(except open_tree and fspick). I don't know if we should write nearly same things in different directories. Actually I preparedopen_treeand fspick test cases(planned to name as newmount02 and newmount03. but the newmount01 has been changed to fsmount01 :), but didn't sent out, due to I hope to the first case(which does basic changes) can be merged at first.
Heh. I had no clue that anyone else is working on this stuff else I won't have touched it at all (and saved some time) :)
Quoted 4 lines
All of your
xxxxx02.ccases are great! I planned to test more different parameters offsconfig()later too. Your invalid parameters test are nice. As you've sent these cases, I think these should be reviewed at first, avoid we do same things:) I'll try to help to review V2 patchset too, if I can:-P
Thanks for suggesting this way out, and I agree 100% with you.
FWIW, I am working on V2 which I should be able to send by tomorrow max (if everything goes as planned). Lets see how it looks after that and I would love to review any improvement patches you may have after these are merged (Please cc me directly, I haven't opted for receiving emails from ltp list).
Signature · 1 line
viresh