From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v1 02/11] syscalls/quotactl06???Also test with vfsv1 format
Date: Wed, 27 Oct 2021 02:50:56 +0000 [thread overview]
Message-ID: <6178BE94.8050108@fujitsu.com> (raw)
In-Reply-To: <YXgGiMSDSwVOhMfW@yuki>
Hi Cyril
> Hi!
>> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c
>> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
>> @@ -1,26 +1,42 @@
>> // SPDX-License-Identifier: GPL-2.0-or-later
>> /*
>> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
>> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
>> * Author: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> + */
>> +
>> +/*\
>> + * [Description]
>> + *
>> + * Tests basic error handling of the quotactl syscall with visible quota files
>> + * (cover two formats, vfsv0 and vfsv1):
>> *
>> - * Tests basic error handling of the quotactl syscall.
>> * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr
>> * existed but not a regular file.
>> + *
>> * 2) quotaclt fails with ENOENT when the file specified by special
>> * or addr does not exist.
>> + *
>> * 3) quotactl fails with EBUSTY when cmd is Q_QUOTAON and another
>> * Q_QUOTAON had already been performed.
>> + *
>> * 4) quotactl fails with EFAULT when addr or special is invalid.
>> + *
>> * 5) quotactl fails with EINVAL when cmd or type is invalid.
>> + *
>> * 6) quotactl fails with ENOTBLK when special is not a block device.
>> + *
>> * 7) quotactl fails with ESRCH when no disk quota is found for the
>> * indicated user and quotas have not been turned on for this fs.
>> + *
>> * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota
>> * format was not found.
>> + *
>> * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there
>> * is no ID greater than or equal to id that has an active quota.
>> + *
>> * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the
>> * specified limits are out of the range allowed by the quota format.
>> + *
>> * 11) quotactl fails with EPERM when the caller lacked the required
>> * privilege (CAP_SYS_ADMIN) for the specified operation.
>> */
>
> Same comments apply here as well.
Got it.
>> @@ -32,10 +48,7 @@
>> #include "tst_capability.h"
>>
>> #define OPTION_INVALID 999
>> -#define QFMT_VFS_V0 2
>> #define USRPATH MNTPOINT "/aquota.user"
>> -#define FMTID QFMT_VFS_V0
>> -
>> #define MNTPOINT "mntpoint"
>> #define TESTDIR1 MNTPOINT "/testdir1"
>> #define TESTDIR2 MNTPOINT "/testdir2"
>> @@ -43,10 +56,10 @@
>> static char usrpath[] = USRPATH;
>> static char testdir1[] = TESTDIR1;
>> static char testdir2[] = TESTDIR2;
>> -static int32_t fmt_id = FMTID;
>> +static int32_t fmt_id;
>> static int32_t fmt_invalid = 999;
>> static int test_invalid;
>> -static int test_id;
>> +static int test_id, mount_flag;
>> static int getnextquota_nsup;
>>
>> static struct if_nextdqblk res_ndq;
>> @@ -105,7 +118,7 @@ static void verify_quotactl(unsigned int n)
>>
>> if (tc->on_flag) {
>> TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev,
>> - FMTID, usrpath));
>> + fmt_id, usrpath));
>> if (TST_RET == -1)
>> tst_brk(TBROK,
>> "quotactl with Q_QUOTAON returned %ld", TST_RET);
>> @@ -135,7 +148,7 @@ static void verify_quotactl(unsigned int n)
>>
>> if (quota_on) {
>> TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev,
>> - FMTID, usrpath));
>> + fmt_id, usrpath));
>> if (TST_RET == -1)
>> tst_brk(TBROK,
>> "quotactl with Q_QUOTAOFF returned %ld", TST_RET);
>> @@ -150,10 +163,23 @@ static void verify_quotactl(unsigned int n)
>>
>> static void setup(void)
>> {
>> - const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
>> + const char *const vfsv0_cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
>> + const char *const vfsv1_cmd[] = {"quotacheck", "-uF", "vfsv1", MNTPOINT, NULL};
>
> If we are going to repeat this snippet in each test it may make sense to
> put it into a header as we do with variants:
>
> static struct quotactl_variant {
> int32_t fmt_id;
> const char *fmt_name;
> } variants[] = {
> {.fmt_id = QFMT_VFS_V0, .fmt_name = "vfsv0"}
> {.fmt_id = QFMT_VFS_V1, .fmt_name = "vfsv1"}
> };
>
> Then we can construct the rest easily from these as:
>
> const char *const cmd[] = {"quotacheck", "-uF", variants[variant].fmt_name, MNTPOINT, NULL};
>
> tst_res(TINFO, "quotactl() with %s format", variants[variant].fmt_name);
>
> SAFE_CMD(cmd, NULL, NULL);
> fmt_id = variants[variant].fmt_id;
Sounds great.
Best Regards
Yang Xu
>
>
>> unsigned int i;
>>
>> - SAFE_CMD(cmd, NULL, NULL);
>> + SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
>> + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota");
>> + mount_flag = 1;
>> +
>> + if (tst_variant) {
>> + tst_res(TINFO, "quotactl() with vfsv1 format");
>> + SAFE_CMD(vfsv1_cmd, NULL, NULL);
>> + fmt_id = QFMT_VFS_V1;
>> + } else {
>> + tst_res(TINFO, "quotactl() with vfsv0 format");
>> + SAFE_CMD(vfsv0_cmd, NULL, NULL);
>> + fmt_id = QFMT_VFS_V0;
>> + }
>>
>> if (access(USRPATH, F_OK) == -1)
>> tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
>> @@ -175,8 +201,15 @@ static void setup(void)
>> }
>> }
>>
>> +static void cleanup(void)
>> +{
>> + if (mount_flag&& tst_umount(MNTPOINT))
>> + tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
>> +}
>> +
>> static struct tst_test test = {
>> .setup = setup,
>> + .cleanup = cleanup,
>> .needs_kconfigs = (const char *[]) {
>> "CONFIG_QFMT_V2",
>> NULL
>> @@ -185,11 +218,11 @@ static struct tst_test test = {
>> .test = verify_quotactl,
>> .dev_fs_type = "ext4",
>> .mntpoint = MNTPOINT,
>> - .mount_device = 1,
>> - .mnt_data = "usrquota",
>> + .needs_device = 1,
>> .needs_cmds = (const char *const []) {
>> "quotacheck",
>> NULL
>> },
>> .needs_root = 1,
>> + .test_variants = 2,
>> };
>> --
>> 2.23.0
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2021-10-27 2:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 13:09 [LTP] [PATCH v1 01/11] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
2021-10-18 13:09 ` [LTP] [PATCH v1 02/11] syscalls/quotactl06:Also " Yang Xu
2021-10-20 8:51 ` xuyang2018.jy
2021-10-26 13:45 ` [LTP] [PATCH v1 02/11] syscalls/quotactl06???Also " Cyril Hrubis
2021-10-27 2:50 ` xuyang2018.jy [this message]
2021-10-18 13:09 ` [LTP] [PATCH v1 03/11] syscalls/quotactl04: Remove useless quotactl mount options Yang Xu
2021-10-26 14:03 ` Cyril Hrubis
2021-10-27 2:52 ` xuyang2018.jy
2021-10-18 13:09 ` [LTP] [PATCH v1 04/11] syscalls/quotactl[3, 5, 7]: Add docparse formatting Yang Xu
2021-10-26 14:05 ` Cyril Hrubis
2021-10-27 2:54 ` xuyang2018.jy
2021-10-18 13:09 ` [LTP] [PATCH v1 05/11] lapi/syscalls: Add syscall number for quotactl_fd Yang Xu
2021-10-26 14:09 ` Cyril Hrubis
2021-10-26 13:36 ` [LTP] [PATCH v1 01/11] syscalls/quotactl01: Also test with vfsv1 format Cyril Hrubis
2021-10-27 2:46 ` 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=6178BE94.8050108@fujitsu.com \
--to=xuyang2018.jy@fujitsu.com \
--cc=chrubis@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox