Skip to contentSkip to conversation

tst_test per FS options and small cleanup

PATCH Superseded Cyril Hrubis 4 participants 13 messages Jun 3, 2024 – Jun 11, 2024 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tst_test per FS options and small cleanup

Add per FS mkfs and mount options and move mkfs_opts to the tst_test struct in two quotactl tests.

Cyril Hrubis (2):
lib: tst_test: Add per filesystem mkfs and mount opts
syscalls: quotactl: Move mkfs opts into tst_test

 include/tst_test.h                            | 64 ++++++++++------
 lib/tst_test.c                                | 73 +++++++++++++------
 .../kernel/syscalls/fanotify/fanotify22.c     |  4 +-
 .../kernel/syscalls/fanotify/fanotify23.c     |  4 +-
 .../kernel/syscalls/getxattr/getxattr04.c     |  4 +-
 testcases/kernel/syscalls/ioctl/ioctl08.c     |  4 +-
 testcases/kernel/syscalls/mmap/mmap16.c       | 19 ++---
 .../kernel/syscalls/quotactl/quotactl01.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl02.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl03.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl04.c     | 19 +++--
 .../kernel/syscalls/quotactl/quotactl05.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl06.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl07.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl08.c     | 19 ++---
 .../kernel/syscalls/quotactl/quotactl09.c     |  6 +-
 testcases/kernel/syscalls/statx/statx05.c     |  4 +-
 testcases/kernel/syscalls/statx/statx06.c     |  8 +-
 testcases/kernel/syscalls/statx/statx07.c     |  4 +-
 testcases/kernel/syscalls/statx/statx09.c     |  4 +-
 20 files changed, 168 insertions(+), 102 deletions(-)
Signature · 5 lines
2.44.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/2 lib: tst_test: Add per filesystem mkfs and mount opts

This commit does:

* Group the filesystem type, mkfs and mount options into a separate structure

* Add an array of these structures to be able to define per filesystem mkfs and mount options

The details on the usage should be hopefully clear from the documentation comments for the struct tst_test.

---
 include/tst_test.h                            | 64 ++++++++++------
 lib/tst_test.c                                | 73 +++++++++++++------
 .../kernel/syscalls/fanotify/fanotify22.c     |  4 +-
 .../kernel/syscalls/fanotify/fanotify23.c     |  4 +-
 .../kernel/syscalls/getxattr/getxattr04.c     |  4 +-
 testcases/kernel/syscalls/ioctl/ioctl08.c     |  4 +-
 testcases/kernel/syscalls/mmap/mmap16.c       | 19 ++---
 .../kernel/syscalls/quotactl/quotactl01.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl02.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl03.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl04.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl05.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl06.c     |  6 +-
 .../kernel/syscalls/quotactl/quotactl07.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl08.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl09.c     |  6 +-
 testcases/kernel/syscalls/statx/statx05.c     |  4 +-
 testcases/kernel/syscalls/statx/statx06.c     |  8 +-
 testcases/kernel/syscalls/statx/statx07.c     |  4 +-
 testcases/kernel/syscalls/statx/statx09.c     |  4 +-
 20 files changed, 157 insertions(+), 83 deletions(-)
include/tst_test.h +41 -23
index 8dc20d110..6ac11f7d8 100644
@@ -247,6 +247,36 @@ struct tst_ulimit_val {
 	rlim_t rlim_cur;
 };
 
+/**
+ * struct tst_fs - A file system type, mkfs and mount options
+ *
+ * @fs_type A filesystem type to use.
+ *
+ * @mkfs_opts: A NULL terminated array of options passed to mkfs in the case
+ *             of 'tst_test.format_device'. These options are passed to mkfs
+ *             before the device path.
+ *
+ * @mkfs_size_opt: An option passed to mkfs in the case of
+ *                 'tst_test.format_device'. The device size in blocks is
+ *                 passed to mkfs after the device path and can be used to
+ *                 limit the file system not to use the whole block device.
+ *
+ * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
+ *             device in the case of 'tst_test.mount_device'.
+ *
+ * @mnt_data: The data passed to mount(2) when the test library mounts a device
+ *            in the case of 'tst_test.mount_device'.
+ */
+struct tst_fs {
+	const char *type;
+
+	const char *const *mkfs_opts;
+	const char *mkfs_size_opt;
+
+	const unsigned int mnt_flags;
+	const void *mnt_data;
+};
+
 /**
  * struct tst_test - A test description.
  *
@@ -377,29 +407,21 @@ struct tst_ulimit_val {
  *
  * @dev_min_size: A minimal device size in megabytes.
  *
- * @dev_fs_type: If set overrides the default file system type for the device and
- *               sets the tst_device.fs_type.
+ * @fs: If fs.type is set it overrides the default file system type for the
+ *      device. The rest of the parameters describe default parameters for
+ *      mkfs and mount.
  *
- * @dev_fs_opts: A NULL terminated array of options passed to mkfs in the case
- *               of 'tst_test.format_device'. These options are passed to mkfs
- *               before the device path.
- *
- * @dev_extra_opts: A NULL terminated array of extra options passed to mkfs in
- *                  the case of 'tst_test.format_device'. Extra options are
- *                  passed to mkfs after the device path. Commonly the option
- *                  after mkfs is the number of blocks and can be used to limit
- *                  the file system not to use the whole block device.
+ * @fss: A NULL type terminated array of per file system type options. If
+ *       tst_test.all_filesystems is not set the array describes a list of
+ *       file systems to test along with parameters to pass to mkfs and mount.
+ *       If tst_test.all_filesystems is set the mkfs and mount options are
+ *       taken from tst_test.fs unless there is an override for a given
+ *       file system type defined in this array.
  *
  * @mntpoint: A mount point where the test library mounts requested file system.
  *            The directory is created by the library, the test must not create
  *            it itself.
  *
- * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
- *             device in the case of 'tst_test.mount_device'.
- *
- * @mnt_data: The data passed to mount(2) when the test library mounts a device
- *            in the case of 'tst_test.mount_device'.
- *
  * @max_runtime: Maximal test runtime in seconds. Any test that runs for more
  *               than a second or two should set this and also use
  *               tst_remaining_runtime() to exit when runtime was used up.
@@ -516,14 +538,10 @@ struct tst_ulimit_val {
 
 	unsigned int dev_min_size;
 
-	const char *dev_fs_type;
-
-	const char *const *dev_fs_opts;
-	const char *const *dev_extra_opts;
+	struct tst_fs fs;
+	struct tst_fs *fss;
 
 	const char *mntpoint;
-	unsigned int mnt_flags;
-	void *mnt_data;
 
 	int max_runtime;
 
lib/tst_test.c +51 -22

121 lines not on this page · raw message

testcases/kernel/syscalls/fanotify/fanotify22.c +3 -1
index f4b7987de..ca4464b28 100644
@@ -319,7 +319,9 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
 	.needs_root = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "124e7c61deb2"},
 		{}
testcases/kernel/syscalls/fanotify/fanotify23.c +3 -1
index 35a613fea..0a5b602d4 100644
@@ -256,7 +256,9 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
 	/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */
