All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls
@ 2020-02-19  9:27 Viresh Kumar
  2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
                   ` (9 more replies)
  0 siblings, 10 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:27 UTC (permalink / raw)
  To: ltp

Hello,

Here is the second version of my work rebased over the latest changes
pushed around fsmount work by Zorro.

V1->V2:
- Lots of changes, really :)
- Rebased over Zorro's work with fsmount.
- The success tests are modified to test all possible flags, attributes
  as well.
- Create tst_ismount() and fsopen_supported_by_kernel() helpers.
- Verify if mount is successful or not using tst_ismount().
- Remove min_kver and instead check if older kernels have patches
  backported or not.
- Test on multiple filesystems.
- Better handling of failures during setup/run callbacks.
- One of the patches around fsmount.h is already merged, dropped it now.
- Other minor cleanups.

Viresh Kumar (10):
  tst_device: Add tst_ismount() helper
  lapi/fsmount.h: Add fsopen_supported_by_kernel()
  lapi/fsmount.h: Include "lapi/fcntl.h"
  syscalls/fsopen: New tests
  syscalls/fsconfig: New tests
  syscalls/fsmount: Improve fsmount01 test
  syscalls/fsmount: Add failure tests
  syscalls/move_mount: New tests
  syscalls/fspick: New tests
  syscalls/open_tree: New tests

 include/lapi/fsmount.h                        |  11 +-
 include/tst_device.h                          |   6 +
 lib/tst_device.c                              |  25 ++++
 runtest/syscalls                              |  16 +++
 testcases/kernel/syscalls/fsconfig/.gitignore |   2 +
 testcases/kernel/syscalls/fsconfig/Makefile   |   6 +
 .../kernel/syscalls/fsconfig/fsconfig01.c     | 110 +++++++++++++++++
 .../kernel/syscalls/fsconfig/fsconfig02.c     | 100 +++++++++++++++
 testcases/kernel/syscalls/fsmount/.gitignore  |   1 +
 testcases/kernel/syscalls/fsmount/fsmount01.c | 114 ++++++++---------
 testcases/kernel/syscalls/fsmount/fsmount02.c |  81 ++++++++++++
 testcases/kernel/syscalls/fsopen/.gitignore   |   2 +
 testcases/kernel/syscalls/fsopen/Makefile     |   6 +
 testcases/kernel/syscalls/fsopen/fsopen01.c   |  85 +++++++++++++
 testcases/kernel/syscalls/fsopen/fsopen02.c   |  57 +++++++++
 testcases/kernel/syscalls/fspick/.gitignore   |   2 +
 testcases/kernel/syscalls/fspick/Makefile     |   6 +
 testcases/kernel/syscalls/fspick/fspick01.c   | 112 +++++++++++++++++
 testcases/kernel/syscalls/fspick/fspick02.c   | 107 ++++++++++++++++
 .../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 |  93 ++++++++++++++
 .../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   | 104 ++++++++++++++++
 27 files changed, 1203 insertions(+), 56 deletions(-)
 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/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

-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
@ 2020-02-19  9:27 ` Viresh Kumar
  2020-02-20  5:10   ` Li Wang
  2020-02-20  7:06   ` Li Wang
  2020-02-19  9:27 ` [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel() Viresh Kumar
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:27 UTC (permalink / raw)
  To: ltp

This patch moves the ismount() helper added to the fsmount syscall tests
to the standard library and renames it to tst_ismount(). The helper can
be used across different files now.

Minor modifications are also done to the helper.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/tst_device.h                          |  6 +++++
 lib/tst_device.c                              | 25 +++++++++++++++++++
 testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------
 3 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/include/tst_device.h b/include/tst_device.h
index 3ad33bd48e10..3f4aaf6f75ab 100644
--- a/include/tst_device.h
+++ b/include/tst_device.h
@@ -36,6 +36,12 @@ extern struct tst_device *tst_device;
  */
 int tst_umount(const char *path);
 
+/*
+ * Verifies if an earlier mount is successful or not.
+ * @path: Mount path to verify
+ */
+int tst_ismount(const char *path);
+
 /*
  * Clears a first few blocks of the device. This is needed when device has
  * already been formatted with a filesystems, subset of mkfs.foo utils aborts
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 8b5459def1cb..4d66b5d45996 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -386,6 +386,31 @@ int tst_umount(const char *path)
 	return -1;
 }
 
+int tst_ismount(const char *path)
+{
+	char line[256];
+	FILE *file;
+	int ret = -1;
+
+	file = SAFE_FOPEN(NULL, "/proc/mounts", "r");
+
+	while (fgets(line, sizeof(line), file)) {
+		if (strstr(line, path) != NULL) {
+			ret = 0;
+			break;
+		}
+	}
+
+	SAFE_FCLOSE(NULL, file);
+
+	if (ret) {
+		errno = ENOENT;
+		tst_resm(TWARN, "No device is mounted at %s", path);
+	}
+
+	return ret;
+}
+
 int find_stat_file(const char *dev, char *path, size_t path_len)
 {
 	const char *devname = strrchr(dev, '/') + 1;
diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c
index 83185b48aedd..5b8e95176728 100644
--- a/testcases/kernel/syscalls/fsmount/fsmount01.c
+++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -12,30 +12,10 @@
 #include "tst_test.h"
 #include "lapi/fcntl.h"
 #include "lapi/fsmount.h"
-#include "tst_safe_stdio.h"
 
-#define LINELENGTH 256
 #define MNTPOINT "newmount_point"
 static int sfd, mfd, is_mounted;
 
-static int ismount(char *mntpoint)
-{
-	int ret = 0;
-	FILE *file;
-	char line[LINELENGTH];
-
-	file = SAFE_FOPEN("/proc/mounts", "r");
-
-	while (fgets(line, sizeof(line), file)) {
-		if (strstr(line, mntpoint) != NULL) {
-			ret = 1;
-			break;
-		}
-	}
-	SAFE_FCLOSE(file);
-	return ret;
-}
-
 static void cleanup(void)
 {
 	if (is_mounted)
@@ -76,12 +56,9 @@ static void test_fsmount(void)
 	tst_res(TPASS, "move_mount() attached to the mount point");
 	SAFE_CLOSE(mfd);
 
-	if (ismount(MNTPOINT)) {
-		tst_res(TPASS, "device mounted");
+	if (!tst_ismount(MNTPOINT)) {
 		SAFE_UMOUNT(MNTPOINT);
 		is_mounted = 0;
-	} else {
-		tst_res(TFAIL, "device not mounted");
 	}
 }
 
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel()
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
  2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
@ 2020-02-19  9:27 ` Viresh Kumar
  2020-02-20  8:01   ` Petr Vorel
  2020-02-19  9:27 ` [LTP] [PATCH V2 03/10] lapi/fsmount.h: Include "lapi/fcntl.h" Viresh Kumar
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:27 UTC (permalink / raw)
  To: ltp

