[PATCH v1 2/2] tests/quotactl-xfs.c: fix typos and unify code
Zhibin Li
08826794brmt at gmail.com
Fri Jun 15 07:57:53 UTC 2018
* quotactl-xfs.c: Fix disorder of PRINT_FIELD_U and check_quota function
invocations; use check_quota function for invalid commands; remove unused
variable rc.
(invalid_cmd): New variable.
---
tests/quotactl-xfs.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/tests/quotactl-xfs.c b/tests/quotactl-xfs.c
index fab451e2..c08b1584 100644
--- a/tests/quotactl-xfs.c
+++ b/tests/quotactl-xfs.c
@@ -142,14 +142,14 @@ print_xquota_stat(int rc, void *ptr, void *arg)
# if VERBOSE
printf(", qs_flags=");
printflags(xfs_quota_flags, qs->qs_flags, "XFS_QUOTA_???");
+ PRINT_FIELD_U(", ", *qs, qs_incoredqs);
PRINT_FIELD_U(", qs_uquota={", qs->qs_uquota, qfs_ino);
PRINT_FIELD_U(", ", qs->qs_uquota, qfs_nblks);
PRINT_FIELD_U(", ", qs->qs_uquota, qfs_nextents);
PRINT_FIELD_U("}, qs_gquota={", qs->qs_gquota, qfs_ino);
PRINT_FIELD_U(", ", qs->qs_gquota, qfs_nblks);
PRINT_FIELD_U(", ", qs->qs_gquota, qfs_nextents);
- PRINT_FIELD_U("}, ", *qs, qs_incoredqs);
- PRINT_FIELD_D(", ", *qs, qs_btimelimit);
+ PRINT_FIELD_D("}, ", *qs, qs_btimelimit);
PRINT_FIELD_D(", ", *qs, qs_itimelimit);
PRINT_FIELD_D(", ", *qs, qs_rtbtimelimit);
PRINT_FIELD_U(", ", *qs, qs_bwarnlimit);
@@ -207,7 +207,7 @@ main(void)
char bogus_addr_str[sizeof(void *) * 2 + sizeof("0x")];
char unterminated_str[sizeof(void *) * 2 + sizeof("0x")];
- long rc;
+ static char invalid_cmd[1024];
TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_disk_quota, xdq);
TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_quota_stat, xqstat);
TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_quota_statv, xqstatv);
@@ -234,12 +234,12 @@ main(void)
"|XFS_QUOTA_GDQ_ACCT|XFS_QUOTA_GDQ_ENFD"
"|XFS_QUOTA_PDQ_ENFD|0xdeadbec0]");
- rc = syscall(__NR_quotactl, QCMD(Q_XQUOTAON, 0xfacefeed), bogus_dev,
- bogus_id, bogus_addr);
- printf("quotactl(QCMD(Q_XQUOTAON, %#x /* ???QUOTA */)"
- ", %s, %p) = %s\n",
- QCMD_TYPE(QCMD(Q_XQUOTAON, 0xfacefeed)),
- bogus_dev_str, bogus_addr, sprintrc(rc));
+ snprintf(invalid_cmd, sizeof(invalid_cmd),
+ "QCMD(Q_XQUOTAON, %#x /* ???QUOTA */)",
+ QCMD_TYPE(QCMD(Q_XQUOTAON, 0xfacefeed)));
+ check_quota(CQF_ID_SKIP,
+ QCMD(Q_XQUOTAON, 0xfacefeed), invalid_cmd,
+ bogus_dev, bogus_dev_str, bogus_addr);
/* Q_XQUOTAOFF */
@@ -264,11 +264,11 @@ main(void)
/* Q_XGETQUOTA */
/* Trying our best to get successful result */
- check_quota(CQF_ADDR_CB, ARG_STR(QCMD(Q_GETQUOTA, USRQUOTA)),
+ check_quota(CQF_ADDR_CB, ARG_STR(QCMD(Q_XGETQUOTA, USRQUOTA)),
ARG_STR("/dev/sda1"), getuid(), xdq, print_xdisk_quota,
(intptr_t) 1);
- check_quota(CQF_ADDR_CB, ARG_STR(QCMD(Q_GETQUOTA, GRPQUOTA)),
+ check_quota(CQF_ADDR_CB, ARG_STR(QCMD(Q_XGETQUOTA, GRPQUOTA)),
ARG_STR(NULL), -1, xdq, print_xdisk_quota, (intptr_t) 2);
@@ -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_XGETQSTATV, PRJQUOTA)),
+ 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_XGETQSTAT, USRQUOTA)),
- ARG_STR("/dev/sda1"), xqstatv, print_xquota_statv, 1);
+ ARG_STR(QCMD(Q_XGETQSTATV, USRQUOTA)),
+ 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 */
--
2.14.4
More information about the Strace-devel
mailing list