-	.dev_fs_type = "ext2",
+	.fs = {
+		.type = "ext2"
+	},
 };
 
 #else
testcases/kernel/syscalls/getxattr/getxattr04.c +3 -1
index 61c8826c9..972238741 100644
@@ -105,7 +105,9 @@ static void setup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs"
+	},
 	.mntpoint = MNTPOINT,
 	.forks_child = 1,
 	.test_all = verify_getxattr,
testcases/kernel/syscalls/ioctl/ioctl08.c +3 -1
index 1fb195797..341ee27c9 100644
@@ -126,7 +126,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "btrfs",
+	.fs = {
+		.type = "btrfs"
+	},
 	.needs_drivers = (const char *const[]) {
 		"btrfs",
 		NULL,
testcases/kernel/syscalls/mmap/mmap16.c +6 -13
index 4e0d8a3f4..ed824c21f 100644
@@ -176,19 +176,12 @@ static struct tst_test test = {
 	.needs_checkpoints = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
-	.dev_fs_opts = (const char *const[]){
-		"-b",
-		"1024",
-		NULL,
-	},
-	.dev_extra_opts = (const char *const[]){
-		"10240",
-		NULL,
-	},
-	.needs_cmds = (const char *const[]){
-		"mkfs.ext4",
-		NULL,
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const[]){
+			"-b", "1024", NULL
+		},
+		.mkfs_size_opt = "10240",
 	},
 	.tags = (const struct tst_tag[]){
 		{"linux-git", "d6320cbfc929"},
testcases/kernel/syscalls/quotactl/quotactl01.c +4 -2
index 36ec93edc..c3fadee67 100644
@@ -216,9 +216,11 @@ static struct tst_test test = {
 	.test = verify_quota,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mount_device = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mnt_data = "usrquota,grpquota",
+	},
 	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota,grpquota",
 	.needs_cmds = (const char *const []) {
 		"quotacheck",
 		NULL
testcases/kernel/syscalls/quotactl/quotactl02.c +4 -2
index d9c4f9b2e..3a52d0e74 100644
@@ -150,9 +150,11 @@ static struct tst_test test = {
 	.test = verify_quota,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "usrquota,grpquota",
+	},
 	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota,grpquota",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
testcases/kernel/syscalls/quotactl/quotactl03.c +4 -2
index 22f5496b6..90dc4bb0b 100644
@@ -83,9 +83,11 @@ static struct tst_test test = {
 	},
 	.test_all = verify_quota,
 	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "usrquota",
+	},
 	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota",
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "657bdfb7f5e6"},
testcases/kernel/syscalls/quotactl/quotactl04.c +3 -1
index a57e6be60..8bc3efdd0 100644
@@ -162,7 +162,9 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_device = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
 	.mntpoint = MNTPOINT,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
 	.needs_cmds = (const char *[]) {
testcases/kernel/syscalls/quotactl/quotactl05.c +4 -2
index ac75cee31..63e6eafbb 100644
@@ -113,9 +113,11 @@ static struct tst_test test = {
 	.test = verify_quota,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "prjquota",
+	},
 	.mntpoint = MNTPOINT,
-	.mnt_data = "prjquota",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
testcases/kernel/syscalls/quotactl/quotactl06.c +4 -2
index 74a098a8c..f113cb462 100644
@@ -219,10 +219,12 @@ static struct tst_test test = {
 	},
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_quotactl,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mnt_data = "usrquota",
+	},
 	.mntpoint = MNTPOINT,
 	.mount_device = 1,
-	.mnt_data = "usrquota",
 	.needs_cmds = (const char *const []) {
 		"quotacheck",
 		NULL
testcases/kernel/syscalls/quotactl/quotactl07.c +3 -1
index 34ff2705d..28db6ba12 100644
@@ -83,7 +83,9 @@ static struct tst_test test = {
 	},
 	.test_all = verify_quota,
 	.format_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+	},
 	.mntpoint = MNTPOINT,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
 	.tags = (const struct tst_tag[]) {
testcases/kernel/syscalls/quotactl/quotactl08.c +3 -1
index 0fabb51a5..67638c226 100644
@@ -216,7 +216,9 @@ static struct tst_test test = {
 	.test = verify_quota,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+	},
 	.needs_device = 1,
 	.setup = setup,
 	.cleanup = cleanup,
testcases/kernel/syscalls/quotactl/quotactl09.c +4 -2
index 9a03bff5f..838a67338 100644
@@ -176,8 +176,10 @@ static struct tst_test test = {
 	},
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_quotactl,
-	.dev_fs_opts = (const char *const[]){"-O quota", NULL},
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const[]){"-O quota", NULL},
+	},
 	.mntpoint = MNTPOINT,
 	.mount_device = 1,
 	.needs_root = 1,
