From: Filipe Manana <fdmanana@kernel.org>
To: Anand Jain <anand.jain@oracle.com>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 05/10] common: add _filter_trailing_whitespace
Date: Tue, 2 Jan 2024 11:17:57 +0000 [thread overview]
Message-ID: <CAL3q7H5MyiJLgB5Pu5UxG9gNzTo0xJPKYSfqDAeLdVuEFOGTFQ@mail.gmail.com> (raw)
In-Reply-To: <0cf6e6a1-c347-4dd9-98cd-4a95f36c84eb@oracle.com>
On Tue, Jan 2, 2024 at 8:02 AM Anand Jain <anand.jain@oracle.com> wrote:
>
>
>
> On 12/29/23 20:57, Filipe Manana wrote:
> > On Fri, Dec 29, 2023 at 11:02 AM Anand Jain <anand.jain@oracle.com> wrote:
> >>
> >> The command 'btrfs inspect-internal dump-tree -t raid_stripe'
> >> introduces trailing whitespace in its output.
> >> Apply a filter to remove it. Used in btrfs/30[4-8][.out].
> >>
> >> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> >> ---
> >> common/filter | 5 +++++
> >> 1 file changed, 5 insertions(+)
> >>
> >> diff --git a/common/filter b/common/filter
> >> index 509ee95039ac..016d213b8bee 100644
> >> --- a/common/filter
> >> +++ b/common/filter
> >> @@ -651,5 +651,10 @@ _filter_bash()
> >> sed -e "s/^bash: line 1: /bash: /"
> >> }
> >>
> >> +_filter_trailing_whitespace()
> >> +{
> >> + sed -e "s/ $//"
> >> +}
> >
> > If we're having such a generic filter in common file, than I'd rather
> > have it delete any number of trailing white spaces, not just a single
> > one, and also account for tabs and other white spaces, so:
> >
> > sed -e "s/\s+$//"
> >
>
> I'll amend.
>
>
> > Also, since this is so specific to the raid stripe tree, I'd rather
> > have this filter included in the raid stripe tree filter introduced in
> > patch 2, _filter_stripe_tree(). That would make the tests shorter and
> > cleaner by avoiding piping yet over another filter that is used only
> > for the raid stripe tree dump...
>
> I kept this as a separate function so that it can be used elsewhere
> when needed. Doesn't that make sense?
Not so much if there's only one use case for it... specially if it's
such a trivial filter...
Even if we had multiple cases, doing this pattern in the tests:
$BTRFS_UTIL_PROG inspect-internal dump-tree (... ) |
_filter_trailing_whitespace | _filter_btrfs_version |
_filter_stripe_tree
Is ugly and verbose. The filtering could be done in
_filter_stripe_tree() by calling "_filter_triling_whitespace" there...
And mentioning that, we could also call _filter_btrfs_version there,
since it's always wanted and to make tests shorter and easier to read.
So in the end it would only be
$BTRFS_UTIL_PROG inspect-internal dump-tree (... ) | _filter_stripe_tree
With _filter_stripe_tree() as:
_filter_stripe_tree()
{
_filter_trailing_whitespace | _filter_btrfs_version | sed -E -e (....)
}
Or:
_filter_stripe_tree()
{
_filter_btrfs_version | sed -E -e "s/\s+$//" -e (...)
}
A lot more clean.
Thanks.
>
> Thanks, Anand
next prev parent reply other threads:[~2024-01-02 11:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
2023-12-29 11:01 ` [PATCH 05/10] common: add _filter_trailing_whitespace Anand Jain
2023-12-29 12:22 ` [PATCH v7 " Anand Jain
2023-12-29 12:29 ` [PATCH " Anand Jain
2023-12-29 12:53 ` Filipe Manana
2023-12-29 12:57 ` Filipe Manana
2024-01-02 8:01 ` Anand Jain
2024-01-02 11:17 ` Filipe Manana [this message]
2024-01-04 4:02 ` Anand Jain
2023-12-29 12:22 ` [PATCH v7 01/10] fstests: doc: add new raid-stripe-tree group Anand Jain
2023-12-29 12:22 ` [PATCH v7 02/10] common: add filter for btrfs raid-stripe dump Anand Jain
2023-12-29 12:22 ` [PATCH v7 03/10] common: add _require_btrfs_no_nodatacow helper Anand Jain
2023-12-29 12:22 ` [PATCH v7 04/10] common: add _require_btrfs_free_space_tree Anand Jain
2023-12-29 12:22 ` [PATCH v7 06/10] btrfs: add fstest for stripe-tree metadata with 4k write Anand Jain
2023-12-29 12:22 ` [PATCH v7 07/10] btrfs: add fstest for 8k write spanning two stripes on raid-stripe-tree Anand Jain
2023-12-29 12:22 ` [PATCH v7 08/10] btrfs: add fstest for writing to a file at an offset with RST Anand Jain
2023-12-29 12:22 ` [PATCH v7 09/10] btrfs: add fstests to write 128k to a RST filesystem Anand Jain
2023-12-29 12:22 ` [PATCH v7 10/10] btrfs: add fstest for overwriting a file partially with RST Anand Jain
2023-12-29 12:34 ` [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
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=CAL3q7H5MyiJLgB5Pu5UxG9gNzTo0xJPKYSfqDAeLdVuEFOGTFQ@mail.gmail.com \
--to=fdmanana@kernel.org \
--cc=anand.jain@oracle.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).