Add a helper to check if the fsmount() related syscalls are supported by
the kernel or not.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/lapi/fsmount.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index 87f2f229c371..e23b52e3733b 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -130,5 +130,14 @@ enum fsconfig_command {
 
 #endif /* OPEN_TREE_CLONE */
 
+void fsopen_supported_by_kernel(void)
+{
+	if ((tst_kvercmp(5, 2, 0)) < 0) {
+		/* Check if the syscall is backported on an older kernel */
+		TEST(syscall(__NR_fsopen, NULL, 0));
+		if (TST_RET == -1 && TST_ERR == ENOSYS)
+			tst_brk(TCONF, "Test not supporter on kernel version < v5.2");
+	}
+}
 
 #endif /* FSMOUNT_H__ */
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 03/10] lapi/fsmount.h: Include "lapi/fcntl.h"
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
  2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
  2020-02-19  9:27 ` [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel() Viresh Kumar
@ 2020-02-19  9:27 ` Viresh Kumar
  2020-02-19  9:28 ` [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests Viresh Kumar
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:27 UTC (permalink / raw)
  To: ltp

All the files that include (and that will include it in future) are most
probably going to need the definitions from "lapi/fcntl.h", include it
directly instead of <fcntl.h>, which will break it for old RHL distros.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/lapi/fsmount.h                        | 2 +-
 testcases/kernel/syscalls/fsmount/fsmount01.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index e23b52e3733b..49738fede5d6 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -7,12 +7,12 @@
 #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/fcntl.h"
 #include "lapi/syscalls.h"
 
 #ifndef HAVE_FSOPEN
diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c
index 5b8e95176728..c3cf8106f63b 100644
--- a/testcases/kernel/syscalls/fsmount/fsmount01.c
+++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -10,7 +10,6 @@
 #include <sys/mount.h>
 
 #include "tst_test.h"
-#include "lapi/fcntl.h"
 #include "lapi/fsmount.h"
 
 #define MNTPOINT "newmount_point"
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (2 preceding siblings ...)
  2020-02-19  9:27 ` [LTP] [PATCH V2 03/10] lapi/fsmount.h: Include "lapi/fcntl.h" Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-20  5:23   ` Li Wang
  2020-02-20 17:04   ` Petr Vorel
  2020-02-19  9:28 ` [LTP] [PATCH V2 05/10] syscalls/fsconfig: " Viresh Kumar
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

Add tests to check working of fsopen() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 runtest/syscalls                            |  3 +
 testcases/kernel/syscalls/fsopen/.gitignore |  2 +
 testcases/kernel/syscalls/fsopen/Makefile   |  6 ++
 testcases/kernel/syscalls/fsopen/fsopen01.c | 85 +++++++++++++++++++++
 testcases/kernel/syscalls/fsopen/fsopen02.c | 57 ++++++++++++++
 5 files changed, 153 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

diff --git a/runtest/syscalls b/runtest/syscalls
index 72e729c1cee9..f113342f0ded 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -343,6 +343,9 @@ fremovexattr02 fremovexattr02
 
 fsmount01 fsmount01
 
+fsopen01 fsopen01
+fsopen02 fsopen02
+
 fstat02 fstat02
 fstat02_64 fstat02_64
 fstat03 fstat03
diff --git a/testcases/kernel/syscalls/fsopen/.gitignore b/testcases/kernel/syscalls/fsopen/.gitignore
new file mode 100644
index 000000000000..5da868621883
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/.gitignore
@@ -0,0 +1,2 @@
+/fsopen01
+/fsopen02
diff --git a/testcases/kernel/syscalls/fsopen/Makefile b/testcases/kernel/syscalls/fsopen/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/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/fsopen/fsopen01.c b/testcases/kernel/syscalls/fsopen/fsopen01.c
new file mode 100644
index 000000000000..2753e5066805
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/fsopen01.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsopen() test which tries to configure and mount the filesystem as
+ * well.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	unsigned int flags;
+} tcases[] = {
+	{"Flag 0", 0},
+	{"Flag FSOPEN_CLOEXEC", FSOPEN_CLOEXEC},
+};
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int fd, fsmfd;
+
+	TEST(fsopen(tst_device->fs_type, tc->flags));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TFAIL | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 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;
+	}
+
+	if (!tst_ismount(MNTPOINT))
+		tst_res(TPASS, "%s: fsopen() passed", tc->name);
+
+	SAFE_UMOUNT(MNTPOINT);
+
+out:
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = 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/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c
new file mode 100644
index 000000000000..72cb940c5468
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/fsopen02.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * 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)
+{
+	fsopen_supported_by_kernel();
+
+	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)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	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,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 05/10] syscalls/fsconfig: New tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (3 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-20  5:41   ` Li Wang
  2020-02-19  9:28 ` [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test Viresh Kumar
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

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");
+			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,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (4 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 05/10] syscalls/fsconfig: " Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-20  6:34   ` Li Wang
  2020-02-20 17:34   ` Petr Vorel
  2020-02-19  9:28 ` [LTP] [PATCH V2 07/10] syscalls/fsmount: Add failure tests Viresh Kumar
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

This patch updates the fsmount01.c file to make it look similar to all
other fsmount related syscall tests and here is the list of all changes:

- Test all fsmount flags and mount attributes
- Remove extra PASS messages as all we want to test here is fsmount()
  and not other syscalls.
- On the same lines, print TFAIL for fsmount() syscall and TBROK for
  other calls.
- close sfd on failures
- Make the file look similar to other fsmount related tests
- General cleanup

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 testcases/kernel/syscalls/fsmount/fsmount01.c | 92 ++++++++++++-------
 1 file changed, 60 insertions(+), 32 deletions(-)

diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c
index c3cf8106f63b..b746a14ba472 100644
--- a/testcases/kernel/syscalls/fsmount/fsmount01.c
+++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -3,67 +3,95 @@
  * Copyright (C) 2020 Red Hat, Inc.  All rights reserved.
  * Author: Zorro Lang <zlang@redhat.com>
  *
- * Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(), move_mount())
- * to mount a filesystem without any specified mount options.
+ * Description:
+ * Basic fsmount() test.
  */
 