testcases/kernel/syscalls/statx/statx05.c +3 -1
index 9781b3e70..242771606 100644
@@ -121,7 +121,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_device = 1,
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
 	.needs_cmds = (const char *[]) {
 		"mkfs.ext4 >= 1.43.0",
 		"e4crypt",
testcases/kernel/syscalls/statx/statx06.c +5 -3
index 1771dff49..bbc90c392 100644
@@ -155,7 +155,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mntpoint = MOUNT_POINT,
 	.mount_device = 1,
-	.dev_fs_type = "ext4",
-	.dev_fs_opts = (const char *const []){"-I", "256", NULL},
-	.mnt_flags = MS_STRICTATIME,
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const []){"-I", "256", NULL},
+		.mnt_flags = MS_STRICTATIME,
+	},
 };
testcases/kernel/syscalls/statx/statx07.c +3 -1
index 1a568ec9e..4c8af5317 100644
@@ -168,7 +168,9 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.min_kver = "4.16",
 	.needs_tmpdir = 1,
-	.dev_fs_type = "nfs",
+	.fs = {
+		.type = "nfs"
+	},
 	.needs_root = 1,
 	.needs_cmds = (const char *[]) {
 		"exportfs",
testcases/kernel/syscalls/statx/statx09.c +3 -1
index 6e75ff3ec..25d14be0e 100644
@@ -156,7 +156,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_device = 1,
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+	},
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_FS_VERITY",
 		NULL
Signature · 5 lines
2.44.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by Andrea Cervesato on v1 1/2
#2 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Hi!

Thanks for the feature.

Quoted 558 lines · Cyril Hrubis

This commit does:

* Group the filesystem type, mkfs and mount options into a separate structure

* Add an array of these structures to be able to define per filesystem mkfs and mount options

The details on the usage should be hopefully clear from the documentation comments for the struct tst_test.

---
  include/tst_test.h                            | 64 ++++++++++------
  lib/tst_test.c                                | 73 +++++++++++++------
  .../kernel/syscalls/fanotify/fanotify22.c     |  4 +-
  .../kernel/syscalls/fanotify/fanotify23.c     |  4 +-
  .../kernel/syscalls/getxattr/getxattr04.c     |  4 +-
  testcases/kernel/syscalls/ioctl/ioctl08.c     |  4 +-
  testcases/kernel/syscalls/mmap/mmap16.c       | 19 ++---
  .../kernel/syscalls/quotactl/quotactl01.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl02.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl03.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl04.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl05.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl06.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl07.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl08.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl09.c     |  6 +-
  testcases/kernel/syscalls/statx/statx05.c     |  4 +-
  testcases/kernel/syscalls/statx/statx06.c     |  8 +-
  testcases/kernel/syscalls/statx/statx07.c     |  4 +-
  testcases/kernel/syscalls/statx/statx09.c     |  4 +-
  20 files changed, 157 insertions(+), 83 deletions(-)
include/tst_test.h +41 -23
index 8dc20d110..6ac11f7d8 100644
@@ -247,6 +247,36 @@ struct tst_ulimit_val {
  	rlim_t rlim_cur;
  };
 
