Re: [PATCH 05/13] fstests: move test group info to test files

Eric Biggers
2021-06-12T00:17:03Z

On Fri, Jun 11, 2021 at 04:29:30PM -0700, Eric Biggers wrote:
> On Tue, Jun 08, 2021 at 10:19:49AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Refactor every test in the entire test suite to use the new boilerplate
> > functions. This also migrates all the test group information into the
> > test files. This patch has been autogenerated via the command:
> >
> > ./tools/convert-group btrfs ceph cifs ext4 f2fs generic nfs ocfs2 overlay perf shared udf xfs
> >
> > NOTE: This patch submission only contains diffs of the first seven btrfs
> > tests because vger rejects 1.5MB patches. The full conversion is in the
> > git branch linked from the cover letter.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> [...]
> > diff --git a/tests/btrfs/006 b/tests/btrfs/006
> > index 67f1fcd8..c0f9541a 100755
> > --- a/tests/btrfs/006
> > +++ b/tests/btrfs/006
> > @@ -7,23 +7,17 @@
> > # run basic btrfs information commands in various ways
> > # sanity tests: filesystem show, label, sync, and device stats
> > #
> > -seq=`basename $0`
> > -seqres=$RESULT_DIR/$seq
> > -echo "== QA output created by $seq"
> > -
> > -here=`pwd`
> > -tmp=/tmp/$$
> > -status=1 # failure is the default!
> > -trap "_cleanup; exit \$status" 0 1 2 3 15
> > +. ./common/preamble
> > +_begin_fstest auto quick volume
> >
> > +# Override the default cleanup function.
> > _cleanup()
> > {
> > cd /
> > rm -f $tmp.*
> > }
>
> A lot of the _cleanup() functions (such as the one above) are identical to the
> one in common/preamble. It might make sense to make tools/convert-group
> recognize these and remove them.

The following command would remove most of them, including ones that omit the
"cd /" or use "rm -rf" instead of "rm -f":

sed -z -E -i 's/(#[^#\n]*\n)*_cleanup\(\)\n\{\n(\s+cd \/\n)?\s+rm -r?f "?\$tmp"?\.\*\n\}\n\n?//' tests/*/*

I'm not sure how far you want to go, though.

- Eric