diff mbox series

[v1,09/11] syscalls/quotactl03: Add quotactl_fd test variant

Message ID 1634562888-5987-4-git-send-email-xuyang2018.jy@fujitsu.com
State Changes Requested
Headers show
Series [v1,01/11] syscalls/quotactl01: Also test with vfsv1 format | expand

Commit Message

Yang Xu Oct. 18, 2021, 1:14 p.m. UTC
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../kernel/syscalls/quotactl/quotactl03.c     | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)

Comments

Cyril Hrubis Oct. 26, 2021, 2:25 p.m. UTC | #1
Hi!
Same two minor comments for the previous patch apply to this patch as well.

Otherwise it looks good.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index 9711b7f07..019e7c646 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -28,15 +28,18 @@ 
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/quota.h>
-
 #include "tst_test.h"
 #include "lapi/quotactl.h"
+#include "quotactl_var.h"
 
 #ifdef HAVE_XFS_XQM_H
 # include <xfs/xqm.h>
 
-static const char mntpoint[] = "mnt_point";
+#define MNTPOINT	"mnt_point"
+#define TESTFILE	MNTPOINT "/testfile"
+
 static uint32_t test_id = 0xfffffffc;
+static int fd = -1;
 
 static void verify_quota(void)
 {
@@ -44,7 +47,7 @@  static void verify_quota(void)
 
 	res_dquota.d_id = 1;
 
-	TEST(quotactl(QCMD(Q_XGETNEXTQUOTA, USRQUOTA), tst_device->dev,
+	TEST(do_quotactl(fd, QCMD(Q_XGETNEXTQUOTA, USRQUOTA), tst_device->dev,
 		test_id, (void *)&res_dquota));
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "quotactl() found the next active ID: %u unexpectedly",
@@ -63,6 +66,18 @@  static void verify_quota(void)
 		tst_res(TPASS, "quotactl() failed with ENOENT as expected");
 }
 
+static void setup(void)
+{
+	quotactl_info();
+	fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666);
+}
+
+static void cleanup(void)
+{
+	if (fd > -1)
+		SAFE_CLOSE(fd);
+}
+
 static struct tst_test test = {
 	.needs_root = 1,
 	.needs_kconfigs = (const char *[]) {
@@ -72,8 +87,11 @@  static struct tst_test test = {
 	.test_all = verify_quota,
 	.mount_device = 1,
 	.dev_fs_type = "xfs",
-	.mntpoint = mntpoint,
-	.mnt_data = "usrquota",
+	.mntpoint = MNTPOINT,
+	.mnt_data = "usrquota,grpquota",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_variants = 2,
 };
 
 #else