From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: test-misc: search the backup slot to use at runtime
Date: Tue, 12 Oct 2021 12:34:44 +0200 [thread overview]
Message-ID: <20211012103444.GX9286@twin.jikos.cz> (raw)
In-Reply-To: <c2919020-bbdd-be93-7293-a2270df45dfa@suse.com>
On Tue, Oct 12, 2021 at 06:19:44PM +0800, Qu Wenruo wrote:
> >> +slot_num=$(echo $found | cut -f1 -d:)
> >> +# To follow the dump-super output, where backup slot starts at 0.
> >> +slot_num=$(($slot_num - 1))
> >> +
> >> +# Save the backup slot info into the log
> >> +_log "Backup slot $slot_num will be utilized"
> >> +dump_super | grep -A9 "backup $slot_num:" >> "$RESULTS"
> >
> > Please don't use the $RESULTS in tests, it's an implementation detail
> > and there should always be helpers hiding, in this case it's run_check.
>
> In this particular case, won't run_check dump all the output into the log?
>
> As here we only want the grep result to be output, not the full dump_super.
Sorry, I was not specific, what I meant is:
"dump_super | run_check grep ..."
so only the result of grep ends up in the log.
> >> run_check "$INTERNAL_BIN/btrfs-corrupt-block" -m $main_root_ptr -f generation "$TEST_DEV"
> > ^^^^^^^^^^^^^^
> >
> > Please always quote variables (unless there's a reason not to like for
> > $SUDO_HELPER).
>
> Forgot it again, but it should be safe as $main_root_ptr should just be
> a u64 number.
>
> But yeah, I should quote it...
I know in this case it's clear there's a number, the point is
consistency of the whole testsuite, so one does not have to think if
this unquoted variable is ok or not. The initialization may happen in
other context or lines away or the variable name could be misleading.
IIRC I've seen some commands fail and instead of a single word in the
output there was the error message. Quoting makes it fail at least
somehow safely instead of letting the variable words be interpreted as
individual parameters.
next prev parent reply other threads:[~2021-10-12 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 8:37 [PATCH] btrfs-progs: test-misc: search the backup slot to use at runtime Qu Wenruo
2021-10-12 10:12 ` David Sterba
2021-10-12 10:19 ` Qu Wenruo
2021-10-12 10:34 ` David Sterba [this message]
2021-10-12 10:56 ` Qu Wenruo
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=20211012103444.GX9286@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox