All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem
Date: Fri, 1 Nov 2019 20:55:58 +0800	[thread overview]
Message-ID: <1572612959-20577-5-git-send-email-xuyang2018.jy@cn.fujitsu.com> (raw)
In-Reply-To: <1572612959-20577-1-git-send-email-xuyang2018.jy@cn.fujitsu.com>

This is a variant about quotactl02. It is used to test project quota.
I split it into a new case instead of adding it in quotaclt02 because
kernel doesn't permit mount both group and project quota before
commit d892d5864f02 ("xfs: Start using pquotaino from the superblock.").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 runtest/syscalls                              |  1 +
 testcases/kernel/syscalls/quotactl/.gitignore |  2 +
 .../kernel/syscalls/quotactl/quotactl05.c     | 99 +++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c

diff --git a/runtest/syscalls b/runtest/syscalls
index c30e9e620..f2c7b0daf 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -954,6 +954,7 @@ quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
+quotactl05 quotactl05
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index 1db7c5d98..9621e7717 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -2,3 +2,5 @@
 /quotactl02
 /quotactl03
 /quotactl04
+/quotactl05
+
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
new file mode 100644
index 000000000..2c4f49f7c
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * Test Name: quotactl05
+ *
+ * Description:
+ * This testcase checks basic flags of quotactl(2) for project on an XFS file
+ * system:
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for project.
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for project.
+ * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits for project.
+ * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits Cgreater than or equal to ID for project.
+ * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for project.
+ * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for project.
+ */
+#include "quotactl02.h"
+#if defined(HAVE_XFS_XQM_H)
+
+static uint32_t qflagp = XFS_QUOTA_PDQ_ENFD;
+static struct t_case {
+	int cmd;
+	void *addr;
+	void (*func_check)();
+	int check_subcmd;
+	int flag;
+	char *des;
+} tcases[] = {
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflagp, check_qoff,
+	QCMD(Q_XGETQSTAT, PRJQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflagp, check_qon,
+	QCMD(Q_XGETQSTAT, PRJQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, PRJQUOTA), 0,
+	"Q_XGETQUOTA for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, PRJQUOTA), 0,
+	"Q_XGETNEXTQUOTA for project"},
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflagp, check_qoffv,
+	QCMD(Q_XGETQSTATV, PRJQUOTA), 1,
+	"turn off xfs quota and get xfs quota off statv for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflagp, check_qonv,
+	QCMD(Q_XGETQSTATV, PRJQUOTA), 1,
+	"turn on xfs quota and get xfs quota on statv for project"},
+#endif
+};
+
+static void setup(void)
+{
+	test_id = geteuid();
+}
+
+static void verify_quota(unsigned int n)
+{
+	struct t_case *tc = &tcases[n];
+
+	TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+		return;
+	}
+
+	if (tc->flag)
+		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
+	else
+		tc->func_check(tc->check_subcmd, tc->des);
+}
+
+static struct tst_test test = {
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.needs_kconfigs = kconfigs,
+	.test = verify_quota,
+	.tcnt = ARRAY_SIZE(tcases),
+	.mount_device = 1,
+	.dev_fs_type = "xfs",
+	.mntpoint = mntpoint,
+	.mnt_data = "prjquota",
+	.setup = setup,
+};
+
+#else
+	TST_TEST_TCONF("This system didn't have <xfs/xqm.h>");
+#endif
-- 
2.18.0




  parent reply	other threads:[~2019-11-01 12:55 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
2019-10-31 14:02   ` Petr Vorel
2019-10-23  9:00 ` [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4 Yang Xu
2019-10-31 15:26   ` Petr Vorel
2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
2019-11-15 15:51         ` Petr Vorel
2019-11-18  6:42           ` Xu, Yang
2019-11-20 17:09             ` Petr Vorel
2019-11-21  3:59               ` Yang Xu
2019-11-15 16:48         ` Petr Vorel
2019-11-18  6:18           ` Xu, Yang
2019-11-18  6:24             ` Petr Vorel
2019-11-01 12:55       ` [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test Yang Xu
2019-11-15 17:41         ` Petr Vorel
2019-11-18  7:59           ` Xu, Yang
2019-11-18  8:25             ` Petr Vorel
2019-11-01 12:55       ` [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
2022-03-15 17:19         ` Petr Vorel
2022-03-16  2:00           ` xuyang2018.jy
2019-11-01 12:55       ` Yang Xu [this message]
2019-11-01 12:55       ` [LTP] [PATCH v3 5/5] syscalls/quotactl06: Add new testcase Yang Xu
2019-11-12  8:05       ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
2019-11-15  9:02         ` Yang Xu
2019-11-15  9:25           ` Petr Vorel
2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
2019-10-24  8:25   ` Jan Kara
2019-10-25  8:49     ` Yang Xu
2019-10-31 14:10     ` Petr Vorel
2019-10-31 14:31   ` Petr Vorel
2019-11-01 12:44     ` Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 4/6] syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
2019-10-24  8:14   ` Jan Kara
2019-10-24  9:55     ` Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 6/6] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
2019-12-17 10:12 [LTP] [PATCH v1 0/4] cleanup capset testcase Yang Xu
2019-12-17 10:12 ` [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
2019-12-17 10:16   ` Yang Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1572612959-20577-5-git-send-email-xuyang2018.jy@cn.fujitsu.com \
    --to=xuyang2018.jy@cn.fujitsu.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.