+/**
+ * struct tst_fs - A file system type, mkfs and mount options
+ *
+ * @fs_type A filesystem type to use.
+ *
+ * @mkfs_opts: A NULL terminated array of options passed to mkfs in the case
+ *             of 'tst_test.format_device'. These options are passed to mkfs
+ *             before the device path.
+ *
+ * @mkfs_size_opt: An option passed to mkfs in the case of
+ *                 'tst_test.format_device'. The device size in blocks is
+ *                 passed to mkfs after the device path and can be used to
+ *                 limit the file system not to use the whole block device.
+ *
+ * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
+ *             device in the case of 'tst_test.mount_device'.
+ *
+ * @mnt_data: The data passed to mount(2) when the test library mounts a device
+ *            in the case of 'tst_test.mount_device'.
+ */
+struct tst_fs {
+	const char *type;
+
+	const char *const *mkfs_opts;
+	const char *mkfs_size_opt;
+
+	const unsigned int mnt_flags;
+	const void *mnt_data;
+};
+
  /**
   * struct tst_test - A test description.
   *
@@ -377,29 +407,21 @@ struct tst_ulimit_val {
   *
   * @dev_min_size: A minimal device size in megabytes.
   *
- * @dev_fs_type: If set overrides the default file system type for the device and
- *               sets the tst_device.fs_type.
+ * @fs: If fs.type is set it overrides the default file system type for the
+ *      device. The rest of the parameters describe default parameters for
+ *      mkfs and mount.
   *
- * @dev_fs_opts: A NULL terminated array of options passed to mkfs in the case
- *               of 'tst_test.format_device'. These options are passed to mkfs
- *               before the device path.
- *
- * @dev_extra_opts: A NULL terminated array of extra options passed to mkfs in
- *                  the case of 'tst_test.format_device'. Extra options are
- *                  passed to mkfs after the device path. Commonly the option
- *                  after mkfs is the number of blocks and can be used to limit
- *                  the file system not to use the whole block device.
+ * @fss: A NULL type terminated array of per file system type options. If
+ *       tst_test.all_filesystems is not set the array describes a list of
+ *       file systems to test along with parameters to pass to mkfs and mount.
+ *       If tst_test.all_filesystems is set the mkfs and mount options are
+ *       taken from tst_test.fs unless there is an override for a given
+ *       file system type defined in this array.
   *
   * @mntpoint: A mount point where the test library mounts requested file system.
   *            The directory is created by the library, the test must not create
   *            it itself.
   *
- * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
- *             device in the case of 'tst_test.mount_device'.
- *
- * @mnt_data: The data passed to mount(2) when the test library mounts a device
- *            in the case of 'tst_test.mount_device'.
- *
   * @max_runtime: Maximal test runtime in seconds. Any test that runs for more
   *               than a second or two should set this and also use
   *               tst_remaining_runtime() to exit when runtime was used up.
@@ -516,14 +538,10 @@ struct tst_ulimit_val {
 
  	unsigned int dev_min_size;
 
-	const char *dev_fs_type;
-
-	const char *const *dev_fs_opts;
-	const char *const *dev_extra_opts;
+	struct tst_fs fs;
+	struct tst_fs *fss;
 
  	const char *mntpoint;
-	unsigned int mnt_flags;
-	void *mnt_data;
 
  	int max_runtime;
 
lib/tst_test.c +51 -22
index 8c212c983..5f6ae904a 100644
@@ -1097,15 +1097,15 @@ static const char *get_device_name(const char *fs_type)
  		return tdev.dev;
  }
 
-static void prepare_device(void)
+static void prepare_device(struct tst_fs *fs)
  {
  	const char *mnt_data;
  	char buf[1024];
 
-	if (tst_test->format_device) {
-		SAFE_MKFS(tdev.dev, tdev.fs_type, tst_test->dev_fs_opts,
-			  tst_test->dev_extra_opts);
-	}
+	const char *const extra[] = {fs->mkfs_size_opt, NULL};
+
+	if (tst_test->format_device)
+		SAFE_MKFS(tdev.dev, tdev.fs_type, fs->mkfs_opts, extra);
 
  	if (tst_test->needs_rofs) {
  		prepare_and_mount_ro_fs(tdev.dev, tst_test->mntpoint,
@@ -1114,11 +1114,11 @@ static void prepare_device(void)
  	}
 
  	if (tst_test->mount_device) {
-		mnt_data = limit_tmpfs_mount_size(tst_test->mnt_data,
+		mnt_data = limit_tmpfs_mount_size(fs->mnt_data,
  				buf, sizeof(buf), tdev.fs_type);
 
  		SAFE_MOUNT(get_device_name(tdev.fs_type), tst_test->mntpoint,
-				tdev.fs_type, tst_test->mnt_flags, mnt_data);
+				tdev.fs_type, fs->mnt_flags, mnt_data);
  		mntpoint_mounted = 1;
  	}
  }
@@ -1321,13 +1321,13 @@ static void do_setup(int argc, char *argv[])
 
  		tst_device = &tdev;
 
-		if (tst_test->dev_fs_type)
-			tdev.fs_type = tst_test->dev_fs_type;
+		if (tst_test->fs.type)
+			tdev.fs_type = tst_test->fs.type;
  		else
  			tdev.fs_type = tst_dev_fs_type();
 
-		if (!tst_test->all_filesystems)
-			prepare_device();
+		if (!tst_test->all_filesystems && !tst_test->fss)
+			prepare_device(&tst_test->fs);
  	}
 
  	if (tst_test->needs_overlay && !tst_test->mount_device)
@@ -1680,6 +1680,41 @@ static int fork_testrun(void)
  	return 0;
  }
 
+static struct tst_fs *lookup_fs_desc(const char *fs_type, int all_filesystems)
+{
+	struct tst_fs *fss = tst_test->fss;
+
+	if (!fss)
+		goto ret;
+
+	for (; fss->type; fss++) {
+		if (!strcmp(fs_type, fss->type))
+			return fss;
+	}
+
+ret:
+	return all_filesystems ? &tst_test->fs : NULL;
+}
+
+static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
+{
+	int ret;
+
+	tst_res(TINFO, "=== Testing on %s ===", fs_type);
+	tdev.fs_type = fs_type;
+
+	prepare_device(fs);
+
+	ret = fork_testrun();
+
+	if (mntpoint_mounted) {
+		tst_umount(tst_test->mntpoint);
+		mntpoint_mounted = 0;
+	}
+
+	return ret;
+}
+
  static int run_tcases_per_fs(void)
  {
  	int ret = 0;
@@ -1690,18 +1725,12 @@ static int run_tcases_per_fs(void)
  		tst_brk(TCONF, "There are no supported filesystems");
 
  	for (i = 0; filesystems[i]; i++) {
+		struct tst_fs *fs = lookup_fs_desc(filesystems[i], tst_test->all_filesystems);
 
-		tst_res(TINFO, "=== Testing on %s ===", filesystems[i]);
-		tdev.fs_type = filesystems[i];
-
-		prepare_device();
-
-		ret = fork_testrun();
+		if (!fs)
+			continue;
 
-		if (mntpoint_mounted) {
-			tst_umount(tst_test->mntpoint);
-			mntpoint_mounted = 0;
-		}
+		run_tcase_on_fs(fs, filesystems[i]);
 
  		if (ret == TCONF)
  			continue;
@@ -1742,7 +1771,7 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
  		test_variants = tst_test->test_variants;
 
  	for (tst_variant = 0; tst_variant < test_variants; tst_variant++) {
-		if (tst_test->all_filesystems)
+		if (tst_test->all_filesystems || tst_test->fss)
  			ret |= run_tcases_per_fs();
  		else
  			ret |= fork_testrun();
testcases/kernel/syscalls/fanotify/fanotify22.c +3 -1
index f4b7987de..ca4464b28 100644
@@ -319,7 +319,9 @@ static struct tst_test test = {
  	.mount_device = 1,
  	.mntpoint = MOUNT_PATH,
  	.needs_root = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
  	.tags = (const struct tst_tag[]) {
  		{"linux-git", "124e7c61deb2"},
  		{}
testcases/kernel/syscalls/fanotify/fanotify23.c +3 -1
index 35a613fea..0a5b602d4 100644
@@ -256,7 +256,9 @@ static struct tst_test test = {
  	.mount_device = 1,
  	.mntpoint = MOUNT_PATH,
  	/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */
