All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <guan@eryu.me>
To: Sidong Yang <realwakka@gmail.com>
Cc: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Qu Wenruo <wqu@suse.com>, Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH] btrfs/022: Add qgroup assign test
Date: Mon, 21 Sep 2020 01:27:40 +0800	[thread overview]
Message-ID: <20200920172740.GQ3853@desktop> (raw)
In-Reply-To: <20200920085753.277590-1-realwakka@gmail.com>

On Sun, Sep 20, 2020 at 08:57:53AM +0000, Sidong Yang wrote:
> The btrfs/022 test is basic test about qgroup. but it doesn't have
> test with qgroup assign function. This patch adds parent assign
> test. parent assign test make two subvolumes and a qgroup for assign.
> Assign two subvolumes with a qgroup and check that quota of group
> has same value with sum of two subvolumes.
> 
> Signed-off-by: Sidong Yang <realwakka@gmail.com>

We usually don't add new test case to existing tests, as that may make a
PASSed test starting to FAIL, which looks like a regression.

> ---
>  tests/btrfs/022 | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/tests/btrfs/022 b/tests/btrfs/022
> index aaa27aaa..cafaa8b2 100755
> --- a/tests/btrfs/022
> +++ b/tests/btrfs/022
> @@ -110,6 +110,40 @@ _limit_test_noexceed()
>  	[ $? -eq 0 ] || _fail "should have been allowed to write"
>  }
>  
> +#basic assign testing
> +_parent_assign_test()

Local function names don't need to be prefixed with "_".

> +{
> +	echo "=== parent assign test ===" >> $seqres.full
> +	_run_btrfs_util_prog subvolume create $SCRATCH_MNT/a

The helpers based on run_check are not recommended, please just
open-coded btrfs subvolume command and filter the output when necessary.
j
> +	_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +	subvolid_a=$(_btrfs_get_subvolid $SCRATCH_MNT a)
> +
> +	_run_btrfs_util_prog subvolume create $SCRATCH_MNT/b
> +	_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +	subvolid_b=$(_btrfs_get_subvolid $SCRATCH_MNT b)
> +
> +	_run_btrfs_util_prog qgroup create 1/100 $SCRATCH_MNT
> +
> +	_run_btrfs_util_prog qgroup assign 0/$subvolid_a 1/100 $SCRATCH_MNT
> +	_run_btrfs_util_prog qgroup assign 0/$subvolid_b 1/100 $SCRATCH_MNT
> +
> +	_ddt of=$SCRATCH_MNT/a/file bs=4M count=1 >> $seqres.full 2>&1
> +	_ddt of=$SCRATCH_MNT/b/file bs=4M count=1 >> $seqres.full 2>&1
> +	sync

Just fsync the individule files if possible.


> +
> +	a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid_a")
> +	a_shared=$(echo $a_shared | awk '{ print $2 }' | tr -dc '0-9')

$AWK_PROG

> +
> +	b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid_b")
> +	b_shared=$(echo $b_shared | awk '{ print $2 }' | tr -dc '0-9')
> +	sum=$(expr $b_shared  + $a_shared)
> +
> +	q_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "1/100")
> +	q_shared=$(echo $q_shared | awk '{ print $2 }' | tr -dc '0-9')
> +
> +	[ $sum -eq $q_shared ] || _fail "shared values don't match"

Print the actual number and expected number as well?

Thanks,
Eryu

> +}
> +
>  units=`_btrfs_qgroup_units`
>  
>  _scratch_mkfs > /dev/null 2>&1
> @@ -133,6 +167,12 @@ _check_scratch_fs
>  _scratch_mkfs > /dev/null 2>&1
>  _scratch_mount
>  _limit_test_noexceed
> +_scratch_unmount
> +_check_scratch_fs
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +_parent_assign_test
>  
>  # success, all done
>  echo "Silence is golden"
> -- 
> 2.25.1

  reply	other threads:[~2020-09-20 17:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-20  8:57 [PATCH] btrfs/022: Add qgroup assign test Sidong Yang
2020-09-20 17:27 ` Eryu Guan [this message]
2020-09-21  0:55   ` Sidong Yang
2020-09-21  1:21 ` Qu Wenruo
2020-09-21 15:16   ` Sidong Yang
2020-09-21 23:49     ` Qu Wenruo
2020-09-23  0:28       ` Sidong Yang

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=20200920172740.GQ3853@desktop \
    --to=guan@eryu.me \
    --cc=fstests@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=realwakka@gmail.com \
    --cc=wqu@suse.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 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.