[LTP] [PATCH v2 12/13] syscalls/quotactl07: Add quotactl_fd test variant
Yang Xu
xuyang2018.jy@fujitsu.com
Wed Oct 27 14:29:29 CEST 2021
Also man-pages has error that Q_XQUOTARM was not introduced by kernel
3.16. So use invalid type directly.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
.../kernel/syscalls/quotactl/quotactl07.c | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl07.c b/testcases/kernel/syscalls/quotactl/quotactl07.c
index 2992a6112..d29a56ee4 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl07.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl07.c
@@ -16,21 +16,22 @@
#include <stdio.h>
#include <sys/quota.h>
#include "tst_test.h"
-#include "lapi/quotactl.h"
+#include "quotactl_syscall_var.h"
#ifdef HAVE_XFS_XQM_H
# include <xfs/xqm.h>
#define MNTPOINT "mntpoint"
+#define TESTFILE MNTPOINT "/testfile"
+
+static int fd = -1;
-static uint32_t qflag_acct = XFS_QUOTA_UDQ_ACCT;
-static unsigned int valid_type = XFS_USER_QUOTA;
/* Include a valid quota type to avoid other EINVAL error */
static unsigned int invalid_type = XFS_GROUP_QUOTA << 1 | XFS_USER_QUOTA;
static void verify_quota(void)
{
- TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0, (void *)&invalid_type));
+ TEST(do_quotactl(fd, QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0, (void *)&invalid_type));
if (TST_ERR == EINVAL)
tst_res(TPASS, "Q_XQUOTARM has quota type check");
else
@@ -39,17 +40,19 @@ static void verify_quota(void)
static void setup(void)
{
- TEST(quotactl(QCMD(Q_XQUOTAOFF, USRQUOTA), tst_device->dev, 0, (void *)&qflag_acct));
- if (TST_RET == -1)
- tst_brk(TBROK | TTERRNO, "quotactl with Q_XQUOTAOFF failed");
+ quotactl_info();
+ fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666);
+}
- TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0, (void *)&valid_type));
- if (TST_ERR == EINVAL)
- tst_brk(TCONF, "current system doesn't support Q_XQUOTARM, skip it");
+static void cleanup(void)
+{
+ if (fd > -1)
+ SAFE_CLOSE(fd);
}
static struct tst_test test = {
.setup = setup,
+ .cleanup = cleanup,
.needs_root = 1,
.needs_kconfigs = (const char *[]) {
"CONFIG_XFS_QUOTA",
@@ -60,6 +63,7 @@ static struct tst_test test = {
.dev_fs_type = "xfs",
.mnt_data = "usrquota",
.mntpoint = MNTPOINT,
+ .test_variants = QUOTACTL_SYSCALL_VARIANTS,
.tags = (const struct tst_tag[]) {
{"linux-git", "3dd4d40b4208"},
{}
--
2.23.0
More information about the ltp
mailing list