Message ID | 6ac7573e8ea5ab6f0ab9256b73802126d72b5156.1582104018.git.viresh.kumar@linaro.org |
---|---|
State | Changes Requested |
Headers | show |
Series | Add new LTP tests related to fsmount family of syscalls | expand |
On Wed, Feb 19, 2020 at 5:28 PM Viresh Kumar <viresh.kumar@linaro.org> wrote: > Add tests to check working of fsconfig() syscall. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- > runtest/syscalls | 3 + > testcases/kernel/syscalls/fsconfig/.gitignore | 2 + > testcases/kernel/syscalls/fsconfig/Makefile | 6 + > .../kernel/syscalls/fsconfig/fsconfig01.c | 110 ++++++++++++++++++ > .../kernel/syscalls/fsconfig/fsconfig02.c | 100 ++++++++++++++++ > 5 files changed, 221 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 > > diff --git a/runtest/syscalls b/runtest/syscalls > index f113342f0ded..4fcbd5f710eb 100644 > --- a/runtest/syscalls > +++ b/runtest/syscalls > @@ -341,6 +341,9 @@ fpathconf01 fpathconf01 > fremovexattr01 fremovexattr01 > fremovexattr02 fremovexattr02 > > +fsconfig01 fsconfig01 > +fsconfig02 fsconfig02 > + > fsmount01 fsmount01 > > fsopen01 fsopen01 > diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore > b/testcases/kernel/syscalls/fsconfig/.gitignore > new file mode 100644 > index 000000000000..2bc54b82751b > --- /dev/null > +++ b/testcases/kernel/syscalls/fsconfig/.gitignore > @@ -0,0 +1,2 @@ > +/fsconfig01 > +/fsconfig02 > diff --git a/testcases/kernel/syscalls/fsconfig/Makefile > b/testcases/kernel/syscalls/fsconfig/Makefile > new file mode 100644 > index 000000000000..5ea7d67db123 > --- /dev/null > +++ b/testcases/kernel/syscalls/fsconfig/Makefile > @@ -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 > diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig01.c > b/testcases/kernel/syscalls/fsconfig/fsconfig01.c > new file mode 100644 > index 000000000000..96bf8eef8e4b > --- /dev/null > +++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c > @@ -0,0 +1,110 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org> > + * > + * Description: > + * Basic fsconfig() test which tries to configure and mount the > filesystem as > + * well. > + */ > +#include "tst_test.h" > +#include "lapi/fsmount.h" > + > +#define MNTPOINT "mntpoint" > + > +static void setup(void) > +{ > + fsopen_supported_by_kernel(); > +} > + > +static void run(void) > +{ > + int fd, fsmfd; > + > + TEST(fsopen(tst_device->fs_type, 0)); > + fd = TST_RET; > + > + if (fd == -1) > + tst_brk(TBROK | TERRNO, "fsopen() failed"); > + > + TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0)); > + if (TST_RET == -1) { > + tst_res(TFAIL | TERRNO, "fsconfig() failed"); > + goto out; > + } > + > + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, > 0)); > + if (TST_RET == -1) { > + tst_res(TFAIL | TERRNO, "fsconfig() failed"); > + goto out; > + } > + > + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev, > AT_FDCWD)); > + if (TST_RET == -1) { > + if (TST_ERR == EOPNOTSUPP) { > + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH not > supported"); > + } else { > + tst_res(TFAIL | TERRNO, "fsconfig() failed"); > The test reports an EINVAL error when testing fsconfig() with 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue. kernel: 5.6.0-rc2+ x86_64 tst_test.c:1278: INFO: Testing on xfs tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:46: FAIL: fsconfig() failed: EINVAL (22)
On 20-02-20, 13:41, Li Wang wrote: > > + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev, > > AT_FDCWD)); > > + if (TST_RET == -1) { > > + if (TST_ERR == EOPNOTSUPP) { > > + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH not > > supported"); On my ARM setup, I always hit this path for few of the syscalls :( > > + } else { > > + tst_res(TFAIL | TERRNO, "fsconfig() failed"); > > > > The test reports an EINVAL error when testing fsconfig() with > 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue. > > kernel: 5.6.0-rc2+ x86_64 > > tst_test.c:1278: INFO: Testing on xfs > tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' > tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s > fsconfig01.c:46: FAIL: fsconfig() failed: EINVAL (22) Both "foo" and tst_device->dev may be wrong here unfortunately. Same for few other commands like: _PATH, _PATH_EMPTY, _FD..
On Thu, Feb 20, 2020 at 1:50 PM Viresh Kumar <viresh.kumar@linaro.org> wrote: > On 20-02-20, 13:41, Li Wang wrote: > > > + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev, > > > AT_FDCWD)); > > > + if (TST_RET == -1) { > > > + if (TST_ERR == EOPNOTSUPP) { > > > + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH > not > > > supported"); > > On my ARM setup, I always hit this path for few of the syscalls :( > > > > + } else { > > > + tst_res(TFAIL | TERRNO, "fsconfig() failed"); > > > > > > > The test reports an EINVAL error when testing fsconfig() with > > 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue. > > > > kernel: 5.6.0-rc2+ x86_64 > > > > tst_test.c:1278: INFO: Testing on xfs > > tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' > > tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s > > fsconfig01.c:46: FAIL: fsconfig() failed: EINVAL (22) > > Both "foo" and tst_device->dev may be wrong here unfortunately. Same > for few other commands like: _PATH, _PATH_EMPTY, _FD.. > If the parameter '_key' is replaced by 'ro' or 'rw', then the test always gets passed, the same behavior occurred in fspick01 too. I'm not sure if the usage is correct for fsconfig(), it'd be great if FS guys could give advice.
Hi Li, > The test reports an EINVAL error when testing fsconfig() with > 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue. > kernel: 5.6.0-rc2+ x86_64 Confirmed, with this XFS config: CONFIG_XFS_FS=y # CONFIG_XFS_QUOTA is not set # CONFIG_XFS_POSIX_ACL is not set # CONFIG_XFS_RT is not set # CONFIG_XFS_ONLINE_SCRUB is not set # CONFIG_XFS_WARN is not set # CONFIG_XFS_DEBUG is not set # CONFIG_VXFS_FS is not set I'll have a look on it on Monday. Kind regards, Petr > tst_test.c:1278: INFO: Testing on xfs > tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' > tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s > fsconfig01.c:46: FAIL: fsconfig() failed: EINVAL (22)
diff --git a/runtest/syscalls b/runtest/syscalls index f113342f0ded..4fcbd5f710eb 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -341,6 +341,9 @@ fpathconf01 fpathconf01 fremovexattr01 fremovexattr01 fremovexattr02 fremovexattr02 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsmount01 fsmount01 fsopen01 fsopen01 diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore new file mode 100644 index 000000000000..2bc54b82751b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/.gitignore @@ -0,0 +1,2 @@ +/fsconfig01 +/fsconfig02 diff --git a/testcases/kernel/syscalls/fsconfig/Makefile b/testcases/kernel/syscalls/fsconfig/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/Makefile @@ -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 diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig01.c b/testcases/kernel/syscalls/fsconfig/fsconfig01.c new file mode 100644 index 000000000000..96bf8eef8e4b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org> + * + * Description: + * Basic fsconfig() test which tries to configure and mount the filesystem as + * well. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void setup(void) +{ + fsopen_supported_by_kernel(); +} + +static void run(void) +{ + int fd, fsmfd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev, AT_FDCWD)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH_EMPTY, "foo", tst_device->dev, AT_FDCWD)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_FD, "foo", NULL, 0)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_FD not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | 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; + } + + if (!tst_ismount(MNTPOINT)) + tst_res(TPASS, "fsconfig() passed"); + + SAFE_UMOUNT(MNTPOINT); + +out: + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig02.c b/testcases/kernel/syscalls/fsconfig/fsconfig02.c new file mode 100644 index 000000000000..b892f303690b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig02.c @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org> + * + * Description: + * Basic fsconfig() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +int fd = -1, temp_fd = -1, invalid_fd = -1; +int aux_0 = 0, aux_1 = 1, aux_fdcwd = AT_FDCWD, aux_minus1 = -1; + +static struct tcase { + char *name; + int *fd; + unsigned int cmd; + const char *key; + const void *value; + int *aux; + int exp_errno; +} tcases[] = { + {"invalid-fd", &invalid_fd, FSCONFIG_SET_FLAG, "user_xattr", NULL, &aux_0, EINVAL}, + {"invalid-cmd", &fd, 100, "rw", NULL, &aux_0, EOPNOTSUPP}, + {"set-flag-key", &fd, FSCONFIG_SET_FLAG, NULL, NULL, &aux_0, EINVAL}, + {"set-flag-value", &fd, FSCONFIG_SET_FLAG, "rw", "foo", &aux_0, EINVAL}, + {"set-flag-aux", &fd, FSCONFIG_SET_FLAG, "rw", NULL, &aux_1, EINVAL}, + {"set-string-key", &fd, FSCONFIG_SET_STRING, NULL, "#grand.central.org:root.cell.", &aux_0, EINVAL}, + {"set-string-value", &fd, FSCONFIG_SET_STRING, "source", NULL, &aux_0, EINVAL}, + {"set-string-aux", &fd, FSCONFIG_SET_STRING, "source", "#grand.central.org:root.cell.", &aux_1, EINVAL}, + {"set-binary-key", &fd, FSCONFIG_SET_BINARY, NULL, "foo", &aux_1, EINVAL}, + {"set-binary-value", &fd, FSCONFIG_SET_BINARY, "sync", NULL, &aux_1, EINVAL}, + {"set-binary-aux", &fd, FSCONFIG_SET_BINARY, "sync", "foo", &aux_0, EINVAL}, + {"set-path-key", &fd, FSCONFIG_SET_PATH, NULL, "/dev/sda1", &aux_fdcwd, EINVAL}, + {"set-path-value", &fd, FSCONFIG_SET_PATH, "sync", NULL, &aux_fdcwd, EINVAL}, + {"set-path-aux", &fd, FSCONFIG_SET_PATH, "sync", "/dev/sda1", &aux_minus1, EINVAL}, + {"set-path-empty-key", &fd, FSCONFIG_SET_PATH_EMPTY, NULL, "/dev/foo", &aux_fdcwd, EINVAL}, + {"set-path-empty-value", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", NULL, &aux_fdcwd, EINVAL}, + {"set-path-empty-aux", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", "/dev/foo", &aux_minus1, EINVAL}, + {"set-fd-key", &fd, FSCONFIG_SET_FD, NULL, NULL, &temp_fd, EINVAL}, + {"set-fd-value", &fd, FSCONFIG_SET_FD, "sync", "foo", &temp_fd, EINVAL}, + {"set-fd-aux", &fd, FSCONFIG_SET_FD, "sync", NULL, &aux_minus1, EINVAL}, + {"cmd-create-key", &fd, FSCONFIG_CMD_CREATE, "foo", NULL, &aux_0, EINVAL}, + {"cmd-create-value", &fd, FSCONFIG_CMD_CREATE, NULL, "foo", &aux_0, EINVAL}, + {"cmd-create-aux", &fd, FSCONFIG_CMD_CREATE, NULL, NULL, &aux_1, EINVAL}, + {"cmd-reconfigure-key", &fd, FSCONFIG_CMD_RECONFIGURE, "foo", NULL, &aux_0, EINVAL}, + {"cmd-reconfigure-value", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, "foo", &aux_0, EINVAL}, + {"cmd-reconfigure-aux", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, &aux_1, EINVAL}, +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + temp_fd = open("testfile", O_RDWR | O_CREAT, 01444); + if (temp_fd == -1) + tst_res(TBROK, "Can't obtain temp_fd, open() failed"); +} + +static void cleanup(void) +{ + if (temp_fd != -1) + SAFE_CLOSE(temp_fd); + if (fd != -1) + SAFE_CLOSE(fd); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(fsconfig(*tc->fd, tc->cmd, tc->key, tc->value, *tc->aux)); + + if (TST_RET != -1) { + tst_brk(TFAIL, "%s: fsconfig() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: fsconfig() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fsconfig() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .needs_device = 1, +};
Add tests to check working of fsconfig() syscall. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 110 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 100 ++++++++++++++++ 5 files changed, 221 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