[PATCH v2 4/7] tests: enhance test coverage of quotactl syscall parser

Zhibin Li 08826794brmt at gmail.com
Thu Jul 12 09:32:11 UTC 2018


* tests/quotactl.c (print_dqfmt): New function.
(main): Use print_dqfmt to print flags of quota format, improve existing
tests and add more tests for Q_GETFMT.
* tests/quotactl-xfs.c: Improve existing tests and add more tests for
Q_XGETQSTAT and Q_XGETQSTATV.
---
 tests/quotactl-xfs.c | 13 +++++++++++--
 tests/quotactl.c     | 40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/tests/quotactl-xfs.c b/tests/quotactl-xfs.c
index fa536eb3..9955292b 100644
--- a/tests/quotactl-xfs.c
+++ b/tests/quotactl-xfs.c
@@ -298,21 +298,30 @@ main(void)
 		    ARG_STR("/dev/sda1"), xqstat, print_xquota_stat, (intptr_t) 1);
 
 	check_quota(CQF_ID_SKIP | CQF_ADDR_CB,
+		    ARG_STR(QCMD(Q_XGETQSTAT, USRQUOTA)),
+		    ARG_STR("NULL"), xqstat, print_xquota_stat, (intptr_t) 2);
+
+	check_quota(CQF_ID_SKIP,
 		    ARG_STR(QCMD(Q_XGETQSTAT, PRJQUOTA)),
 		    unterminated, unterminated_str,
-		    xqstat + 1, print_xquota_stat, (intptr_t) 2);
+		    xqstat + 1);
 
 
 	/* Q_XGETQSTATV */
 
 	check_quota(CQF_ID_SKIP | CQF_ADDR_CB,
 		    ARG_STR(QCMD(Q_XGETQSTATV, USRQUOTA)),
-		    ARG_STR("/dev/sda1"), xqstatv, print_xquota_statv, 1);
+		    ARG_STR("/dev/sda1"), xqstatv, print_xquota_statv, (intptr_t) 1);
 
 	check_quota(CQF_ID_SKIP | CQF_ADDR_CB,
 		    ARG_STR(QCMD(Q_XGETQSTATV, GRPQUOTA)),
 		    ARG_STR(NULL), xqstatv, print_xquota_statv, (intptr_t) 2);
 
+	check_quota(CQF_ID_SKIP,
+		    ARG_STR(QCMD(Q_XGETQSTATV, PRJQUOTA)),
+		    unterminated, unterminated_str,
+		    xqstatv + 1);
+
 
 	/* Q_XQUOTARM */
 
diff --git a/tests/quotactl.c b/tests/quotactl.c
index f1648d94..21d20102 100644
--- a/tests/quotactl.c
+++ b/tests/quotactl.c
@@ -161,6 +161,37 @@ print_dqinfo(long rc, void *ptr, void *arg)
 	printf("}");
 }
 
+void
+print_dqfmt(long rc, void *ptr, void *arg)
+{
+	uint32_t *fmtval = ptr;
+	long out_arg = (long) arg;
+	const char *fmtstr;
+
+	if (((rc != 0) && out_arg) || (out_arg > 1)) {
+		printf("%p", fmtval);
+		return;
+	}
+	printf("[");
+	switch (*fmtval) {
+	case 1:
+		fmtstr = "QFMT_VFS_OLD";
+		break;
+	case 2:
+		fmtstr = "QFMT_VFS_V0";
+		break;
+	case 3:
+		fmtstr = "QFMT_OCFS2";
+		break;
+	case 4:
+		fmtstr = "QFMT_VFS_V1";
+		break;
+	default:
+		printf("%#x /* QFMT_VFS_??? */]", *fmtval);
+		return;
+	}
+	printf("%s]", fmtstr);
+}
 
 int
 main(void)
@@ -294,9 +325,14 @@ main(void)
 	check_quota(CQF_ID_SKIP,
 		    ARG_STR(QCMD(Q_GETFMT, USRQUOTA)),
 		    unterminated, unterminated_str, fmt + 1);
-	check_quota(CQF_ID_SKIP,
+	check_quota(CQF_ID_SKIP | CQF_ADDR_CB,
+		    ARG_STR(QCMD(Q_GETFMT, GRPQUOTA)),
+		    ARG_STR("/dev/sda1"), fmt, print_dqfmt, (uintptr_t) 1);
+	/* Try to check valid quota format */
+	*fmt = QFMT_VFS_OLD;
+	check_quota(CQF_ID_SKIP | CQF_ADDR_CB,
 		    ARG_STR(QCMD(Q_GETFMT, GRPQUOTA)),
-		    ARG_STR("/dev/sda1"), fmt);
+		    ARG_STR("/dev/sda1"), fmt, print_dqfmt, (uintptr_t) 1);
 
 
 	/* Q_SYNC */
-- 
2.14.4



More information about the Strace-devel mailing list