[LTP] [PATCH v1 10/11] syscalls/quotactl04: Add quotactl_fd test variant
Yang Xu
xuyang2018.jy@fujitsu.com
Mon Oct 18 15:14:47 CEST 2021
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
.../kernel/syscalls/quotactl/quotactl04.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index e01657de5..010fa8fd6 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
*/
/*\
@@ -44,11 +44,14 @@
#include "tst_test.h"
#include "lapi/quotactl.h"
#include "tst_safe_stdio.h"
+#include "quotactl_var.h"
#define FMTID QFMT_VFS_V1
#define MNTPOINT "mntpoint"
+#define TESTFILE MNTPOINT "/testfile"
+
static int32_t fmt_id = FMTID;
-static int test_id, mount_flag;
+static int test_id, mount_flag, fd = -1;
static struct dqblk set_dq = {
.dqb_bsoftlimit = 100,
.dqb_valid = QIF_BLIMITS
@@ -139,6 +142,7 @@ static void setup(void)
const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
int rc, major, minor, patch;
+ quotactl_info();
test_id = geteuid();
f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
@@ -149,10 +153,14 @@ 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(TESTFILE, O_RDWR | O_CREAT, 0666);
}
static void cleanup(void)
{
+ if (fd > -1)
+ SAFE_CLOSE(fd);
+
if (mount_flag && tst_umount(MNTPOINT))
tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
}
@@ -167,7 +175,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;
@@ -200,5 +208,6 @@ static struct tst_test test = {
.needs_cmds = (const char *[]) {
"mkfs.ext4",
NULL
- }
+ },
+ .test_variants = 2,
};
--
2.23.0
More information about the ltp
mailing list