-#include <sys/mount.h>
-
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
-#define MNTPOINT "newmount_point"
-static int sfd, mfd, is_mounted;
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	unsigned int flags;
+	unsigned int mount_attrs;
+} tcases[] = {
+	{"Flag 0, attr RDONLY", 0, MOUNT_ATTR_RDONLY},
+	{"Flag 0, attr NOSUID", 0, MOUNT_ATTR_NOSUID},
+	{"Flag 0, attr NODEV", 0, MOUNT_ATTR_NODEV},
+	{"Flag 0, attr NOEXEC", 0, MOUNT_ATTR_NOEXEC},
+	{"Flag 0, attr RELATIME", 0, MOUNT_ATTR_RELATIME},
+	{"Flag 0, attr NOATIME", 0, MOUNT_ATTR_NOATIME},
+	{"Flag 0, attr STRICTATIME", 0, MOUNT_ATTR_STRICTATIME},
+	{"Flag 0, attr NODIRATIME", 0, MOUNT_ATTR_NODIRATIME},
+	{"Flag CLOEXEC, attr RDONLY", FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY},
+	{"Flag CLOEXEC, attr NOSUID", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID},
+	{"Flag CLOEXEC, attr NODEV", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV},
+	{"Flag CLOEXEC, attr NOEXEC", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC},
+	{"Flag CLOEXEC, attr RELATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_RELATIME},
+	{"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME},
+	{"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME},
+	{"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME},
+};
 
-static void cleanup(void)
+static void setup(void)
 {
-	if (is_mounted)
-		SAFE_UMOUNT(MNTPOINT);
+	fsopen_supported_by_kernel();
 }
 
-static void test_fsmount(void)
+static void run(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
+	int sfd, mfd;
+
 	TEST(fsopen(tst_device->fs_type, FSOPEN_CLOEXEC));
-	if (TST_RET < 0)
-		tst_brk(TBROK | TTERRNO, "fsopen() on %s failed", tst_device->fs_type);
+	if (TST_RET == -1) {
+		tst_brk(TBROK | TTERRNO, "fsopen() on %s failed",
+			tst_device->fs_type);
+	}
 	sfd = TST_RET;
-	tst_res(TPASS, "fsopen() on %s", tst_device->fs_type);
 
 	TEST(fsconfig(sfd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
-	if (TST_RET < 0)
+	if (TST_RET < 0) {
+		SAFE_CLOSE(sfd);
 		tst_brk(TBROK | TTERRNO,
 			"fsconfig() failed to set source to %s", tst_device->dev);
-	tst_res(TPASS, "fsconfig() set source to %s", tst_device->dev);
-
+	}
 
 	TEST(fsconfig(sfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
-	if (TST_RET < 0)
+	if (TST_RET < 0) {
+		SAFE_CLOSE(sfd);
 		tst_brk(TBROK | TTERRNO, "fsconfig() created superblock");
-	tst_res(TPASS, "fsconfig() created superblock");
+	}
 
-	TEST(fsmount(sfd, FSMOUNT_CLOEXEC, 0));
-	if (TST_RET < 0)
-		tst_brk(TBROK | TTERRNO, "fsmount() failed to create a mount object");
-	mfd = TST_RET;
-	tst_res(TPASS, "fsmount() created a mount object");
+	TEST(fsmount(sfd, tc->flags, tc->mount_attrs));
 	SAFE_CLOSE(sfd);
 
+	if (TST_RET < 0) {
+		tst_brk(TFAIL | TTERRNO,
+			"fsmount() failed to create a mount object");
+	}
+	mfd = TST_RET;
+
 	TEST(move_mount(mfd, "", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH));
-	if (TST_RET < 0)
-		tst_brk(TBROK | TTERRNO, "move_mount() failed to attach to the mount point");
-	is_mounted = 1;
-	tst_res(TPASS, "move_mount() attached to the mount point");
 	SAFE_CLOSE(mfd);
 
-	if (!tst_ismount(MNTPOINT)) {
-		SAFE_UMOUNT(MNTPOINT);
-		is_mounted = 0;
+	if (TST_RET < 0) {
+		tst_brk(TBROK | TTERRNO,
+			"move_mount() failed to attach to the mount point");
 	}
+
+	if (!tst_ismount(MNTPOINT))
+		tst_res(TPASS, "%s: fsmount() passed", tc->name);
+
+	SAFE_UMOUNT(MNTPOINT);
 }
 
 static struct tst_test test = {
-	.test_all = test_fsmount,
-	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
 	.needs_root = 1,
 	.mntpoint = MNTPOINT,
 	.format_device = 1,
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 07/10] syscalls/fsmount: Add failure tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (5 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-19  9:28 ` [LTP] [PATCH V2 08/10] syscalls/move_mount: New tests Viresh Kumar
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

This adds fsmount02.c tests to verify all the errors returned on
failures.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 runtest/syscalls                              |  1 +
 testcases/kernel/syscalls/fsmount/.gitignore  |  1 +
 testcases/kernel/syscalls/fsmount/fsmount02.c | 81 +++++++++++++++++++
 3 files changed, 83 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c

diff --git a/runtest/syscalls b/runtest/syscalls
index 4fcbd5f710eb..5b652a518dc6 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -345,6 +345,7 @@ fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 
 fsmount01 fsmount01
+fsmount02 fsmount02
 
 fsopen01 fsopen01
 fsopen02 fsopen02
diff --git a/testcases/kernel/syscalls/fsmount/.gitignore b/testcases/kernel/syscalls/fsmount/.gitignore
index e2f01ea17a40..7b77c5e33ee6 100644
--- a/testcases/kernel/syscalls/fsmount/.gitignore
+++ b/testcases/kernel/syscalls/fsmount/.gitignore
@@ -1 +1,2 @@
 /fsmount01
+/fsmount02
diff --git a/testcases/kernel/syscalls/fsmount/fsmount02.c b/testcases/kernel/syscalls/fsmount/fsmount02.c
new file mode 100644
index 000000000000..cdb43612ae75
--- /dev/null
+++ b/testcases/kernel/syscalls/fsmount/fsmount02.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsmount() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+int fd = -1, invalid_fd = -1;
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	int *fd;
+	unsigned int flags;
+	unsigned int mount_attrs;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", &invalid_fd, FSMOUNT_CLOEXEC, 0, EBADF},
+	{"invalid-flags", &fd, 0x02, 0, EINVAL},
+	{"invalid-attrs", &fd, FSMOUNT_CLOEXEC, 0x100, EINVAL},
+};
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+}
+
+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");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fsmount(*tc->fd, tc->flags, tc->mount_attrs));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: fsmount() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fsmount() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fsmount() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.mntpoint = MNTPOINT,
+	.format_device = 1,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 08/10] syscalls/move_mount: New tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (6 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 07/10] syscalls/fsmount: Add failure tests Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-19  9:28 ` [LTP] [PATCH V2 09/10] syscalls/fspick: " Viresh Kumar
  2020-02-19  9:28 ` [LTP] [PATCH V2 10/10] syscalls/open_tree: " Viresh Kumar
  9 siblings, 0 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

Add tests to check working of move_mount() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 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 | 93 +++++++++++++++++++
 5 files changed, 186 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

diff --git a/runtest/syscalls b/runtest/syscalls
index 5b652a518dc6..f207a73c3e6d 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -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
diff --git a/testcases/kernel/syscalls/move_mount/.gitignore b/testcases/kernel/syscalls/move_mount/.gitignore
new file mode 100644
index 000000000000..83ae40145dff
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/.gitignore
@@ -0,0 +1,2 @@
+/move_mount01
+/move_mount02
diff --git a/testcases/kernel/syscalls/move_mount/Makefile b/testcases/kernel/syscalls/move_mount/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/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/move_mount/move_mount01.c b/testcases/kernel/syscalls/move_mount/move_mount01.c
new file mode 100644
index 000000000000..ff281e0c565b
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/move_mount01.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic move_mount() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	unsigned int flags;
+} tcases[] = {
+	{"Flag MOVE_MOUNT_F_SYMLINKS", MOVE_MOUNT_F_SYMLINKS},
+	{"Flag MOVE_MOUNT_F_AUTOMOUNTS", MOVE_MOUNT_F_AUTOMOUNTS},
+	{"Flag MOVE_MOUNT_F_EMPTY_PATH", MOVE_MOUNT_F_EMPTY_PATH},
+	{"Flag MOVE_MOUNT_T_SYMLINKS", MOVE_MOUNT_T_SYMLINKS},
+	{"Flag MOVE_MOUNT_T_AUTOMOUNTS", MOVE_MOUNT_T_AUTOMOUNTS},
+	{"Flag MOVE_MOUNT_T_EMPTY_PATH", MOVE_MOUNT_T_EMPTY_PATH},
+};
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int fsmfd, fd;
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			tc->flags | MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TERRNO, "move_mount() failed");
+
+	if (!tst_ismount(MNTPOINT))
+		tst_res(TPASS, "%s: move_mount() passed", tc->name);
+
+	SAFE_UMOUNT(MNTPOINT);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = 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/move_mount/move_mount02.c b/testcases/kernel/syscalls/move_mount/move_mount02.c
new file mode 100644
index 000000000000..805a098bfac5
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/move_mount02.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic move_mount() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+int invalid_fd = -1, fsmfd;
+
+static struct tcase {
+	char *name;
+	int *from_dirfd;
+	const char *from_pathname;
+	int to_dirfd;
+	const char *to_pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-from-fd", &invalid_fd, "", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF},
+	{"invalid-from-path", &fsmfd, "invalid", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, ENOENT},
+	{"invalid-to-fd", &fsmfd, "", -1, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF},
+	{"invalid-to-path", &fsmfd, "", AT_FDCWD, "invalid", MOVE_MOUNT_F_EMPTY_PATH, ENOENT},
+	{"invalid-flags", &fsmfd, "", AT_FDCWD, MNTPOINT, 0x08, EINVAL},
+};
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int fd;
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+	TEST(move_mount(*tc->from_dirfd, tc->from_pathname, tc->to_dirfd,
+			tc->to_pathname, tc->flags));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET != -1) {
+		SAFE_UMOUNT(MNTPOINT);
+		tst_brk(TFAIL, "%s: move_mount() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: move_mount() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: move_mount() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 09/10] syscalls/fspick: New tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (7 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 08/10] syscalls/move_mount: New tests Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-20  7:57   ` Li Wang
  2020-02-19  9:28 ` [LTP] [PATCH V2 10/10] syscalls/open_tree: " Viresh Kumar
  9 siblings, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

Add tests to check working of fspick() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 runtest/syscalls                            |   3 +
 testcases/kernel/syscalls/fspick/.gitignore |   2 +
 testcases/kernel/syscalls/fspick/Makefile   |   6 ++
 testcases/kernel/syscalls/fspick/fspick01.c | 112 ++++++++++++++++++++
 testcases/kernel/syscalls/fspick/fspick02.c | 107 +++++++++++++++++++
 5 files changed, 230 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

diff --git a/runtest/syscalls b/runtest/syscalls
index f207a73c3e6d..b73df9a7cbec 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -350,6 +350,9 @@ fsmount02 fsmount02
 fsopen01 fsopen01
 fsopen02 fsopen02
 
+fspick01 fspick01
+fspick02 fspick02
+
 fstat02 fstat02
 fstat02_64 fstat02_64
 fstat03 fstat03
diff --git a/testcases/kernel/syscalls/fspick/.gitignore b/testcases/kernel/syscalls/fspick/.gitignore
new file mode 100644
index 000000000000..a8aa61dce18b
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/.gitignore
@@ -0,0 +1,2 @@
+/fspick01
+/fspick02
diff --git a/testcases/kernel/syscalls/fspick/Makefile b/testcases/kernel/syscalls/fspick/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/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/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c
new file mode 100644
index 000000000000..ac0b12195102
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/fspick01.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fspick() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	unsigned int flags;
+} tcases[] = {
+	{"Flag FSPICK_CLOEXEC", FSPICK_CLOEXEC},
+	{"Flag FSPICK_SYMLINK_NOFOLLOW", FSPICK_SYMLINK_NOFOLLOW},
+	{"Flag FSPICK_NO_AUTOMOUNT", FSPICK_NO_AUTOMOUNT},
+	{"Flag FSPICK_EMPTY_PATH", FSPICK_EMPTY_PATH},
+};
+
+static int ismounted;
+
+static void cleanup(void)
+{
+	if (ismounted)
+		SAFE_UMOUNT(MNTPOINT);
+}
+
+static void setup(void)
+{
+	int fd, fsmfd;
+
+	fsopen_supported_by_kernel();
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "move_mount() failed");
+
+	ismounted = 1;
+
+	if (tst_ismount(MNTPOINT))
+		tst_brk(TBROK | TERRNO, "device not mounted");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int fspick_fd;
+
+	TEST(fspick(AT_FDCWD, MNTPOINT, tc->flags));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TERRNO, "fspick() failed");
+
+	fspick_fd = TST_RET;
+
+	TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "user_xattr", "false", 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fspick_fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsconfig(fspick_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fspick_fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	SAFE_CLOSE(fspick_fd);
+	tst_res(TPASS, "%s: fspick() passed", tc->name);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
diff --git a/testcases/kernel/syscalls/fspick/fspick02.c b/testcases/kernel/syscalls/fspick/fspick02.c
new file mode 100644
index 000000000000..b5949177ee23
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/fspick02.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fspick() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	int dirfd;
+	const char *pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", -1, MNTPOINT, FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, EBADF},
+	{"invalid-path", AT_FDCWD, "invalid", FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, ENOENT},
+	{"invalid-flags", AT_FDCWD, MNTPOINT, 0x10, EINVAL},
+};
+
+static int ismounted;
+
+static void cleanup(void)
+{
+	if (ismounted)
+		SAFE_UMOUNT(MNTPOINT);
+}
+
+static void setup(void)
+{
+	int fd, fsmfd;
+
+	fsopen_supported_by_kernel();
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "move_mount() failed");
+
+	ismounted = 1;
+
+	if (tst_ismount(MNTPOINT))
+		tst_brk(TBROK | TERRNO, "device not mounted");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fspick(tc->dirfd, tc->pathname, tc->flags));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: fspick() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fspick() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fspick() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 10/10] syscalls/open_tree: New tests
  2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (8 preceding siblings ...)
  2020-02-19  9:28 ` [LTP] [PATCH V2 09/10] syscalls/fspick: " Viresh Kumar
@ 2020-02-19  9:28 ` Viresh Kumar
  2020-02-20  7:25   ` Li Wang
  9 siblings, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-19  9:28 UTC (permalink / raw)
  To: ltp

Add tests to check working of open_tree() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 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   | 104 ++++++++++++++++
 5 files changed, 230 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

diff --git a/runtest/syscalls b/runtest/syscalls
index b73df9a7cbec..79a2579e5903 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -844,6 +844,9 @@ openat01 openat01
 openat02 openat02
 openat03 openat03
 
+open_tree01 open_tree01
+open_tree02 open_tree02
+
 mincore01 mincore01
 mincore02 mincore02
 
diff --git a/testcases/kernel/syscalls/open_tree/.gitignore b/testcases/kernel/syscalls/open_tree/.gitignore
new file mode 100644
index 000000000000..2f732b44518e
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/.gitignore
@@ -0,0 +1,2 @@
+/open_tree01
+/open_tree02
diff --git a/testcases/kernel/syscalls/open_tree/Makefile b/testcases/kernel/syscalls/open_tree/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/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/open_tree/open_tree01.c b/testcases/kernel/syscalls/open_tree/open_tree01.c
new file mode 100644
index 000000000000..93df51a3fa11
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/open_tree01.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic open_tree() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+#define OT_MNTPOINT	"ot_mntpoint"
+
+static struct tcase {
+	char *name;
+	unsigned int flags;
+} tcases[] = {
+	{"Flag OPEN_TREE_CLONE", OPEN_TREE_CLONE},
+	{"Flag OPEN_TREE_CLOEXEC", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC},
+};
+
+static int dir_created;
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+
+	SAFE_MKDIR(OT_MNTPOINT, 0777);
+	dir_created = 1;
+}
+
+static void cleanup(void)
+{
+	if (dir_created)
+		SAFE_RMDIR(OT_MNTPOINT);
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int fd, fsmfd, otfd;
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "move_mount() failed");
+
+	if (tst_ismount(MNTPOINT)) {
+		tst_res(TBROK | TERRNO, "device not mounted");
+		goto out;
+	}
+
+	TEST(open_tree(AT_FDCWD, MNTPOINT, tc->flags));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TERRNO, "open_tree() failed");
+		goto out;
+	}
+
+	otfd = TST_RET;
+	TEST(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(otfd);
+
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "move_mount() failed");
+		goto out;
+	}
+
+	if (!tst_ismount(OT_MNTPOINT))
+		tst_res(TPASS, "%s: open_tree() passed", tc->name);
+
+	SAFE_UMOUNT(OT_MNTPOINT);
+out:
+	SAFE_UMOUNT(MNTPOINT);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
diff --git a/testcases/kernel/syscalls/open_tree/open_tree02.c b/testcases/kernel/syscalls/open_tree/open_tree02.c
new file mode 100644
index 000000000000..e752bb45b24e
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic open_tree() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static struct tcase {
+	char *name;
+	int dirfd;
+	const char *pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", -1, MNTPOINT, OPEN_TREE_CLONE, EBADF},
+	{"invalid-path", AT_FDCWD, "invalid", OPEN_TREE_CLONE, ENOENT},
+	{"invalid-flags", AT_FDCWD, MNTPOINT, 0xFFFFFFFF, EINVAL},
+};
+
+static int ismounted;
+
+static void cleanup(void)
+{
+	if (ismounted)
+		SAFE_UMOUNT(MNTPOINT);
+}
+
+static void setup(void)
+{
+	int fd, fsmfd;
+
+	fsopen_supported_by_kernel();
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsconfig failed");
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "move_mount() failed");
+
+	if (tst_ismount(MNTPOINT))
+		tst_brk(TBROK | TERRNO, "device not mounted");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(open_tree(tc->dirfd, tc->pathname, tc->flags));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: open_tree() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: open_tree() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: open_tree() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.dev_fs_flags = TST_FS_SKIP_FUSE,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
@ 2020-02-20  5:10   ` Li Wang
  2020-02-20  5:20     ` Viresh Kumar
  2020-02-20  7:06   ` Li Wang
  1 sibling, 1 reply; 36+ messages in thread
From: Li Wang @ 2020-02-20  5:10 UTC (permalink / raw)
  To: ltp

On Wed, Feb 19, 2020 at 5:28 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> This patch moves the ismount() helper added to the fsmount syscall tests
> to the standard library and renames it to tst_ismount(). The helper can
> be used across different files now.
>
> Minor modifications are also done to the helper.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
Acked-by: Li Wang <liwang@redhat.com>


> ---
> +/*
> + * Verifies if an earlier mount is successful or not.
> + * @path: Mount path to verify
> + */
> +int tst_ismount(const char *path);
>

I have slightly thought to rename it as 'tst_is_mounted(const char *path)',
but it also depends on other reviewer's opinion, I have no strong insist
here.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/88c19774/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-20  5:10   ` Li Wang
@ 2020-02-20  5:20     ` Viresh Kumar
  0 siblings, 0 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-20  5:20 UTC (permalink / raw)
  To: ltp

On 20-02-20, 13:10, Li Wang wrote:
> I have slightly thought to rename it as 'tst_is_mounted(const char *path)',
> but it also depends on other reviewer's opinion, I have no strong insist
> here.

I didn't apply much brain and just used the name you suggested last :)

Sure, we can name it anything we like. I also thought about
tst_verify_mount() though :)

-- 
viresh

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-19  9:28 ` [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests Viresh Kumar
@ 2020-02-20  5:23   ` Li Wang
  2020-02-20  8:51     ` Petr Vorel
  2020-02-20 17:04   ` Petr Vorel
  1 sibling, 1 reply; 36+ messages in thread
From: Li Wang @ 2020-02-20  5:23 UTC (permalink / raw)
  To: ltp

On Wed, Feb 19, 2020 at 5:28 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> ...
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/fsopen01.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> + *
> + * Description:
> + * Basic fsopen() test which tries to configure and mount the filesystem
> as
> + * well.
> + */
> +#include "tst_test.h"
> +#include "lapi/fsmount.h"
> +
> +#define MNTPOINT       "mntpoint"
> +
> +static struct tcase {
> +       char *name;
> +       unsigned int flags;
> +} tcases[] = {
> +       {"Flag 0", 0},
> +       {"Flag FSOPEN_CLOEXEC", FSOPEN_CLOEXEC},
>

Maybe better to remove the 'Flag' keywords from here and add it to the
print sentence.


> +static void run(unsigned int n)
> +{
> ...
> +
> +       if (!tst_ismount(MNTPOINT))
> +               tst_res(TPASS, "%s: fsopen() passed", tc->name);
>

tst_res(TPASS, "Flag %s: fsopen() passed", tc->name);

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/b99343b4/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 05/10] syscalls/fsconfig: New tests
  2020-02-19  9:28 ` [LTP] [PATCH V2 05/10] syscalls/fsconfig: " Viresh Kumar
@ 2020-02-20  5:41   ` Li Wang
  2020-02-20  5:50     ` Viresh Kumar
  2020-02-21 16:44     ` Petr Vorel
  0 siblings, 2 replies; 36+ messages in thread
From: Li Wang @ 2020-02-20  5:41 UTC (permalink / raw)
  To: ltp

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)
-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/a2e38d20/attachment-0001.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 05/10] syscalls/fsconfig: New tests
  2020-02-20  5:41   ` Li Wang
@ 2020-02-20  5:50     ` Viresh Kumar
  2020-02-20 10:09       ` Li Wang
  2020-02-21 16:44     ` Petr Vorel
  1 sibling, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-20  5:50 UTC (permalink / raw)
  To: ltp

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..

-- 
viresh

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test
  2020-02-19  9:28 ` [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test Viresh Kumar
@ 2020-02-20  6:34   ` Li Wang
  2020-02-20 17:34   ` Petr Vorel
  1 sibling, 0 replies; 36+ messages in thread
From: Li Wang @ 2020-02-20  6:34 UTC (permalink / raw)
  To: ltp

On Wed, Feb 19, 2020 at 5:28 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> This patch updates the fsmount01.c file to make it look similar to all
> other fsmount related syscall tests and here is the list of all changes:
>
> - Test all fsmount flags and mount attributes
> - Remove extra PASS messages as all we want to test here is fsmount()
>   and not other syscalls.
> - On the same lines, print TFAIL for fsmount() syscall and TBROK for
>   other calls.
> - close sfd on failures
> - Make the file look similar to other fsmount related tests
> - General cleanup
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  testcases/kernel/syscalls/fsmount/fsmount01.c | 92 ++++++++++++-------
>  1 file changed, 60 insertions(+), 32 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c
> b/testcases/kernel/syscalls/fsmount/fsmount01.c
> index c3cf8106f63b..b746a14ba472 100644
> --- a/testcases/kernel/syscalls/fsmount/fsmount01.c
> +++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
> @@ -3,67 +3,95 @@
>   * Copyright (C) 2020 Red Hat, Inc.  All rights reserved.
>   * Author: Zorro Lang <zlang@redhat.com>
>   *
> - * Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(),
> move_mount())
> - * to mount a filesystem without any specified mount options.
> + * Description:
> + * Basic fsmount() test.
>   */
>
> -#include <sys/mount.h>
> -
>  #include "tst_test.h"
>  #include "lapi/fsmount.h"
>
> -#define MNTPOINT "newmount_point"
> -static int sfd, mfd, is_mounted;
> +#define MNTPOINT       "mntpoint"
> +
> +static struct tcase {
> +       char *name;
> +       unsigned int flags;
> +       unsigned int mount_attrs;
> +} tcases[] = {
> +       {"Flag 0, attr RDONLY", 0, MOUNT_ATTR_RDONLY},
> +       {"Flag 0, attr NOSUID", 0, MOUNT_ATTR_NOSUID},
> +       {"Flag 0, attr NODEV", 0, MOUNT_ATTR_NODEV},
> +       {"Flag 0, attr NOEXEC", 0, MOUNT_ATTR_NOEXEC},
> +       {"Flag 0, attr RELATIME", 0, MOUNT_ATTR_RELATIME},
> +       {"Flag 0, attr NOATIME", 0, MOUNT_ATTR_NOATIME},
> +       {"Flag 0, attr STRICTATIME", 0, MOUNT_ATTR_STRICTATIME},
> +       {"Flag 0, attr NODIRATIME", 0, MOUNT_ATTR_NODIRATIME},
> +       {"Flag CLOEXEC, attr RDONLY", FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY},
> +       {"Flag CLOEXEC, attr NOSUID", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID},
> +       {"Flag CLOEXEC, attr NODEV", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV},
> +       {"Flag CLOEXEC, attr NOEXEC", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC},
> +       {"Flag CLOEXEC, attr RELATIME", FSMOUNT_CLOEXEC,
> MOUNT_ATTR_RELATIME},
> +       {"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC,
> MOUNT_ATTR_NOATIME},
> +       {"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC,
> MOUNT_ATTR_STRICTATIME},
> +       {"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC,
> MOUNT_ATTR_NODIRATIME},
> +};
>

Again, if you move the 'Flag & attr' to print info, this patch looks pretty
good to me.

> +       if (!tst_ismount(MNTPOINT))
> +               tst_res(TPASS, "%s: fsmount() passed", tc->name);
>

What about:
        tst_res(TPASS, "'Flag & mount_attr: %s': fsmount() passed",
tc->name);

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/2c5c3798/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
  2020-02-20  5:10   ` Li Wang
@ 2020-02-20  7:06   ` Li Wang
  2020-02-20  7:19     ` Viresh Kumar
  1 sibling, 1 reply; 36+ messages in thread
From: Li Wang @ 2020-02-20  7:06 UTC (permalink / raw)
  To: ltp

> +int tst_ismount(const char *path)
> +{
> +       char line[256];
> +       FILE *file;
> +       int ret = -1;

+
> +       file = SAFE_FOPEN(NULL, "/proc/mounts", "r");
> +
> +       while (fgets(line, sizeof(line), file)) {
> +               if (strstr(line, path) != NULL) {
> +                       ret = 0;
> +                       break;
> +               }
> +       }
> +
> +       SAFE_FCLOSE(NULL, file);
> +
> +       if (ret) {
> +               errno = ENOENT;
> +               tst_resm(TWARN, "No device is mounted at %s", path);
> +       }
> +
> +       return ret;
>

Sorry, I think the return value should be '1' if it has been mounted
already.

e.g
These codes will make people confused about whether it's
mounted successfully or not.

if (tst_ismount(MNTPOINT))
        tst_brk(TBROK | TERRNO, "device not mounted");


+}
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/98197515/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-20  7:06   ` Li Wang
@ 2020-02-20  7:19     ` Viresh Kumar
  2020-02-20  7:52       ` Petr Vorel
  0 siblings, 1 reply; 36+ messages in thread
From: Viresh Kumar @ 2020-02-20  7:19 UTC (permalink / raw)
  To: ltp

On 20-02-20, 15:06, Li Wang wrote:
> > +int tst_ismount(const char *path)
> > +{
> > +       char line[256];
> > +       FILE *file;
> > +       int ret = -1;
> 
> +
> > +       file = SAFE_FOPEN(NULL, "/proc/mounts", "r");
> > +
> > +       while (fgets(line, sizeof(line), file)) {
> > +               if (strstr(line, path) != NULL) {
> > +                       ret = 0;
> > +                       break;
> > +               }
> > +       }
> > +
> > +       SAFE_FCLOSE(NULL, file);
> > +
> > +       if (ret) {
> > +               errno = ENOENT;
> > +               tst_resm(TWARN, "No device is mounted at %s", path);
> > +       }
> > +
> > +       return ret;
> >
> 
> Sorry, I think the return value should be '1' if it has been mounted
> already.
> 
> e.g
> These codes will make people confused about whether it's
> mounted successfully or not.
> 
> if (tst_ismount(MNTPOINT))
>         tst_brk(TBROK | TERRNO, "device not mounted");

I kept the return 0 on success thing here as well, but maybe yeah, it
should return 1 on success here.

-- 
viresh

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 10/10] syscalls/open_tree: New tests
  2020-02-19  9:28 ` [LTP] [PATCH V2 10/10] syscalls/open_tree: " Viresh Kumar
@ 2020-02-20  7:25   ` Li Wang
  2020-02-20  7:35     ` Viresh Kumar
  0 siblings, 1 reply; 36+ messages in thread
From: Li Wang @ 2020-02-20  7:25 UTC (permalink / raw)
  To: ltp

Viresh Kumar <viresh.kumar@linaro.org> wrote:

> ...
> +++ b/testcases/kernel/syscalls/open_tree/open_tree01.c
> ...
> +static struct tcase {
> +       char *name;
> +       unsigned int flags;
> +} tcases[] = {
> +       {"Flag OPEN_TREE_CLONE", OPEN_TREE_CLONE},
> +       {"Flag OPEN_TREE_CLOEXEC", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC},
> +};
>
==> remove Flag


+++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
> @@ -0,0 +1,104 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> ...
> +
> +       fsmfd = TST_RET;
> +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> +                       MOVE_MOUNT_F_EMPTY_PATH));
> +       SAFE_CLOSE(fsmfd);
> +
> +       if (TST_RET == -1)
> +               tst_brk(TBROK | TERRNO, "move_mount() failed");
> +
>

+       ismounted = 1;

We need to set 'ismounted' variable to 1 here, otherwise, the test will
break at the second loop.

------Error log------
tst_test.c:1278: INFO: Testing on ext3
tst_mkfs.c:90: INFO: Formatting /dev/loop2 with ext3 opts='' extra opts=''
mke2fs 1.44.6 (5-Mar-2019)
/dev/loop2 is mounted; will not make a filesystem here!
tst_mkfs.c:101: BROK: tst_test.c:831: mkfs.ext3 failed with 1
tst_device.c:222: WARN: ioctl(/dev/loop2, LOOP_CLR_FD, 0) no ENXIO for too
long
tst_tmpdir.c:330: WARN: tst_rmdir: rmobj(/tmp/SHZbDJ) failed:
unlink(/tmp/SHZbDJ/mntpoint) failed; errno=21: EISDIR

Summary:
passed   3
failed   0
skipped  0
warnings 0

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/dd859363/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 10/10] syscalls/open_tree: New tests
  2020-02-20  7:25   ` Li Wang
@ 2020-02-20  7:35     ` Viresh Kumar
  0 siblings, 0 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-20  7:35 UTC (permalink / raw)
  To: ltp

On 20-02-20, 15:25, Li Wang wrote:
> Viresh Kumar <viresh.kumar@linaro.org> wrote:
> 
> > ...
> > +++ b/testcases/kernel/syscalls/open_tree/open_tree01.c
> > ...
> > +static struct tcase {
> > +       char *name;
> > +       unsigned int flags;
> > +} tcases[] = {
> > +       {"Flag OPEN_TREE_CLONE", OPEN_TREE_CLONE},
> > +       {"Flag OPEN_TREE_CLOEXEC", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC},
> > +};
> >
> ==> remove Flag
> 
> 
> +++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
> > @@ -0,0 +1,104 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > ...
> > +
> > +       fsmfd = TST_RET;
> > +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> > +                       MOVE_MOUNT_F_EMPTY_PATH));
> > +       SAFE_CLOSE(fsmfd);
> > +
> > +       if (TST_RET == -1)
> > +               tst_brk(TBROK | TERRNO, "move_mount() failed");
> > +
> >
> 
> +       ismounted = 1;
> 
> We need to set 'ismounted' variable to 1 here, otherwise, the test will
> break at the second loop.

Last minute change went untested it seems. Sorry about that.

-- 
viresh

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper
  2020-02-20  7:19     ` Viresh Kumar
@ 2020-02-20  7:52       ` Petr Vorel
  0 siblings, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-20  7:52 UTC (permalink / raw)
  To: ltp

Hi,

...
> > Sorry, I think the return value should be '1' if it has been mounted
> > already.

> > e.g
> > These codes will make people confused about whether it's
> > mounted successfully or not.

> > if (tst_ismount(MNTPOINT))
> >         tst_brk(TBROK | TERRNO, "device not mounted");

> I kept the return 0 on success thing here as well, but maybe yeah, it
> should return 1 on success here.

Most of the functions returns 1 or -1 on failure. But here it's this approach
really confusing, because the name and purpose. So I'd also be for 0 on failure and 1
on success.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 09/10] syscalls/fspick: New tests
  2020-02-19  9:28 ` [LTP] [PATCH V2 09/10] syscalls/fspick: " Viresh Kumar
@ 2020-02-20  7:57   ` Li Wang
  0 siblings, 0 replies; 36+ messages in thread
From: Li Wang @ 2020-02-20  7:57 UTC (permalink / raw)
  To: ltp

Viresh Kumar <viresh.kumar@linaro.org> wrote:

> ...
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fspick/fspick01.c
> ...
> +
> +static void run(unsigned int n)
> +{
> +       struct tcase *tc = &tcases[n];
> +       int fspick_fd;
> +
> +       TEST(fspick(AT_FDCWD, MNTPOINT, tc->flags));
> +       if (TST_RET == -1)
> +               tst_brk(TFAIL | TERRNO, "fspick() failed");
> +
> +       fspick_fd = TST_RET;
> +
> +       TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "user_xattr",
> "false", 0));
> +       if (TST_RET == -1) {
> +               SAFE_CLOSE(fspick_fd);
> +               tst_brk(TBROK | TERRNO, "fsconfig() failed");
>
Test kernel: 5.6.0-rc2+ x86_64

tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop3 with xfs opts='' extra opts=''
tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
fspick01.c:90: BROK: fsconfig() failed: EINVAL (22)


> +       }
> +
> +       TEST(fsconfig(fspick_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0));
> +       if (TST_RET == -1) {
> +               SAFE_CLOSE(fspick_fd);
> +               tst_brk(TBROK | TERRNO, "fsconfig() failed");
> +       }
> +
> +       SAFE_CLOSE(fspick_fd);
> +       tst_res(TPASS, "%s: fspick() passed", tc->name);
> +}
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/82abd210/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel()
  2020-02-19  9:27 ` [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel() Viresh Kumar
@ 2020-02-20  8:01   ` Petr Vorel
  0 siblings, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-20  8:01 UTC (permalink / raw)
  To: ltp

Hi Viresh,

...
> +++ b/include/lapi/fsmount.h
...
> +void fsopen_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 2, 0)) < 0) {
> +		/* Check if the syscall is backported on an older kernel */
> +		TEST(syscall(__NR_fsopen, NULL, 0));
> +		if (TST_RET == -1 && TST_ERR == ENOSYS)
> +			tst_brk(TCONF, "Test not supporter on kernel version < v5.2");
typo supporter => supported.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-20  5:23   ` Li Wang
@ 2020-02-20  8:51     ` Petr Vorel
  0 siblings, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-20  8:51 UTC (permalink / raw)
  To: ltp

Hi,

> > +static struct tcase {
> > +       char *name;
> > +       unsigned int flags;
> > +} tcases[] = {
> > +       {"Flag 0", 0},
> > +       {"Flag FSOPEN_CLOEXEC", FSOPEN_CLOEXEC},


> Maybe better to remove the 'Flag' keywords from here and add it to the
> print sentence.
+1. BTW if you remove bogus text, you can use macro to not repeat the flag,
see testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
#define TYPE_NAME(x) .ttype = x, .desc = #x
(just a suggestion, nothing really important)

> > +static void run(unsigned int n)
> > +{
> > ...
> > +
> > +       if (!tst_ismount(MNTPOINT))
> > +               tst_res(TPASS, "%s: fsopen() passed", tc->name);


> tst_res(TPASS, "Flag %s: fsopen() passed", tc->name);

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 05/10] syscalls/fsconfig: New tests
  2020-02-20  5:50     ` Viresh Kumar
@ 2020-02-20 10:09       ` Li Wang
  0 siblings, 0 replies; 36+ messages in thread
From: Li Wang @ 2020-02-20 10:09 UTC (permalink / raw)
  To: ltp

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.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/d12ad1c0/attachment.htm>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-19  9:28 ` [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests Viresh Kumar
  2020-02-20  5:23   ` Li Wang
@ 2020-02-20 17:04   ` Petr Vorel
  2020-02-24  3:18     ` Viresh Kumar
  1 sibling, 1 reply; 36+ messages in thread
From: Petr Vorel @ 2020-02-20 17:04 UTC (permalink / raw)
  To: ltp

Hi Viresh,

...
> +static struct tcase {
> +	char *name;
> +	unsigned int flags;
> +} tcases[] = {
> +	{"Flag 0", 0},
> +	{"Flag FSOPEN_CLOEXEC", FSOPEN_CLOEXEC},
> +};
Note about removing text from flags apply also for this test.

> +static void setup(void)
> +{
> +	fsopen_supported_by_kernel();
> +}
How about removing this and use as setup function directly
fsopen_supported_by_kernel()?
.setup = fsopen_supported_by_kernel,

Other than that it's OK.
However I have problem on fsopen01 and fsmount02.
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making
filesystem (use -I to override)
tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1

.dev_fs_flags = TST_FS_SKIP_FUSE helps with exfat and ntfs, but this also fails
on vfat.

This is tested on system with CONFIG_VFAT_FS=m and CONFIG_FAT_FS=m, vfat and fat
are loaded by mkfs.vfat. IMHO we need something like TST_FS_SKIP_EXFAT | TST_FS_SKIP_FAT | TST_FS_SKIP_NTFS | TST_FS_SKIP_FUSE
i.e. explicitly say what FS is not wanted no matter whether it's fuse or not.

Or maybe just TST_FS_SKIP_FAT | TST_FS_SKIP_FUSE would be enough.

NOTE: flags TST_FS_SKIP_EXFAT, TST_FS_SKIP_FAT, TST_FS_SKIP_NTFS do not exists yet.

...
> diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c
> new file mode 100644
> index 000000000000..72cb940c5468
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/fsopen02.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> + *
> + * Description:
Nit: I'd avoid "Description:".
> + * Basic fsopen() failure tests.
> + */
...

> +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)",
> +			tc->name, n);
This also need tst_res() and return, or second test get skipped if first fails.
See http://lists.linux.it/pipermail/ltp/2020-February/015505.html

> +	}
> +
> +	if (tc->exp_errno != TST_ERR) {
> +		tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with %s",
> +			tc->name, tst_strerrno(tc->exp_errno));
And here too.
> +	}

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test
  2020-02-19  9:28 ` [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test Viresh Kumar
  2020-02-20  6:34   ` Li Wang
@ 2020-02-20 17:34   ` Petr Vorel
  1 sibling, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-20 17:34 UTC (permalink / raw)
  To: ltp

Hi,

> +static struct tcase {
> +	char *name;
> +	unsigned int flags;
> +	unsigned int mount_attrs;
> +} tcases[] = {
> +	{"Flag 0, attr RDONLY", 0, MOUNT_ATTR_RDONLY},
> +	{"Flag 0, attr NOSUID", 0, MOUNT_ATTR_NOSUID},
> +	{"Flag 0, attr NODEV", 0, MOUNT_ATTR_NODEV},
> +	{"Flag 0, attr NOEXEC", 0, MOUNT_ATTR_NOEXEC},
> +	{"Flag 0, attr RELATIME", 0, MOUNT_ATTR_RELATIME},
> +	{"Flag 0, attr NOATIME", 0, MOUNT_ATTR_NOATIME},
> +	{"Flag 0, attr STRICTATIME", 0, MOUNT_ATTR_STRICTATIME},
> +	{"Flag 0, attr NODIRATIME", 0, MOUNT_ATTR_NODIRATIME},
> +	{"Flag CLOEXEC, attr RDONLY", FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY},
> +	{"Flag CLOEXEC, attr NOSUID", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID},
> +	{"Flag CLOEXEC, attr NODEV", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV},
> +	{"Flag CLOEXEC, attr NOEXEC", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC},
> +	{"Flag CLOEXEC, attr RELATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_RELATIME},
> +	{"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME},
> +	{"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME},
> +	{"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME},
> +};
I'd use desc field

#define DESC(x, y) .flags = x, .mount_attrs = y, .desc = #x ", " #y

+static struct tcase {
+	char *desc;
+	unsigned int flags;
+	unsigned int mount_attrs;
+} tcases[] = {
+	{DESC(0, MOUNT_ATTR_RDONLY)},
+	{DESC(0, MOUNT_ATTR_NOSUID)},

(avoid copy paste).

> +static void setup(void)
>  {
> -	if (is_mounted)
> -		SAFE_UMOUNT(MNTPOINT);
> +	fsopen_supported_by_kernel();
again, just .setup = fsopen_supported_by_kernel;
>  }

> -static void test_fsmount(void)
> +static void run(unsigned int n)
>  {
> +	struct tcase *tc = &tcases[n];
> +	int sfd, mfd;
> +
>  	TEST(fsopen(tst_device->fs_type, FSOPEN_CLOEXEC));
> -	if (TST_RET < 0)
> -		tst_brk(TBROK | TTERRNO, "fsopen() on %s failed", tst_device->fs_type);
> +	if (TST_RET == -1) {
> +		tst_brk(TBROK | TTERRNO, "fsopen() on %s failed",
> +			tst_device->fs_type);
Again, tst_brk(TBROK) shouldn't be on tcnt = ARRAY_SIZE(tcases),
it skips all following tests after failure (sometimes needed but IMHO not here).

> +	}
>  	sfd = TST_RET;
> -	tst_res(TPASS, "fsopen() on %s", tst_device->fs_type);

>  	TEST(fsconfig(sfd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
> -	if (TST_RET < 0)
> +	if (TST_RET < 0) {
> +		SAFE_CLOSE(sfd);
>  		tst_brk(TBROK | TTERRNO,
>  			"fsconfig() failed to set source to %s", tst_device->dev);
> -	tst_res(TPASS, "fsconfig() set source to %s", tst_device->dev);
> -
> +	}

>  	TEST(fsconfig(sfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
> -	if (TST_RET < 0)
> +	if (TST_RET < 0) {
> +		SAFE_CLOSE(sfd);
>  		tst_brk(TBROK | TTERRNO, "fsconfig() created superblock");
As you added more runs of the test (changed .test_all to .test && run =
ARRAY_SIZE(tcases)), you need to change all tst_brk() to tst_res() + return.

I also merged tst_brk(TBROK), I guess TFAIL would be better.

Other than that it looks ok.

I also wonder if it'd be worth to implement in fsmount.h some macros to reduce
code duplicity. e.g. one of similar patterns (just flag is different):

TEST(fsopen(tst_device->fs_type, FLAG));
fd = TST_RET;
if (fd == -1)
		tst_brk(TBROK | TERRNO, "fsopen() failed");

But that's not important.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 05/10] syscalls/fsconfig: New tests
  2020-02-20  5:41   ` Li Wang
  2020-02-20  5:50     ` Viresh Kumar
@ 2020-02-21 16:44     ` Petr Vorel
  1 sibling, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-21 16:44 UTC (permalink / raw)
  To: ltp

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)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-20 17:04   ` Petr Vorel
@ 2020-02-24  3:18     ` Viresh Kumar
  2020-02-24  3:35       ` Yang Xu
  2020-02-24 13:08       ` Cyril Hrubis
  0 siblings, 2 replies; 36+ messages in thread
From: Viresh Kumar @ 2020-02-24  3:18 UTC (permalink / raw)
  To: ltp

On 20-02-20, 18:04, Petr Vorel wrote:
> However I have problem on fsopen01 and fsmount02.
> mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making
> filesystem (use -I to override)
> tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1
> 
> .dev_fs_flags = TST_FS_SKIP_FUSE helps with exfat and ntfs, but this also fails
> on vfat.
> 
> This is tested on system with CONFIG_VFAT_FS=m and CONFIG_FAT_FS=m, vfat and fat
> are loaded by mkfs.vfat. IMHO we need something like TST_FS_SKIP_EXFAT | TST_FS_SKIP_FAT | TST_FS_SKIP_NTFS | TST_FS_SKIP_FUSE
> i.e. explicitly say what FS is not wanted no matter whether it's fuse or not.
> 
> Or maybe just TST_FS_SKIP_FAT | TST_FS_SKIP_FUSE would be enough.
> 
> NOTE: flags TST_FS_SKIP_EXFAT, TST_FS_SKIP_FAT, TST_FS_SKIP_NTFS do not exists yet.

I am not sure what should be done here.

@Cyril ?

-- 
viresh

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24  3:18     ` Viresh Kumar
@ 2020-02-24  3:35       ` Yang Xu
  2020-02-24  6:27         ` Petr Vorel
  2020-02-24 13:08       ` Cyril Hrubis
  1 sibling, 1 reply; 36+ messages in thread
From: Yang Xu @ 2020-02-24  3:35 UTC (permalink / raw)
  To: ltp

Hi Viresh

> On 20-02-20, 18:04, Petr Vorel wrote:
>> However I have problem on fsopen01 and fsmount02.
>> mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making
>> filesystem (use -I to override)
>> tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1
>>
>> .dev_fs_flags = TST_FS_SKIP_FUSE helps with exfat and ntfs, but this also fails
>> on vfat.
>>
>> This is tested on system with CONFIG_VFAT_FS=m and CONFIG_FAT_FS=m, vfat and fat
>> are loaded by mkfs.vfat. IMHO we need something like TST_FS_SKIP_EXFAT | TST_FS_SKIP_FAT | TST_FS_SKIP_NTFS | TST_FS_SKIP_FUSE
>> i.e. explicitly say what FS is not wanted no matter whether it's fuse or not.
>>
>> Or maybe just TST_FS_SKIP_FAT | TST_FS_SKIP_FUSE would be enough.
>>
>> NOTE: flags TST_FS_SKIP_EXFAT, TST_FS_SKIP_FAT, TST_FS_SKIP_NTFS do not exists yet.
> 
> I am not sure what should be done here.
I guess petr may want to let you add TST_FS_SKIP_FAT flag like  adding 
TST_FS_SKIP_FUSE flag in commit dbe56e52bc50("ib: Add flags to 
tst_get_supported_fs_types()").

Best Regards
Yang Xu
> 
> @Cyril ?
> 



^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24  3:35       ` Yang Xu
@ 2020-02-24  6:27         ` Petr Vorel
  0 siblings, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-24  6:27 UTC (permalink / raw)
  To: ltp

Hi,

> > On 20-02-20, 18:04, Petr Vorel wrote:
> > > However I have problem on fsopen01 and fsmount02.
> > > mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making
> > > filesystem (use -I to override)
> > > tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1

> > > .dev_fs_flags = TST_FS_SKIP_FUSE helps with exfat and ntfs, but this also fails
> > > on vfat.

> > > This is tested on system with CONFIG_VFAT_FS=m and CONFIG_FAT_FS=m, vfat and fat
> > > are loaded by mkfs.vfat. IMHO we need something like TST_FS_SKIP_EXFAT | TST_FS_SKIP_FAT | TST_FS_SKIP_NTFS | TST_FS_SKIP_FUSE
> > > i.e. explicitly say what FS is not wanted no matter whether it's fuse or not.

> > > Or maybe just TST_FS_SKIP_FAT | TST_FS_SKIP_FUSE would be enough.

> > > NOTE: flags TST_FS_SKIP_EXFAT, TST_FS_SKIP_FAT, TST_FS_SKIP_NTFS do not exists yet.

> > I am not sure what should be done here.
> I guess petr may want to let you add TST_FS_SKIP_FAT flag like  adding
> TST_FS_SKIP_FUSE flag in commit dbe56e52bc50("ib: Add flags to
> tst_get_supported_fs_types()").
Yes, that's what I meant.
This was meant as a question whether there is simpler solution than this
(it's easy to implement it, but I might have overlook something - it might be
fixed even without it).

> Best Regards
> Yang Xu

> > @Cyril ?




^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24  3:18     ` Viresh Kumar
  2020-02-24  3:35       ` Yang Xu
@ 2020-02-24 13:08       ` Cyril Hrubis
  2020-02-24 15:30         ` Petr Vorel
  1 sibling, 1 reply; 36+ messages in thread
From: Cyril Hrubis @ 2020-02-24 13:08 UTC (permalink / raw)
  To: ltp

Hi!
> I am not sure what should be done here.
> 
> @Cyril ?

Hmm, we should fix library to be able to format the device properly,
looks like some kind of bug though:

https://github.com/dosfstools/dosfstools/issues/40

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24 13:08       ` Cyril Hrubis
@ 2020-02-24 15:30         ` Petr Vorel
  2020-02-24 15:32           ` Cyril Hrubis
  0 siblings, 1 reply; 36+ messages in thread
From: Petr Vorel @ 2020-02-24 15:30 UTC (permalink / raw)
  To: ltp

Hi,

> > @Cyril ?

> Hmm, we should fix library to be able to format the device properly,
> looks like some kind of bug though:

> https://github.com/dosfstools/dosfstools/issues/40

I'm not able to reproduce the problems on fsopen01 and fsmount02.
Using different tmp directory via TMPDIR fixed that, but it started to work even
without it and even reboot didn't bring back the failure. On different host
(different distro) it worked all the time. I wonder what was wrong.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24 15:30         ` Petr Vorel
@ 2020-02-24 15:32           ` Cyril Hrubis
  2020-02-24 15:46             ` Petr Vorel
  0 siblings, 1 reply; 36+ messages in thread
From: Cyril Hrubis @ 2020-02-24 15:32 UTC (permalink / raw)
  To: ltp

Hi!
> > Hmm, we should fix library to be able to format the device properly,
> > looks like some kind of bug though:
> 
> > https://github.com/dosfstools/dosfstools/issues/40
> 
> I'm not able to reproduce the problems on fsopen01 and fsmount02.
> Using different tmp directory via TMPDIR fixed that, but it started to work even
> without it and even reboot didn't bring back the failure. On different host
> (different distro) it worked all the time. I wonder what was wrong.

Hmm, that sounds really strange, I doubt that there is something that
would create partitions on a loop device on a background, so it really
smells like a bug.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests
  2020-02-24 15:32           ` Cyril Hrubis
@ 2020-02-24 15:46             ` Petr Vorel
  0 siblings, 0 replies; 36+ messages in thread
From: Petr Vorel @ 2020-02-24 15:46 UTC (permalink / raw)
  To: ltp

Hi,

> > > Hmm, we should fix library to be able to format the device properly,
> > > looks like some kind of bug though:

> > > https://github.com/dosfstools/dosfstools/issues/40

> > I'm not able to reproduce the problems on fsopen01 and fsmount02.
> > Using different tmp directory via TMPDIR fixed that, but it started to work even
> > without it and even reboot didn't bring back the failure. On different host
> > (different distro) it worked all the time. I wonder what was wrong.

> Hmm, that sounds really strange, I doubt that there is something that
> would create partitions on a loop device on a background, so it really
> smells like a bug.
I haven't found any hint in dmesg. I tested in on a machine, which sometimes has
problems with disc I/O (occasionally it's slow). So maybe it was hw related.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2020-02-24 15:46 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  9:27 [LTP] [PATCH V2 00/10] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
2020-02-19  9:27 ` [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper Viresh Kumar
2020-02-20  5:10   ` Li Wang
2020-02-20  5:20     ` Viresh Kumar
2020-02-20  7:06   ` Li Wang
2020-02-20  7:19     ` Viresh Kumar
2020-02-20  7:52       ` Petr Vorel
2020-02-19  9:27 ` [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel() Viresh Kumar
2020-02-20  8:01   ` Petr Vorel
2020-02-19  9:27 ` [LTP] [PATCH V2 03/10] lapi/fsmount.h: Include "lapi/fcntl.h" Viresh Kumar
2020-02-19  9:28 ` [LTP] [PATCH V2 04/10] syscalls/fsopen: New tests Viresh Kumar
2020-02-20  5:23   ` Li Wang
2020-02-20  8:51     ` Petr Vorel
2020-02-20 17:04   ` Petr Vorel
2020-02-24  3:18     ` Viresh Kumar
2020-02-24  3:35       ` Yang Xu
2020-02-24  6:27         ` Petr Vorel
2020-02-24 13:08       ` Cyril Hrubis
2020-02-24 15:30         ` Petr Vorel
2020-02-24 15:32           ` Cyril Hrubis
2020-02-24 15:46             ` Petr Vorel
2020-02-19  9:28 ` [LTP] [PATCH V2 05/10] syscalls/fsconfig: " Viresh Kumar
2020-02-20  5:41   ` Li Wang
2020-02-20  5:50     ` Viresh Kumar
2020-02-20 10:09       ` Li Wang
2020-02-21 16:44     ` Petr Vorel
2020-02-19  9:28 ` [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test Viresh Kumar
2020-02-20  6:34   ` Li Wang
2020-02-20 17:34   ` Petr Vorel
2020-02-19  9:28 ` [LTP] [PATCH V2 07/10] syscalls/fsmount: Add failure tests Viresh Kumar
2020-02-19  9:28 ` [LTP] [PATCH V2 08/10] syscalls/move_mount: New tests Viresh Kumar
2020-02-19  9:28 ` [LTP] [PATCH V2 09/10] syscalls/fspick: " Viresh Kumar
2020-02-20  7:57   ` Li Wang
2020-02-19  9:28 ` [LTP] [PATCH V2 10/10] syscalls/open_tree: " Viresh Kumar
2020-02-20  7:25   ` Li Wang
2020-02-20  7:35     ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.