All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Dave Chinner <david@fromorbit.com>
Cc: fstests <fstests@vger.kernel.org>
Subject: Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
Date: Tue, 24 May 2022 15:14:39 +0300	[thread overview]
Message-ID: <CAOQ4uxiZ3jQ7oBhAvgGexid8OT8Z223ynop7NdFGF9FRC-ueiA@mail.gmail.com> (raw)
In-Reply-To: <20220524101320.GJ2306852@dread.disaster.area>

On Tue, May 24, 2022 at 1:13 PM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 01:01:57PM +0300, Amir Goldstein wrote:
> > On Tue, May 24, 2022 at 12:57 PM Dave Chinner <david@fromorbit.com> wrote:
> > >
> > > On Tue, May 24, 2022 at 11:29:17AM +0300, Amir Goldstein wrote:
> > > > On Tue, May 24, 2022 at 11:01 AM Dave Chinner <david@fromorbit.com> wrote:
> > > > >
> > > > > Hi folks,
> > > > >
> > > > > I pulled on a string a couple of days ago, and it got out of
> > > > > control. It all started when I went to kill a test with ctrl-c and
> > > > > it, once again, left background processes running that I had to hunt
> > > > > down and kill manually.
> > > > >
> > > > > I then started looking a why this keeps happening, and realised that
> > > > > the way we clean up on test completion is messy, inconsistent and
> > > > > frequently buggy. So I started cleaning it all up, starting with the
> > > > > tests/xfs directory because I saw a lot of low hanging fruit there.
> > > > >
> > > > > Essentially, we use _cleanup() functions as a way of overriding the
> > > > > default trap handler we install in _begin_fstest(). Rather than
> > > > > register a new handler, we just redefine the common cleanup function
> > > > > and re-implement it (poorly) in every test that does an override.
> > > > > Often these overrides are completely unnecessary - I think I reduced
> > > > > the total number of overrides in tests/xfs by ~30% (~190 -> ~125),
> > > > > and I reudced the number of *unique overrides by a lot more than
> > > > > that.
> > > > >
> > > >
> > > > That looks like an awesome improvement!
> > > >
> > > > > The method for overriding changes to be "stacked cleanups" rather
> > > > > than "duplicated cleanups". That is, tests no longer open code:
> > > > >
> > > > >         cd /
> > > > >         rm -rf $tmp.*
> > > > >
> > > > > THis is what common/preamble::_cleanup() does. We should call that
> > > > > function to do this. Hence if we have a local cleanup that we need
> > > > > to do, it becomes:
> > > > >
> > > > > local_cleanup()
> > > > > {
> > > > >         rm -f $testfile
> > > > >         _cleanup
> > > > > }
> > > > > _register_cleanup local_cleanup
> > > >
> > > > While removing boilerplate code, we had better not create another boilerplate.
> > > > Instead of expecting test writers to always call _cleanup
> > > > if we always want _cleanup to be called we can always implicitly
> > > > chain it in _register_cleanup():
> > > >
> > > > --- a/common/preamble
> > > > +++ b/common/preamble
> > > > @@ -20,7 +20,7 @@ _register_cleanup()
> > > >         shift
> > > >
> > > >         test -n "$cleanup" && cleanup="${cleanup}; "
> > > > -       trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
> > > > +       trap "${cleanup}_cleanup; exit \$status" EXIT HUP INT QUIT TERM $*
> > > >  }
> > >
> > > I considered that, but then I found the _no_cleanup cases. IOWs,
> > > this doesn't work for the cases where we want to prevent the generic
> > > _cleanup function from being run on failure/test exit. Hence the
> > > cleanup function stacking behaviour rather than unconditional
> > > calling of _cleanup as per above.
> > >
> >
> > I didn't know about those.
> > Since you went to all this trouble to find them, can you provide a reference.
> > I wonder, what could ever be the reason not to want to rm $tmp.*?
>
> [PATCH 6/8] fstests: consolidate no cleanup test setup
>

Ah I see.
It might have been better to explicitly opt-out of cleanup
only for those tests via _register_no_cleanup or _unregister_cleanup

similar to the common _require_scratch and the exceptions of
_require_scratch_nocheck

But that could be done by followup cleanup and someone has
an itch to scratch ;)

Thanks,
Amir.

  reply	other threads:[~2022-05-24 12:14 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
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 [this message]
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=CAOQ4uxiZ3jQ7oBhAvgGexid8OT8Z223ynop7NdFGF9FRC-ueiA@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=david@fromorbit.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 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.