[LTP] [PATCH v1 08/11] syscalls/quotaclt02, 5: Add quotactl_fd test variant
Yang Xu
xuyang2018.jy@fujitsu.com
Mon Oct 18 15:14:45 CEST 2021
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
.../kernel/syscalls/quotactl/quotactl02.c | 14 +++++++++++--
.../kernel/syscalls/quotactl/quotactl02.h | 20 ++++++++++---------
.../kernel/syscalls/quotactl/quotactl05.c | 14 +++++++++++--
3 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index ad81ee7e5..40bd5bd8b 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -121,11 +121,19 @@ static struct t_case {
static void setup(void)
{
+ quotactl_info();
test_id = geteuid();
+ fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666);
check_support_cmd(USRQUOTA);
check_support_cmd(GRPQUOTA);
}
+static void cleanup(void)
+{
+ if (fd > -1)
+ SAFE_CLOSE(fd);
+}
+
static void verify_quota(unsigned int n)
{
struct t_case *tc = &tcases[n];
@@ -144,7 +152,7 @@ static void verify_quota(unsigned int n)
return;
}
- TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+ TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr));
if (TST_RET == -1) {
tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
return;
@@ -166,9 +174,11 @@ static struct tst_test test = {
.tcnt = ARRAY_SIZE(tcases),
.mount_device = 1,
.dev_fs_type = "xfs",
- .mntpoint = mntpoint,
+ .mntpoint = MNTPOINT,
.mnt_data = "usrquota,grpquota",
.setup = setup,
+ .cleanup = cleanup,
+ .test_variants = 2,
};
#else
TST_TEST_TCONF("System doesn't have <xfs/xqm.h>");
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.h b/testcases/kernel/syscalls/quotactl/quotactl02.h
index 37f3d7eb7..5b7c5ab32 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.h
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.h
@@ -14,18 +14,20 @@
#include <stdio.h>
#include "tst_test.h"
#include "lapi/quotactl.h"
+#include "quotactl_var.h"
#ifdef HAVE_XFS_XQM_H
# include <xfs/xqm.h>
+#define MNTPOINT "mntpoint"
+#define TESTFILE MNTPOINT "/testfile"
static struct fs_disk_quota set_dquota = {
.d_rtb_softlimit = 1000,
.d_fieldmask = FS_DQ_RTBSOFT
};
static uint32_t test_id;
-static int x_getnextquota_nsup;
+static int x_getnextquota_nsup, fd = -1;
static int x_getstatv_nsup;
-static const char mntpoint[] = "mnt_point";
void check_support_cmd(int quotatype)
{
@@ -37,12 +39,12 @@ void check_support_cmd(int quotatype)
x_getnextquota_nsup = 0;
x_getstatv_nsup = 0;
- TEST(quotactl(QCMD(Q_XGETNEXTQUOTA, quotatype), tst_device->dev,
+ TEST(do_quotactl(fd, QCMD(Q_XGETNEXTQUOTA, quotatype), tst_device->dev,
test_id, (void *) &resfs_dquota));
if (TST_ERR == EINVAL || TST_ERR == ENOSYS)
x_getnextquota_nsup = 1;
- TEST(quotactl(QCMD(Q_XGETQSTATV, quotatype), tst_device->dev, test_id,
+ TEST(do_quotactl(fd, QCMD(Q_XGETQSTATV, quotatype), tst_device->dev, test_id,
(void *) &resfs_qstatv));
if (TST_ERR == EINVAL || TST_ERR == ENOSYS)
x_getstatv_nsup = 1;
@@ -53,7 +55,7 @@ void check_qoff(int subcmd, char *desp, int flag)
int res;
struct fs_quota_stat res_qstat;
- res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
+ res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat);
if (res == -1) {
tst_res(TFAIL | TERRNO,
"quotactl() failed to get xfs quota off status");
@@ -73,7 +75,7 @@ void check_qon(int subcmd, char *desp, int flag)
int res;
struct fs_quota_stat res_qstat;
- res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
+ res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat);
if (res == -1) {
tst_res(TFAIL | TERRNO,
"quotactl() failed to get xfs quota on status");
@@ -95,7 +97,7 @@ void check_qoffv(int subcmd, char *desp, int flag)
.qs_version = FS_QSTATV_VERSION1,
};
- res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+ res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
if (res == -1) {
tst_res(TFAIL | TERRNO,
"quotactl() failed to get xfs quota off stav");
@@ -117,7 +119,7 @@ void check_qonv(int subcmd, char *desp, int flag)
.qs_version = FS_QSTATV_VERSION1
};
- res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+ res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
if (res == -1) {
tst_res(TFAIL | TERRNO,
"quotactl() failed to get xfs quota on statv");
@@ -139,7 +141,7 @@ void check_qlim(int subcmd, char *desp)
res_dquota.d_rtb_softlimit = 0;
- res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_dquota);
+ res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_dquota);
if (res == -1) {
tst_res(TFAIL | TERRNO,
"quotactl() failed to get xfs disk quota limits");
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
index fbc7f5924..7306623a0 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl05.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -71,10 +71,18 @@ static struct t_case {
static void setup(void)
{
+ quotactl_info();
test_id = geteuid();
+ fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666);
check_support_cmd(PRJQUOTA);
}
+static void cleanup(void)
+{
+ if (fd > -1)
+ SAFE_CLOSE(fd);
+}
+
static void verify_quota(unsigned int n)
{
struct t_case *tc = &tcases[n];
@@ -94,7 +102,7 @@ static void verify_quota(unsigned int n)
return;
}
- TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+ TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr));
if (TST_RET == -1) {
tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
return;
@@ -116,9 +124,11 @@ static struct tst_test test = {
.tcnt = ARRAY_SIZE(tcases),
.mount_device = 1,
.dev_fs_type = "xfs",
- .mntpoint = mntpoint,
+ .mntpoint = MNTPOINT,
.mnt_data = "prjquota",
.setup = setup,
+ .cleanup = cleanup,
+ .test_variants = 2,
};
#else
--
2.23.0
More information about the ltp
mailing list