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

Yang Xu xuyang2018.jy@fujitsu.com
Mon Oct 18 15:14:46 CEST 2021


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

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



More information about the ltp mailing list