From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v6 2/3] syscalls/quotactl07: Refactor this case
Date: Thu, 13 Jan 2022 15:03:23 +0100 [thread overview]
Message-ID: <YeAxK/IMvCIb0Sp7@yuki> (raw)
In-Reply-To: <1641973691-22981-2-git-send-email-xuyang2018.jy@fujitsu.com>
Hi!
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl07.c b/testcases/kernel/syscalls/quotactl/quotactl07.c
> index 2992a6112..2427ef682 100644
> --- a/testcases/kernel/syscalls/quotactl/quotactl07.c
> +++ b/testcases/kernel/syscalls/quotactl/quotactl07.c
> @@ -7,7 +7,9 @@
> /*\
> * [Description]
> *
> - * This is a regresstion test for kernel commit 3dd4d40b4208
> + * This is not only a functional test but also a error test for Q_XQUOTARM.
> + *
> + * It is a regresstion test for kernel commit 3dd4d40b4208
> * ("xfs: Sanity check flags of Q_XQUOTARM call").
> */
>
> @@ -15,51 +17,71 @@
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/quota.h>
> +#include <sys/statvfs.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"
> -
> -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 unsigned int valid_type = XFS_USER_QUOTA;
> +static int mount_flag;
>
> static void verify_quota(void)
> {
> - TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0, (void *)&invalid_type));
> - if (TST_ERR == EINVAL)
> - tst_res(TPASS, "Q_XQUOTARM has quota type check");
> + struct statfs before, after;
> +
> + SAFE_STATFS(MNTPOINT, &before);
> + TST_EXP_PASS(do_quotactl(fd, QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0,
> + (void *)&valid_type), "do_quotactl(Q_XQUOTARM,valid_type)");
> + SAFE_STATFS(MNTPOINT, &after);
> + if (before.f_bavail <= after.f_bavail)
> + tst_res(TPASS, "Q_XQUOTARM to free space, delta(%lu)", after.f_bavail - before.f_bavail);
> else
> - tst_res(TFAIL, "Q_XQUOTARM doesn't have quota type check");
> + tst_res(TFAIL, "Q_XQUOTARM to free space, delta(-%lu)", before.f_bavail - after.f_bavail);
> +
> + TST_EXP_FAIL(do_quotactl(fd, QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, 0,
> + (void *)&invalid_type), EINVAL, "do_quotactl(Q_XQUOTARM, invalid_type)");
> }
>
> 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();
> +
> + /* ensure superblock has quota data, but not running */
> + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota");
> + mount_flag = 1;
> + SAFE_UMOUNT(MNTPOINT);
> + mount_flag = 0;
> + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "noquota");
> + mount_flag = 1;
Maybe just SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "remount, noquota") ?
If we can remount the device without umounting it the code would be a
bit shorter.
Anyways looks good to me:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-01-13 14:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 7:48 [LTP] [PATCH v6 1/3] syscalls/quotactl09: Test error when quota info hidden in filesystem Yang Xu
2022-01-12 7:48 ` [LTP] [PATCH v6 2/3] syscalls/quotactl07: Refactor this case Yang Xu
2022-01-13 14:03 ` Cyril Hrubis [this message]
2022-01-14 3:29 ` xuyang2018.jy
2022-01-12 7:48 ` [LTP] [PATCH v6 3/3] syscalls/quotactl: Make use of TST_EXP_PASS_SILENT and TST_EXP_FAIL Yang Xu
2022-01-13 14:45 ` Cyril Hrubis
2022-01-14 3:58 ` xuyang2018.jy
2022-01-12 9:18 ` [LTP] [PATCH v6 1/3] syscalls/quotactl09: Test error when quota info hidden in filesystem xuyang2018.jy
2022-01-12 9:46 ` Cyril Hrubis
2022-01-13 6:51 ` xuyang2018.jy
2022-01-13 9:49 ` Cyril Hrubis
2022-01-13 14:22 ` Cyril Hrubis
2022-01-14 2:27 ` xuyang2018.jy
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=YeAxK/IMvCIb0Sp7@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox