diff mbox series

[v3,10/12] syscalls/quotactl04: Add quotactl_fd test variant

Message ID 1636455396-8508-1-git-send-email-xuyang2018.jy@fujitsu.com
State Changes Requested
Headers show
Series [v3,01/12] syscalls/quotactl01: Also test with vfsv1 format | expand

Commit Message

Yang Xu Nov. 9, 2021, 10:56 a.m. UTC
Also remove useless geteuid.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/quotactl/quotactl04.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index dab61cf4d..f71016967 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -29,10 +29,10 @@ 
 #include <sys/mount.h>
 #include "tst_safe_stdio.h"
 #include "tst_test.h"
-#include "lapi/quotactl.h"
+#include "quotactl_syscall_var.h"
 
 #define FMTID QFMT_VFS_V1
-#define MNTPOINT	"mntpoint"
+
 static int32_t fmt_id = FMTID;
 static int test_id, mount_flag;
 static struct dqblk set_dq = {
@@ -125,7 +125,7 @@  static void setup(void)
 	const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
 	int rc, major, minor, patch;
 
-	test_id = geteuid();
+	quotactl_info();
 	f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
 	rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
 	if (rc != 3)
@@ -135,10 +135,13 @@  static void setup(void)
 	pclose(f);
 	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
 	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
 }
 
 static void cleanup(void)
 {
+	if (fd > -1)
+		SAFE_CLOSE(fd);
 	if (mount_flag && tst_umount(MNTPOINT))
 		tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
 }
@@ -153,7 +156,7 @@  static void verify_quota(unsigned int n)
 
 	tst_res(TINFO, "Test #%d: %s", n, tc->tname);
 
-	TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));
+	TEST(do_quotactl(fd, tc->cmd, tst_device->dev, *tc->id, tc->addr));
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
 		return;
@@ -183,6 +186,7 @@  static struct tst_test test = {
 	.needs_device = 1,
 	.dev_fs_type = "ext4",
 	.mntpoint = MNTPOINT,
+	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
 	.needs_cmds = (const char *[]) {
 		"mkfs.ext4",
 		NULL