[LTP] [PATCH v3 09/12] syscalls/quotactl03: Add quotactl_fd test variant
Yang Xu
xuyang2018.jy@fujitsu.com
Tue Nov 9 11:54:45 CET 2021
Also remove dupcliated header file.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
.../kernel/syscalls/quotactl/quotactl03.c | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index e0e4bf5b2..22f5496b6 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -23,19 +23,17 @@
*/
#define _GNU_SOURCE
-#include "config.h"
#include <errno.h>
#include <unistd.h>
#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>
-static const char mntpoint[] = "mnt_point";
static uint32_t test_id = 0xfffffffc;
static void verify_quota(void)
@@ -44,7 +42,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,7 +61,21 @@ static void verify_quota(void)
tst_res(TPASS, "quotactl() failed with ENOENT as expected");
}
+static void setup(void)
+{
+ quotactl_info();
+ fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
+}
+
+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",
@@ -72,8 +84,9 @@ static struct tst_test test = {
.test_all = verify_quota,
.mount_device = 1,
.dev_fs_type = "xfs",
- .mntpoint = mntpoint,
+ .mntpoint = MNTPOINT,
.mnt_data = "usrquota",
+ .test_variants = QUOTACTL_SYSCALL_VARIANTS,
.tags = (const struct tst_tag[]) {
{"linux-git", "657bdfb7f5e6"},
{}
--
2.23.0
More information about the ltp
mailing list