From: Dave Chinner <david@fromorbit.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: fstests <fstests@vger.kernel.org>
Subject: Re: [PATCH 3/8] xfs/*: clean up _cleanup override
Date: Tue, 24 May 2022 22:27:03 +1000 [thread overview]
Message-ID: <20220524122703.GL2306852@dread.disaster.area> (raw)
In-Reply-To: <CAOQ4uxgZwngHevX_FXytAi68k=aqp_N-8Buk50rrJKD0UoK+2g@mail.gmail.com>
On Tue, May 24, 2022 at 01:42:15PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 12:41 PM Dave Chinner <david@fromorbit.com> wrote:
> >
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > Use a local cleanup function and _register_cleanup properly.
> >
> > Remove local cleanups that just do what the standard _cleanup and
> > test exist does.
> >
> > Remove local cleanups that just remove test files and then do
> > standard _cleanup functionality.
>
> As I mentioned in response to the cover letter, the call to _cleanup()
> can and I think should be chained implicitly, but I am still waiting
> for your response regarding the tests where generic _cleanup is not
> desired.
Please go an look at the lore archive if vger is having problems
delivering to you - the whole thread is there, as are all my
responses.
[PATCH 6/8] fstests: consolidate no cleanup test setup
https://lore.kernel.org/fstests/20220524073411.1943480-7-david@fromorbit.com/T/#u
> > diff --git a/tests/xfs/006 b/tests/xfs/006
> > index cecceaa3..fd8d8071 100755
> > --- a/tests/xfs/006
> > +++ b/tests/xfs/006
> > @@ -11,11 +11,10 @@
> > _begin_fstest auto quick mount eio
> >
> > # Override the default cleanup function.
> > -_cleanup()
> > +_dmerror_cleanup()
> > {
> > - cd /
> > - rm -f $tmp.*
> > _dmerror_cleanup
>
> That looks recursive.
> Again, if the call to _cleanup is implicitly chained then
> the local function is not needed and trap can call
> the global _dmerror_cleanup().
Yes, the local name should have been _dm_error_cleanup(), like I
used elsewhere.
> > diff --git a/tests/xfs/008 b/tests/xfs/008
> > index a53f6c92..5bef44bb 100755
> > --- a/tests/xfs/008
> > +++ b/tests/xfs/008
> > @@ -12,13 +12,6 @@ _begin_fstest rw ioctl auto quick
> > status=0 # success is the default!
> > pgsize=`$here/src/feature -s`
> >
> > -# Override the default cleanup function.
> > -_cleanup()
> > -{
> > - rm -f $tmp.*
> > - rm -rf $TEST_DIR/randholes.$$.*
>
> It's fine to keep the test files behind, but maybe
> make that change more clear in commit message
> because it was not clear to me that there was a change of
> behavior when I read the commit message.
>
> Sorry to drop this extra burden on you, but this seems
> important to me and I cannot add this information after the fact.
The point of TEST_DIR is it gathers cruft from tests so exercises
filesystem aging. If the file is tiny, there's no point in removing
it - all we have to do is ensure it is removed in the test setup so
we have known initial state. So If that's the case, I removed the
cleanup of it altogether.
Like I said, I have time to do a single classification pass across
all these tests, but if I have to document every single little
change I make in doing these cleanups, I'm not going to bother
trying because it's too hard and takes too long.
Do you want perfect commits or do you want better infrastructure?
> Also, it was very hard to see in this review if the test files
> that are not cleaned in cleanup() are cleaned in the beginning
> of the test or if it is not important to clean them because they
> are overwritten.
All tests are required to control their initial state on the test
device as many tests use the same file names and locations and there
is no guarantee that the test device is clean. Hence tests must
clean up during startup to ensure they have a known initial state
to begin the test from.
> I did my best to try and I think there is a missing cleanup of
> ${OUTPUT_DIR} in the beginning of xfs/253.
> Although that may already be considered a test bug, removing
> the cleanup of ${OUTPUT_DIR} from cleanup() will expose this bug.
OUTPUT_DIR="${SCRATCH_MNT}/test_${seq}"
No cleanup is needed for tests that use the scratch device.
> > diff --git a/tests/xfs/051 b/tests/xfs/051
> > index ea70cb50..4718099d 100755
> > --- a/tests/xfs/051
> > +++ b/tests/xfs/051
> > @@ -11,14 +11,13 @@
> > . ./common/preamble
> > _begin_fstest shutdown auto log metadata
> >
> > -# Override the default cleanup function.
> > -_cleanup()
> > +_fsstress_cleanup()
> > {
> > - cd /
> > - rm -f $tmp.*
> > $KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
> > - _scratch_unmount > /dev/null 2>&1
> > + wait
>
> All right. I see that cleanup helpers are not consistent
> in calling wait after kill and in using SIGKILL.
> I guess we could go either way. So be it.
That's the whole point of these cleanups - they will be collapsed
down to a single helper and then we can apply the same behaviour
consistently across them all.
> > diff --git a/tests/xfs/310 b/tests/xfs/310
> > index 3214e04b..c635b39a 100755
> > --- a/tests/xfs/310
> > +++ b/tests/xfs/310
> > @@ -9,14 +9,12 @@
> > . ./common/preamble
> > _begin_fstest auto clone rmap
> >
> > -# Override the default cleanup function.
> > -_cleanup()
> > +_dmhuge_cleanup()
> > {
> > - cd /
> > - umount $SCRATCH_MNT > /dev/null 2>&1
> > _dmhugedisk_cleanup
> > - rm -rf $tmp.*
> > + _cleanup
> > }
> > +_register_cleanup _dmhuge_cleanup
>
> Maybe it's just me, but if the intention is to maybe make this
> function global someday then the difference with the name
> _dmhugedisk_cleanup() is confusing.
The names I used here are for classification, so I can grep over
the _register_cleanup line and easily determine all the tests use
loop devices, dmflakey, dmerror, etc and then consolidate them all
into a single cleanup function that works for them all. This is just
the first step in that process.
> I'd rather keep the local function name local_cleanup
> in unclear cases like this one.
And that defeats the entire purpose of giving them a descriptive
name at this point in time.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2022-05-24 12:27 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
2022-05-24 7:34 ` [PATCH 1/8] generic/038: kill background threads on interrupt Dave Chinner
2022-05-24 9:41 ` Amir Goldstein
2022-05-24 12:10 ` Dave Chinner
2022-05-24 12:30 ` Amir Goldstein
2022-05-24 7:34 ` [PATCH 2/8] fstests: _cleanup overrides are messy Dave Chinner
2022-05-24 16:16 ` Amir Goldstein
2022-05-24 7:34 ` [PATCH 3/8] xfs/*: clean up _cleanup override Dave Chinner
2022-05-24 10:42 ` Amir Goldstein
2022-05-24 12:27 ` Dave Chinner [this message]
2022-05-24 12:55 ` Amir Goldstein
2022-05-24 13:24 ` Dave Chinner
2022-05-24 14:17 ` Amir Goldstein
2022-05-24 16:32 ` Zorro Lang
2022-05-24 23:34 ` Dave Chinner
2022-05-25 2:54 ` Amir Goldstein
2022-05-24 17:13 ` Zorro Lang
2022-05-26 15:04 ` Zorro Lang
2022-05-26 23:39 ` Dave Chinner
2022-05-24 7:34 ` [PATCH 4/8] fstests: define a common _dump_cleanup function Dave Chinner
2022-05-24 9:04 ` Amir Goldstein
2022-05-24 9:52 ` Dave Chinner
2022-05-24 9:59 ` Amir Goldstein
2022-05-24 7:34 ` [PATCH 5/8] fstests: use a common fsstress cleanup function Dave Chinner
2022-05-24 12:25 ` Amir Goldstein
2022-05-24 7:34 ` [PATCH 6/8] fstests: consolidate no cleanup test setup Dave Chinner
2022-05-24 12:22 ` Amir Goldstein
2022-05-24 13:07 ` Dave Chinner
2022-05-24 7:34 ` [PATCH 7/8] fstests: Set up BUS trap for tests by default Dave Chinner
2022-05-24 8:48 ` Amir Goldstein
2022-05-24 7:34 ` [PATCH 8/8] fstests: cleanup _cleanup usage in shared Dave Chinner
2022-05-24 10:49 ` Amir Goldstein
2022-05-24 11:11 ` Amir Goldstein
2022-05-24 8:29 ` [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Amir Goldstein
2022-05-24 9:57 ` Dave Chinner
2022-05-24 10:01 ` Amir Goldstein
2022-05-24 10:13 ` Dave Chinner
2022-05-24 12:14 ` Amir Goldstein
2022-05-24 12:28 ` Dave Chinner
2022-05-24 12:34 ` Amir Goldstein
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=20220524122703.GL2306852@dread.disaster.area \
--to=david@fromorbit.com \
--cc=amir73il@gmail.com \
--cc=fstests@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