-	.dev_fs_type = "ext2",
+	.fs = {
+		.type = "ext2"
+	},
  };
 
  #else
testcases/kernel/syscalls/getxattr/getxattr04.c +3 -1
index 61c8826c9..972238741 100644
@@ -105,7 +105,9 @@ static void setup(void)
  static struct tst_test test = {
  	.needs_root = 1,
  	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs"
+	},
  	.mntpoint = MNTPOINT,
  	.forks_child = 1,
  	.test_all = verify_getxattr,
testcases/kernel/syscalls/ioctl/ioctl08.c +3 -1
index 1fb195797..341ee27c9 100644
@@ -126,7 +126,9 @@ static struct tst_test test = {
  	.needs_root = 1,
  	.mount_device = 1,
  	.mntpoint = MNTPOINT,
-	.dev_fs_type = "btrfs",
+	.fs = {
+		.type = "btrfs"
+	},
  	.needs_drivers = (const char *const[]) {
  		"btrfs",
  		NULL,
testcases/kernel/syscalls/mmap/mmap16.c +6 -13
index 4e0d8a3f4..ed824c21f 100644
@@ -176,19 +176,12 @@ static struct tst_test test = {
  	.needs_checkpoints = 1,
  	.mount_device = 1,
  	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
-	.dev_fs_opts = (const char *const[]){
-		"-b",
-		"1024",
-		NULL,
-	},
-	.dev_extra_opts = (const char *const[]){
-		"10240",
-		NULL,
-	},
-	.needs_cmds = (const char *const[]){
-		"mkfs.ext4",
-		NULL,
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const[]){
+			"-b", "1024", NULL
+		},
+		.mkfs_size_opt = "10240",
  	},
  	.tags = (const struct tst_tag[]){
  		{"linux-git", "d6320cbfc929"},
testcases/kernel/syscalls/quotactl/quotactl01.c +4 -2
index 36ec93edc..c3fadee67 100644
@@ -216,9 +216,11 @@ static struct tst_test test = {
  	.test = verify_quota,
  	.tcnt = ARRAY_SIZE(tcases),
  	.mount_device = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mnt_data = "usrquota,grpquota",
+	},
  	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota,grpquota",
  	.needs_cmds = (const char *const []) {
  		"quotacheck",
  		NULL
testcases/kernel/syscalls/quotactl/quotactl02.c +4 -2
index d9c4f9b2e..3a52d0e74 100644
@@ -150,9 +150,11 @@ static struct tst_test test = {
  	.test = verify_quota,
  	.tcnt = ARRAY_SIZE(tcases),
  	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "usrquota,grpquota",
+	},
  	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota,grpquota",
  	.setup = setup,
  	.cleanup = cleanup,
  	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
testcases/kernel/syscalls/quotactl/quotactl03.c +4 -2
index 22f5496b6..90dc4bb0b 100644
@@ -83,9 +83,11 @@ static struct tst_test test = {
  	},
  	.test_all = verify_quota,
  	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "usrquota",
+	},
  	.mntpoint = MNTPOINT,
-	.mnt_data = "usrquota",
  	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
  	.tags = (const struct tst_tag[]) {
  		{"linux-git", "657bdfb7f5e6"},
testcases/kernel/syscalls/quotactl/quotactl04.c +3 -1
index a57e6be60..8bc3efdd0 100644
@@ -162,7 +162,9 @@ static struct tst_test test = {
  	.setup = setup,
  	.cleanup = cleanup,
  	.needs_device = 1,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
  	.mntpoint = MNTPOINT,
  	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
  	.needs_cmds = (const char *[]) {
testcases/kernel/syscalls/quotactl/quotactl05.c +4 -2
index ac75cee31..63e6eafbb 100644
@@ -113,9 +113,11 @@ static struct tst_test test = {
  	.test = verify_quota,
  	.tcnt = ARRAY_SIZE(tcases),
  	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+		.mnt_data = "prjquota",
+	},
  	.mntpoint = MNTPOINT,
-	.mnt_data = "prjquota",
  	.setup = setup,
  	.cleanup = cleanup,
  	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
testcases/kernel/syscalls/quotactl/quotactl06.c +4 -2
index 74a098a8c..f113cb462 100644
@@ -219,10 +219,12 @@ static struct tst_test test = {
  	},
  	.tcnt = ARRAY_SIZE(tcases),
  	.test = verify_quotactl,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mnt_data = "usrquota",
+	},
  	.mntpoint = MNTPOINT,
  	.mount_device = 1,
-	.mnt_data = "usrquota",
  	.needs_cmds = (const char *const []) {
  		"quotacheck",
  		NULL
testcases/kernel/syscalls/quotactl/quotactl07.c +3 -1
index 34ff2705d..28db6ba12 100644
@@ -83,7 +83,9 @@ static struct tst_test test = {
  	},
  	.test_all = verify_quota,
  	.format_device = 1,
-	.dev_fs_type = "xfs",
+	.fs = {
+		.type = "xfs",
+	},
  	.mntpoint = MNTPOINT,
  	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
  	.tags = (const struct tst_tag[]) {
testcases/kernel/syscalls/quotactl/quotactl08.c +3 -1
index 0fabb51a5..67638c226 100644
@@ -216,7 +216,9 @@ static struct tst_test test = {
  	.test = verify_quota,
  	.tcnt = ARRAY_SIZE(tcases),
  	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+	},
  	.needs_device = 1,
  	.setup = setup,
  	.cleanup = cleanup,
testcases/kernel/syscalls/quotactl/quotactl09.c +4 -2
index 9a03bff5f..838a67338 100644
@@ -176,8 +176,10 @@ static struct tst_test test = {
  	},
  	.tcnt = ARRAY_SIZE(tcases),
  	.test = verify_quotactl,
-	.dev_fs_opts = (const char *const[]){"-O quota", NULL},
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const[]){"-O quota", NULL},
+	},
  	.mntpoint = MNTPOINT,
  	.mount_device = 1,
  	.needs_root = 1,
testcases/kernel/syscalls/statx/statx05.c +3 -1
index 9781b3e70..242771606 100644
@@ -121,7 +121,9 @@ static struct tst_test test = {
  	.needs_root = 1,
  	.needs_device = 1,
  	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4"
+	},
  	.needs_cmds = (const char *[]) {
  		"mkfs.ext4 >= 1.43.0",
  		"e4crypt",
testcases/kernel/syscalls/statx/statx06.c +5 -3
index 1771dff49..bbc90c392 100644
@@ -155,7 +155,9 @@ static struct tst_test test = {
  	.needs_root = 1,
  	.mntpoint = MOUNT_POINT,
  	.mount_device = 1,
-	.dev_fs_type = "ext4",
-	.dev_fs_opts = (const char *const []){"-I", "256", NULL},
-	.mnt_flags = MS_STRICTATIME,
+	.fs = {
+		.type = "ext4",
+		.mkfs_opts = (const char *const []){"-I", "256", NULL},
+		.mnt_flags = MS_STRICTATIME,
+	},
  };
testcases/kernel/syscalls/statx/statx07.c +3 -1
index 1a568ec9e..4c8af5317 100644
@@ -168,7 +168,9 @@ static struct tst_test test = {
  	.cleanup = cleanup,
  	.min_kver = "4.16",
  	.needs_tmpdir = 1,
-	.dev_fs_type = "nfs",
+	.fs = {
+		.type = "nfs"
+	},
  	.needs_root = 1,
  	.needs_cmds = (const char *[]) {
  		"exportfs",
testcases/kernel/syscalls/statx/statx09.c +0 -0
index 6e75ff3ec..25d14be0e 100644

testcases/kernel/syscalls/statx/statx09.c static struct tst_test test = { · line 164

Quoted 10 lines
testcases/kernel/syscalls/statx/statx09.c +3 -1
@@ -156,7 +156,9 @@ static struct tst_test test = {
  	.needs_root = 1,
  	.needs_device = 1,
  	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.fs = {
+		.type = "ext4",
+	},
  	.needs_kconfigs = (const char *[]) {
  		"CONFIG_FS_VERITY",
  		NULL

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/2
#3 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

In reply to Cyril Hrubis

Hi Cyril,

Quoted 10 lines

This commit does:

* Group the filesystem type, mkfs and mount options into a separate structure

* Add an array of these structures to be able to define per filesystem mkfs and mount options

The details on the usage should be hopefully clear from the documentation comments for the struct tst_test.

Nice cleanup!

BTW is this effort somehow related to Martin's suggestion to "combine .all_filesystems + .needs_rofs together"? [1] Or you're still not convinced it'd be useful?

Also, this reminds me our goal to implement minimal filesystem size required per filesystem.

[1] https://lore.kernel.org/ltp/[email protected]/

...

Quoted 4 lines

+/**
+ * struct tst_fs - A file system type, mkfs and mount options
+ *
+ * @fs_type A filesystem type to use.

nit: @type.

Unfortunately sphinx does not complain when building docs, but you can see "undescribed" in the resulted html.

Quoted 25 lines

+ *
+ * @mkfs_opts: A NULL terminated array of options passed to mkfs in the case
+ * of 'tst_test.format_device'. These options are passed to mkfs
+ * before the device path.
+ *
+ * @mkfs_size_opt: An option passed to mkfs in the case of

+ *                 'tst_test.format_device'. The device size in blocks is
+ *                 passed to mkfs after the device path and can be used to
+ *                 limit the file system not to use the whole block device.

+ *
+ * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
+ * device in the case of 'tst_test.mount_device'.
+ *
+ * @mnt_data: The data passed to mount(2) when the test library mounts a device
+ * in the case of 'tst_test.mount_device'.
+ */

include/tst_test.h +9 -0
+struct tst_fs {
+	const char *type;
+
+	const char *const *mkfs_opts;
+	const char *mkfs_size_opt;
+
+	const unsigned int mnt_flags;
+	const void *mnt_data;
+};

...

Quoted 11 lines

- * @dev_fs_type: If set overrides the default file system type for the device and
- * sets the tst_device.fs_type.
+ * @fs: If fs.type is set it overrides the default file system type for the
+ * device. The rest of the parameters describe default parameters for
+ * mkfs and mount.
*
- * @dev_fs_opts: A NULL terminated array of options passed to mkfs in the case
- * of 'tst_test.format_device'. These options are passed to mkfs
- * before the device path.
- *
- * @dev_extra_opts: A NULL terminated array of extra options passed to mkfs in

Quoted 5 lines
- *                  the case of 'tst_test.format_device'. Extra options are
- *                  passed to mkfs after the device path. Commonly the option
- *                  after mkfs is the number of blocks and can be used to limit
- *                  the file system not to use the whole block device.

+ * @fss: A NULL type terminated array of per file system type options. If

Could this be fs_all (although it can be used also without all_filesystems just to describe more fs)? Because fss looks confusing a bit (it looks as some abbreviation, thus I would
not match it to fs member).

Quoted 2 lines

+ * tst_test.all_filesystems is not set the array describes a list of
+ * file systems to test along with parameters to pass to mkfs and mount.

So that one can decide if use .fss instead of .all_filesystems and .skip_filesystems? I like the flexibility, but it can leads to confusion.

Also it'd be like to 1) use fss in some test 2) have at least trivial library test.

Also nit: writing it as @all_filesystems formats it red (I'd prefer to be a HTML link to the member in docs, but no idea how to do it. @Andrea, any idea?)

Quoted 3 lines
+ *       If tst_test.all_filesystems is set the mkfs and mount options are
+ *       taken from tst_test.fs unless there is an override for a given
+ *       file system type defined in this array.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

In reply to Cyril Hrubis

Hi,
a design note below.

Quoted 91 lines · Cyril Hrubis

This commit does:

* Group the filesystem type, mkfs and mount options into a separate structure

* Add an array of these structures to be able to define per filesystem mkfs and mount options

The details on the usage should be hopefully clear from the documentation comments for the struct tst_test.

---
  include/tst_test.h                            | 64 ++++++++++------
  lib/tst_test.c                                | 73 +++++++++++++------
  .../kernel/syscalls/fanotify/fanotify22.c     |  4 +-
  .../kernel/syscalls/fanotify/fanotify23.c     |  4 +-
  .../kernel/syscalls/getxattr/getxattr04.c     |  4 +-
  testcases/kernel/syscalls/ioctl/ioctl08.c     |  4 +-
  testcases/kernel/syscalls/mmap/mmap16.c       | 19 ++---
  .../kernel/syscalls/quotactl/quotactl01.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl02.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl03.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl04.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl05.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl06.c     |  6 +-
  .../kernel/syscalls/quotactl/quotactl07.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl08.c     |  4 +-
  .../kernel/syscalls/quotactl/quotactl09.c     |  6 +-
  testcases/kernel/syscalls/statx/statx05.c     |  4 +-
  testcases/kernel/syscalls/statx/statx06.c     |  8 +-
  testcases/kernel/syscalls/statx/statx07.c     |  4 +-
  testcases/kernel/syscalls/statx/statx09.c     |  4 +-
  20 files changed, 157 insertions(+), 83 deletions(-)
include/tst_test.h +33 -7
index 8dc20d110..6ac11f7d8 100644
@@ -247,6 +247,36 @@ struct tst_ulimit_val {
  	rlim_t rlim_cur;
  };
 
+/**
+ * struct tst_fs - A file system type, mkfs and mount options
+ *
+ * @fs_type A filesystem type to use.
+ *
+ * @mkfs_opts: A NULL terminated array of options passed to mkfs in the case
+ *             of 'tst_test.format_device'. These options are passed to mkfs
+ *             before the device path.
+ *
+ * @mkfs_size_opt: An option passed to mkfs in the case of
+ *                 'tst_test.format_device'. The device size in blocks is
+ *                 passed to mkfs after the device path and can be used to
+ *                 limit the file system not to use the whole block device.
+ *
+ * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
+ *             device in the case of 'tst_test.mount_device'.
+ *
+ * @mnt_data: The data passed to mount(2) when the test library mounts a device
+ *            in the case of 'tst_test.mount_device'.
+ */
+struct tst_fs {
+	const char *type;
+
+	const char *const *mkfs_opts;
+	const char *mkfs_size_opt;
+
+	const unsigned int mnt_flags;
+	const void *mnt_data;
+};
+
  /**
   * struct tst_test - A test description.
   *
@@ -377,29 +407,21 @@ struct tst_ulimit_val {
   *
   * @dev_min_size: A minimal device size in megabytes.
   *
- * @dev_fs_type: If set overrides the default file system type for the device and
- *               sets the tst_device.fs_type.
+ * @fs: If fs.type is set it overrides the default file system type for the
+ *      device. The rest of the parameters describe default parameters for
+ *      mkfs and mount.
   *
- * @dev_fs_opts: A NULL terminated array of options passed to mkfs in the case
- *               of 'tst_test.format_device'. These options are passed to mkfs
- *               before the device path.
- *
- * @dev_extra_opts: A NULL terminated array of extra options passed to mkfs in

include/tst_test.h struct tst_ulimit_val { · line 419

Quoted 10 lines
include/tst_test.h +6 -4
- *                  the case of 'tst_test.format_device'. Extra options are
- *                  passed to mkfs after the device path. Commonly the option
- *                  after mkfs is the number of blocks and can be used to limit
- *                  the file system not to use the whole block device.
+ * @fss: A NULL type terminated array of per file system type options. If
+ *       tst_test.all_filesystems is not set the array describes a list of
+ *       file systems to test along with parameters to pass to mkfs and mount.
+ *       If tst_test.all_filesystems is set the mkfs and mount options are
+ *       taken from tst_test.fs unless there is an override for a given
+ *       file system type defined in this array.

I like the general idea but I don't see the point of having separate .fs and .fss. You could simply use .fss[0] for the same purpose as .fs.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Hi Martin, Cyril,

Quoted 2 lines

Hi,
a design note below.

...

Quoted 9 lines
Quoted 6 lines

+ * @fss: A NULL type terminated array of per file system type options. If

+ *       tst_test.all_filesystems is not set the array describes a list of
+ *       file systems to test along with parameters to pass to mkfs and mount.
+ *       If tst_test.all_filesystems is set the mkfs and mount options are
+ *       taken from tst_test.fs unless there is an override for a given
+ *       file system type defined in this array.

I like the general idea but I don't see the point of having separate .fs and .fss. You could simply use .fss[0] for the same purpose as .fs.

Look at the second patch where it is used (quotactl08.c):

static struct tst_test test = {
	...
	.fs = {
		.mkfs_opts = (const char *const[]){
			"-O quota", NULL
		},
		.type = "ext4",
	},

So would you set it as array?

static struct tst_test test = {
	...
	.fss = (struct tst_fs[]){
		{
			.mkfs_opts = (const char *const[]){
				"-O quota", NULL
			},
			.type = "ext4",
		},
		{}
	},

It's a bit verbose, but maybe having separate .fs is slightly more confusing.

Also having only array, we could use .fs name for it.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Quoted 25 lines · Petr Vorel

Look at the second patch where it is used (quotactl08.c):

static struct tst_test test = {
	...
	.fs = {
		.mkfs_opts = (const char *const[]){
			"-O quota", NULL
		},
		.type = "ext4",
	},

So would you set it as array?

static struct tst_test test = {
	...
	.fss = (struct tst_fs[]){
		{
			.mkfs_opts = (const char *const[]){
				"-O quota", NULL
			},
			.type = "ext4",
		},
		{}
	},
Quoted 3 lines

It's a bit verbose, but maybe having separate .fs is slightly more confusing.

Also having only array, we could use .fs name for it.

It's a lot less confusing than having half of the filesystem settings in .fs and the other half in .fss when you enable .all_filesystems.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Hi!

Quoted 2 lines

It's a lot less confusing than having half of the filesystem settings in .fs and the other half in .fss when you enable .all_filesystems.

There is a subltle difference in the design which I tried to explain in the documentation comment. If you enable .all_filesystems all parameters are taken from the fs and the fss severs only as an override for the defaults in fs. Since the test has no idea about which filesystems are tested on .all_filesystems the defaults has to be stored somewhere.

Another option would be storing the defaults in .fss with NULL filesystem name, but that would IMHO be even more confusing.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Quoted 2 lines · Cyril Hrubis

Another option would be storing the defaults in .fss with NULL filesystem name, but that would IMHO be even more confusing.

Yes, that is the solution that I had in mind when I wrote the previous e-mail. It makes more sense to me.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Hi!

Quoted 5 lines
Quoted 2 lines

Another option would be storing the defaults in .fss with NULL filesystem name, but that would IMHO be even more confusing.

Yes, that is the solution that I had in mind when I wrote the previous e-mail. It makes more sense to me.

Unfortunately this does not work, since the array is NULL fs_type terminated.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 5 lines
Quoted 2 lines

Another option would be storing the defaults in .fss with NULL filesystem name, but that would IMHO be even more confusing.

Yes, that is the solution that I had in mind when I wrote the previous e-mail. It makes more sense to me.

Unfortunately this does not work, since the array is NULL fs_type terminated.

You can make an exception for .fss[0] since it doesn't make sense to have zero-length array there.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

Re: [LTP] [PATCH 1/2] lib: tst_test: Add per filesystem mkfs and mount opts

Hi!

Quoted 2 lines

You can make an exception for .fss[0] since it doesn't make sense to have zero-length array there.

Good point, let me try...

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

PATCH 2/2 syscalls: quotactl: Move mkfs opts into tst_test

In reply to Cyril Hrubis
---
 testcases/kernel/syscalls/quotactl/quotactl04.c | 15 ++++++---------
 testcases/kernel/syscalls/quotactl/quotactl08.c | 15 +++++----------
 2 files changed, 11 insertions(+), 19 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl04.c +6 -9
index 8bc3efdd0..d1416c0a4 100644
@@ -32,7 +32,7 @@
 #define FMTID QFMT_VFS_V1
 
 static int32_t fmt_id = FMTID;
-static int test_id, mount_flag;
+static int test_id;
 static struct dqblk set_dq = {
 	.dqb_bsoftlimit = 100,
 	.dqb_valid = QIF_BLIMITS
@@ -98,12 +98,8 @@ static struct tcase {
 
 static void setup(void)
 {
-	const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
-
 	quotactl_info();
-	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
-	mount_flag = 1;
+
 	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
 
 	TEST(do_quotactl(fd, QCMD(Q_GETNEXTQUOTA, PRJQUOTA), tst_device->dev,
@@ -116,8 +112,6 @@ static void cleanup(void)
 {
 	if (fd > -1)
 		SAFE_CLOSE(fd);
-	if (mount_flag && tst_umount(MNTPOINT))
-		tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
 }
 
 static void verify_quota(unsigned int n)
@@ -161,8 +155,11 @@ static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
-	.needs_device = 1,
+	.mount_device = 1,
 	.fs = {
+		.mkfs_opts = (const char *const[]){
+			"-I 256", "-O quota,project", NULL
+		},
 		.type = "ext4"
 	},
 	.mntpoint = MNTPOINT,
testcases/kernel/syscalls/quotactl/quotactl08.c +5 -10
index 67638c226..9ae5fb9e2 100644
@@ -44,7 +44,7 @@
 #define MNTPOINT	"mntpoint"
 
 static int32_t fmt_id = QFMT_VFS_V1;
-static int test_id, mount_flag;
+static int test_id;
 static struct dqblk set_dq = {
 	.dqb_bsoftlimit = 100,
 	.dqb_valid = QIF_BLIMITS
@@ -153,14 +153,8 @@ static struct tcase {
 
 static void setup(void)
 {
-	const char *const fs_opts[] = { "-O quota", NULL};
-
 	quotactl_info();
 
-	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
-	mount_flag = 1;
-
 	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
 	TEST(do_quotactl(fd, QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev,
 		0, (void *) &res_ndq));
@@ -172,8 +166,6 @@ static void cleanup(void)
 {
 	if (fd > -1)
 		SAFE_CLOSE(fd);
-	if (mount_flag && tst_umount(MNTPOINT))
-		tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
 }
 
 static void verify_quota(unsigned int n)
@@ -217,9 +209,12 @@ static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
 	.mntpoint = MNTPOINT,
 	.fs = {
+		.mkfs_opts = (const char *const[]){
+			"-O quota", NULL
+		},
 		.type = "ext4",
 	},
-	.needs_device = 1,
+	.mount_device = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
Signature · 5 lines
2.44.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp