diff mbox series

[v2,2/2] syscalls: quotactl: Move mkfs opts into tst_test

Message ID 20240612121106.11127-3-chrubis@suse.cz
State Accepted
Headers show
Series tst_test per FS options and small cleanup | expand

Commit Message

Cyril Hrubis June 12, 2024, 12:11 p.m. UTC
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../kernel/syscalls/quotactl/quotactl04.c     | 19 +++++++++----------
 .../kernel/syscalls/quotactl/quotactl08.c     | 19 ++++++++-----------
 2 files changed, 17 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index 7fdff6502..91f15eb5d 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -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,9 +155,14 @@  static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
-	.needs_device = 1,
+	.mount_device = 1,
 	.filesystems = (struct tst_fs []) {
-		{.type = "ext4"},
+		{
+			.type = "ext4",
+			.mkfs_opts = (const char *const[]) {
+				"-I 256", "-O quota,project", NULL
+			},
+		},
 		{}
 	},
 	.mntpoint = MNTPOINT,
diff --git a/testcases/kernel/syscalls/quotactl/quotactl08.c b/testcases/kernel/syscalls/quotactl/quotactl08.c
index aafb1cd2b..85a2f4731 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl08.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl08.c
@@ -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,10 +209,15 @@  static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
 	.mntpoint = MNTPOINT,
 	.filesystems = (struct tst_fs []) {
-		{.type = "ext4"},
+		{
+			.type = "ext4",
+			.mkfs_opts = (const char *const[]){
+				"-O quota", NULL
+			},
+		},
 		{}
 	},
-	.needs_device = 1,
+	.mount_device = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,