All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
@ 2022-05-24  7:34 Dave Chinner
  2022-05-24  7:34 ` [PATCH 1/8] generic/038: kill background threads on interrupt Dave Chinner
                   ` (8 more replies)
  0 siblings, 9 replies; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

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.

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 this looks more verbose, it means we can actually reuse the
same cleanup function across lots of tests. 

A large number of xfsdump tests were all using the same override
cleanup function to call _cleanup_dump. These are all changed to:

. ./common/dump
_register_cleanup _cleanup_dump

and _cleanup_dump stacks like this:

_cleanup_dump()
{
	#do xfsdump cleanup stuff

	_cleanup
}

and we don't need to do anything else. There is one xfsdump test
that needs it's own cleanup. It stacks like this:

local_cleanup()
{
	rm -f $testfile
	_cleanup_dump
}
_register_cleanup local_cleanup

All the tests that run fsstress in the background now have a common
cleanup function that kills fsstress processes defined in
common/preamble. They just do:

_register_cleanup _cleanup_fsstress

And now every test that puts fsstress in the background behaves
correctly and kills all the background fsstree processes when
interrupted.

The conversion is by no means complete. I've named the local cleanup
functions by what they do so we can go back and derive commonality
between them. The number of different variations on tearing down
loops devices is crazy, and half of them are buggy. I haven't worked
through these yet, so you'll see lots of tests with:

_loop_cleanup()
{
	......
	_cleanup
}
_register_cleanup _loop_cleanup

That have similar but different ways of cleaning up loop devices.

I also added a _no_cleanup() function, as there are a large number
of xfs fuzzer tests that want to leave a warm corpse behind so that
debugging what just happened is easy.

I also added BUS to the default signal trap set - well over a 100
tests in tests/xfs had a line like:

_register_cleanup "_cleanup" BUS

just to add BUS signals to the set that would cause the cleanup
function to run. Just make it the default!

Overall, this significantly reduces the amount of boiler plate in
tests, and sets us down the path of common cleanup functions that
tests may not even need to define. e.g. just including
./common/dmflakey registers the _cleanup_dmflakey() trap that will
do all the necessary cleanup when the test exists. This makes the
tests simpler, more robust and reduces the maintenance burden of
over 1700 individual tests....

I won't put the full diffstat in this mail, but the benefits should
be clean from the summary:

360 files changed, 420 insertions(+), 1781 deletions(-)

I've lost count of the number of test bugs I killed in removing
all this code, and that's largely just in the tests/xfs directory.
So before I go spend another couple of days on converting the rest
of fstests, I figured I better make sure everyone is OK with these
changes.

Thoughts, comments?

-Dave.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/8] generic/038: kill background threads on interrupt
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
@ 2022-05-24  7:34 ` Dave Chinner
  2022-05-24  9:41   ` Amir Goldstein
  2022-05-24  7:34 ` [PATCH 2/8] fstests: _cleanup overrides are messy Dave Chinner
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

When I ctrl-c g/038, it either does nothing or it leaves processes
running in the background. It is not cleaning up it's background
processes correctly, so add kill vectors into the cleanup. Make sure
we only kill in the cleanup trap if the background processes are
running.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/generic/038 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tests/generic/038 b/tests/generic/038
index c6cea94e..0462ea13 100755
--- a/tests/generic/038
+++ b/tests/generic/038
@@ -36,6 +36,10 @@ _begin_fstest auto stress trim
 # Override the default cleanup function.
 _cleanup()
 {
+	[ -n "${create_pids}" ] && kill ${create_pids[@]}
+	[ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
+	[ -n "${trim_pids}" ] && kill ${trim_pids[@]}
+	wait
 	rm -fr $tmp
 }
 
@@ -47,6 +51,8 @@ _supported_fs generic
 _require_scratch
 _require_xfs_io_command "falloc"
 
+echo "Silence is golden"
+
 # Keep allocating and deallocating 1G of data space with the goal of creating
 # and deleting 1 block group constantly. The intention is to race with the
 # fstrim loop below.
@@ -121,6 +127,7 @@ _scratch_mount
 _require_fs_space $SCRATCH_MNT $((10 * 1024 * 1024))
 _require_batched_discard $SCRATCH_MNT
 
+
 for ((i = 0; i < $((4 * $LOAD_FACTOR)); i++)); do
 	trim_loop &
 	trim_pids[$i]=$!
@@ -136,12 +143,9 @@ create_files "foobar"
 kill ${fallocate_pids[@]}
 kill ${trim_pids[@]}
 wait
+unset create_pids
+unset fallocate_pids
+unset trim_pids
 
-# The fstests framework will now check for fs consistency with fsck.
-# The trimming was racy and caused some btree nodes to get full of zeroes on
-# disk, which obviously caused fs metadata corruption. The race often lead
-# to missing free space entries in a block group's free space cache too.
-
-echo "Silence is golden"
 status=0
 exit
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 2/8] fstests: _cleanup overrides are messy
  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  7:34 ` Dave Chinner
  2022-05-24 16:16   ` Amir Goldstein
  2022-05-24  7:34 ` [PATCH 3/8] xfs/*: clean up _cleanup override Dave Chinner
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Most _cleanup() function overrides look like:

_cleanup()
{
	# do something test specific
	cd /
	rm -rf $tmp.*
}

But they often get the last two lines either wrong or omit them.
These are the lines the common/preamble::_cleanup() define.

The problem here is that we are just overriding the generic _cleanup
function by redeclaring it after calling _begin_fstest. What we
should be doing is registering a new local cleanup function that
calls the generic cleanup function when we have finished the local
cleanup. i.e.:

_local_cleanup()
{
	# do something test specific

	_cleanup
}

Make _register_cleanup() function to cancel the existing
cleanup trap and register the new trap function so that local
cleanups can be done cleanly.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/preamble | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/preamble b/common/preamble
index e60cd949..7aa55dc6 100644
--- a/common/preamble
+++ b/common/preamble
@@ -4,7 +4,9 @@
 
 # Boilerplate fstests functionality
 
-# Standard cleanup function.  Individual tests can override this.
+# Standard cleanup function. If individual tests register their own cleanup
+# function, they need to call this from within their own cleanup function once
+# the test has finished cleaning up it's own state.
 _cleanup()
 {
 	cd /
@@ -19,6 +21,9 @@ _register_cleanup()
 	local cleanup="$1"
 	shift
 
+	# clear out existing traps first
+	trap - EXIT HUP INT QUIT TERM $*
+
 	test -n "$cleanup" && cleanup="${cleanup}; "
 	trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 3/8] xfs/*: clean up _cleanup override
  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  7:34 ` [PATCH 2/8] fstests: _cleanup overrides are messy Dave Chinner
@ 2022-05-24  7:34 ` Dave Chinner
  2022-05-24 10:42   ` Amir Goldstein
  2022-05-24  7:34 ` [PATCH 4/8] fstests: define a common _dump_cleanup function Dave Chinner
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

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.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/004     |  7 -------
 tests/xfs/006     |  7 ++++---
 tests/xfs/008     |  9 ++-------
 tests/xfs/009     |  7 -------
 tests/xfs/009.out |  1 -
 tests/xfs/010     |  8 --------
 tests/xfs/011     | 12 +++---------
 tests/xfs/012     | 10 ++--------
 tests/xfs/013     |  8 +++-----
 tests/xfs/014     |  8 +++-----
 tests/xfs/016     |  9 ---------
 tests/xfs/016.out |  1 -
 tests/xfs/017     |  7 -------
 tests/xfs/019     |  8 --------
 tests/xfs/019.out |  1 -
 tests/xfs/020     |  9 ++++-----
 tests/xfs/021     |  8 --------
 tests/xfs/021.out |  1 -
 tests/xfs/022     |  7 +++----
 tests/xfs/023     |  7 +++----
 tests/xfs/024     |  7 +++----
 tests/xfs/025     |  7 +++----
 tests/xfs/026     |  7 +++----
 tests/xfs/027     |  7 +++----
 tests/xfs/028     |  7 +++----
 tests/xfs/030     |  8 --------
 tests/xfs/033     |  8 --------
 tests/xfs/034     |  9 ---------
 tests/xfs/034.out |  1 -
 tests/xfs/035     |  6 +++---
 tests/xfs/036     |  7 +++----
 tests/xfs/037     |  7 +++----
 tests/xfs/038     |  7 +++----
 tests/xfs/039     |  7 +++----
 tests/xfs/041     |  8 --------
 tests/xfs/042     |  7 -------
 tests/xfs/043     |  7 +++----
 tests/xfs/046     |  7 +++----
 tests/xfs/047     |  7 +++----
 tests/xfs/049     | 21 +++++++++------------
 tests/xfs/050     |  8 --------
 tests/xfs/051     |  9 ++++-----
 tests/xfs/052     |  8 --------
 tests/xfs/055     |  7 +++----
 tests/xfs/056     |  7 +++----
 tests/xfs/057     | 16 ++++++++++------
 tests/xfs/059     |  7 +++----
 tests/xfs/060     |  7 +++----
 tests/xfs/061     |  7 +++----
 tests/xfs/063     |  7 +++----
 tests/xfs/064     |  7 +++----
 tests/xfs/065     |  7 +++----
 tests/xfs/066     |  9 ++++-----
 tests/xfs/068     |  7 +++----
 tests/xfs/070     |  7 +++----
 tests/xfs/071     |  8 --------
 tests/xfs/072     |  8 --------
 tests/xfs/073     | 11 +++++------
 tests/xfs/074     |  8 ++++----
 tests/xfs/076     |  8 --------
 tests/xfs/078     |  9 +++------
 tests/xfs/079     | 11 +++++------
 tests/xfs/080     |  7 -------
 tests/xfs/083     |  7 +++----
 tests/xfs/085     |  7 +++----
 tests/xfs/086     |  7 +++----
 tests/xfs/087     |  7 +++----
 tests/xfs/088     |  7 +++----
 tests/xfs/089     |  7 +++----
 tests/xfs/091     |  7 +++----
 tests/xfs/093     |  7 +++----
 tests/xfs/097     |  7 +++----
 tests/xfs/098     |  7 +++----
 tests/xfs/099     |  7 +++----
 tests/xfs/100     |  7 +++----
 tests/xfs/101     |  7 +++----
 tests/xfs/102     |  7 +++----
 tests/xfs/105     |  7 +++----
 tests/xfs/112     |  7 +++----
 tests/xfs/113     |  7 +++----
 tests/xfs/117     |  7 +++----
 tests/xfs/120     |  7 +++----
 tests/xfs/123     |  7 +++----
 tests/xfs/124     |  7 +++----
 tests/xfs/125     |  7 +++----
 tests/xfs/126     |  7 +++----
 tests/xfs/129     |  9 ++++-----
 tests/xfs/130     |  7 +++----
 tests/xfs/131     |  8 --------
 tests/xfs/139     |  7 -------
 tests/xfs/140     |  7 -------
 tests/xfs/141     | 11 +++++------
 tests/xfs/148     |  7 +++----
 tests/xfs/149     | 15 ++++++++-------
 tests/xfs/152     | 21 +++++++++------------
 tests/xfs/153     |  8 --------
 tests/xfs/157     |  8 ++++----
 tests/xfs/159     |  8 --------
 tests/xfs/167     |  9 +++++----
 tests/xfs/169     |  8 --------
 tests/xfs/177     |  6 +++---
 tests/xfs/181     | 10 ++++------
 tests/xfs/185     | 10 +++++-----
 tests/xfs/188     |  8 --------
 tests/xfs/189     |  8 +++-----
 tests/xfs/194     | 12 ------------
 tests/xfs/195     |  8 +-------
 tests/xfs/197     |  7 +------
 tests/xfs/199     |  7 -------
 tests/xfs/201     |  6 ------
 tests/xfs/206     | 12 ++++++------
 tests/xfs/220     |  7 -------
 tests/xfs/229     |  7 +------
 tests/xfs/231     |  7 +++----
 tests/xfs/232     |  7 +++----
 tests/xfs/234     |  9 ++++-----
 tests/xfs/236     |  8 --------
 tests/xfs/237     | 10 +++++-----
 tests/xfs/239     |  8 ++++----
 tests/xfs/240     | 10 +++++-----
 tests/xfs/241     |  8 ++++----
 tests/xfs/244     |  8 --------
 tests/xfs/250     |  6 +++---
 tests/xfs/253     |  9 ---------
 tests/xfs/259     |  8 +++++---
 tests/xfs/260     | 11 +----------
 tests/xfs/261     |  7 -------
 tests/xfs/264     |  7 +++----
 tests/xfs/265     |  8 --------
 tests/xfs/266     |  7 +++----
 tests/xfs/267     |  7 +++----
 tests/xfs/268     |  8 +++-----
 tests/xfs/269     |  7 -------
 tests/xfs/271     |  8 ++++----
 tests/xfs/272     |  8 ++++----
 tests/xfs/273     |  8 ++++----
 tests/xfs/274     |  8 ++++----
 tests/xfs/275     |  8 ++++----
 tests/xfs/276     |  8 ++++----
 tests/xfs/277     |  9 +++++----
 tests/xfs/279     |  9 ++++-----
 tests/xfs/281     |  7 +++----
 tests/xfs/282     |  7 +++----
 tests/xfs/283     |  7 +++----
 tests/xfs/284     | 10 ++++------
 tests/xfs/287     |  7 +++----
 tests/xfs/289     | 17 +++++++++--------
 tests/xfs/296     |  9 ++++-----
 tests/xfs/299     |  8 --------
 tests/xfs/301     |  9 ++++-----
 tests/xfs/302     |  9 ++++-----
 tests/xfs/309     |  8 --------
 tests/xfs/310     |  8 +++-----
 tests/xfs/311     | 10 ++++------
 tests/xfs/312     |  8 --------
 tests/xfs/313     |  8 --------
 tests/xfs/314     |  8 --------
 tests/xfs/315     |  8 --------
 tests/xfs/316     |  8 --------
 tests/xfs/317     |  8 --------
 tests/xfs/318     |  8 --------
 tests/xfs/319     |  8 --------
 tests/xfs/320     |  8 --------
 tests/xfs/321     |  8 --------
 tests/xfs/322     |  8 --------
 tests/xfs/323     |  8 --------
 tests/xfs/324     |  8 --------
 tests/xfs/325     |  8 --------
 tests/xfs/326     |  8 --------
 tests/xfs/327     |  8 --------
 tests/xfs/336     |  7 -------
 tests/xfs/432     |  8 ++++----
 tests/xfs/438     | 16 ++++++++++------
 tests/xfs/442     | 10 +++++-----
 tests/xfs/447     |  7 +++----
 tests/xfs/501     |  7 +++----
 tests/xfs/503     | 10 ++++------
 tests/xfs/507     | 13 +++++--------
 tests/xfs/511     |  8 --------
 tests/xfs/512     |  8 +-------
 tests/xfs/513     | 15 +++++----------
 tests/xfs/514     | 10 ++++------
 tests/xfs/515     | 10 ++++------
 tests/xfs/516     |  7 -------
 tests/xfs/517     |  9 +++------
 tests/xfs/520     |  8 --------
 tests/xfs/521     |  8 ++++----
 tests/xfs/522     |  7 -------
 tests/xfs/523     |  7 -------
 tests/xfs/524     |  8 ++++----
 tests/xfs/525     |  7 -------
 tests/xfs/526     |  7 -------
 tests/xfs/528     |  6 +++---
 tests/xfs/530     |  6 +++---
 tests/xfs/542     |  7 ++++---
 tests/xfs/543     |  7 -------
 tests/xfs/544     | 11 ++++++++---
 197 files changed, 477 insertions(+), 1106 deletions(-)

diff --git a/tests/xfs/004 b/tests/xfs/004
index f18316b3..f8cfeb6a 100755
--- a/tests/xfs/004
+++ b/tests/xfs/004
@@ -11,13 +11,6 @@ _begin_fstest db auto quick
 
 status=0
 
-# Override the default cleanup function.
-_cleanup()
-{
-	_scratch_unmount
-	rm -f $tmp.*
-}
-
 _populate_scratch()
 {
 	echo "=== mkfs output ===" >>$seqres.full
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
+	_cleanup
 }
 
 # Import common functions.
@@ -28,6 +27,8 @@ _require_scratch
 _require_dm_target error
 _require_fs_sysfs error/fail_at_unmount
 
+_register_cleanup _dmerror_cleanup
+
 _scratch_mkfs > $seqres.full 2>&1
 _dmerror_init
 _dmerror_mount
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.$$.*
-}
-
 _filter()
 {
     sed -e "s/-b $pgsize/-b PGSIZE/g" \
@@ -68,6 +61,8 @@ _do_test()
 _supported_fs xfs
 _require_test
 
+rm -rf $TEST_DIR/randholes.$$.*
+
 # Note on special numbers here.
 #
 # We are trying to create roughly 50 or 100 holes in a file
diff --git a/tests/xfs/009 b/tests/xfs/009
index 54270243..186ba5b3 100755
--- a/tests/xfs/009
+++ b/tests/xfs/009
@@ -9,13 +9,6 @@
 . ./common/preamble
 _begin_fstest rw ioctl auto prealloc quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-    echo "*** unmount"
-    _scratch_unmount
-}
-
 _init()
 {
     echo "*** mkfs"
diff --git a/tests/xfs/009.out b/tests/xfs/009.out
index 02b5d82a..596c686f 100644
--- a/tests/xfs/009.out
+++ b/tests/xfs/009.out
@@ -111,4 +111,3 @@ filesize = 500
         [ofs,count]: start..end
         [0,1000]: BLOCKRANGE
 filesize = 500
-*** unmount
diff --git a/tests/xfs/010 b/tests/xfs/010
index 16c08b85..bdca950c 100755
--- a/tests/xfs/010
+++ b/tests/xfs/010
@@ -15,14 +15,6 @@ _begin_fstest auto quick repair
 . ./common/filter
 . ./common/repair
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 _sparse_inode_populate()
 {
 	dir=$1
diff --git a/tests/xfs/011 b/tests/xfs/011
index d6e9099e..161f263c 100755
--- a/tests/xfs/011
+++ b/tests/xfs/011
@@ -11,17 +11,13 @@
 . ./common/preamble
 _begin_fstest auto freeze log metadata quick
 
-# Import common functions.
-
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
 	$KILLALL_PROG -9 fsstress 2>/dev/null
 	wait
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _fsstress_cleanup
 
 # Use the information exported by XFS to sysfs to determine whether the log has
 # active reservations after a filesystem freeze.
@@ -85,7 +81,5 @@ done
 $KILLALL_PROG $FSSTRESS_PROG
 wait
 
-_scratch_unmount
-
 status=0
 exit
diff --git a/tests/xfs/012 b/tests/xfs/012
index 5ebc9058..c5569f6d 100755
--- a/tests/xfs/012
+++ b/tests/xfs/012
@@ -11,14 +11,6 @@ _begin_fstest rw auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    rm -rf $TEST_DIR/holes.$$.*
-}
-
 _filesize()
 {
     ls -l $1 | $AWK_PROG '{print "    filesize = " $5}'
@@ -85,6 +77,8 @@ _do_test()
 _supported_fs xfs
 _require_test
 
+rm -rf $TEST_DIR/holes.$$.*
+
 # small & fairly dense
 _do_test 1 "-l 40960000 -b 40960 -i 10 -c 1" 100
 
diff --git a/tests/xfs/013 b/tests/xfs/013
index 2d005753..c451ded3 100755
--- a/tests/xfs/013
+++ b/tests/xfs/013
@@ -16,15 +16,13 @@ _begin_fstest auto metadata stress
 # Import common functions.
 . ./common/filter
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
 	$KILLALL_PROG -9 fsstress 2>/dev/null
 	wait
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _fsstress_cleanup
 
 filter_enospc() {
 	sed -e '/^.*No space left on device.*/d'
diff --git a/tests/xfs/014 b/tests/xfs/014
index 1f0ebac3..1e099df6 100755
--- a/tests/xfs/014
+++ b/tests/xfs/014
@@ -18,14 +18,12 @@ _begin_fstest auto enospc quick quota
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	umount $LOOP_MNT 2>/dev/null
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Create a file using a repeated open, extending write and close pattern. This
 # causes the preallocation to persist after the file is closed. Preallocation
diff --git a/tests/xfs/016 b/tests/xfs/016
index 6337bb1f..04c7ce95 100755
--- a/tests/xfs/016
+++ b/tests/xfs/016
@@ -22,15 +22,6 @@
 . ./common/preamble
 _begin_fstest rw auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    echo "*** unmount"
-    _scratch_unmount 2>/dev/null
-}
-
 _block_filter()
 {
     sed -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g'
diff --git a/tests/xfs/016.out b/tests/xfs/016.out
index f4c8f88d..7c2bd144 100644
--- a/tests/xfs/016.out
+++ b/tests/xfs/016.out
@@ -117,4 +117,3 @@ Wrote 51200.00Kb (value 0xc6)
    *** fiddle
    *** unmount
 *** check for corruption
-*** unmount
diff --git a/tests/xfs/017 b/tests/xfs/017
index 8a20e592..14e29b98 100755
--- a/tests/xfs/017
+++ b/tests/xfs/017
@@ -11,13 +11,6 @@ _begin_fstest mount auto quick stress
 
 _register_cleanup "_cleanup; rm -f $tmp.*"
 
-# Override the default cleanup function.
-_cleanup()
-{
-    echo "*** unmount"
-    _scratch_unmount 2>/dev/null
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/019 b/tests/xfs/019
index 790a6821..9aa02f22 100755
--- a/tests/xfs/019
+++ b/tests/xfs/019
@@ -14,14 +14,6 @@ rm -f $seqfull
 # Import common functions.
 . ./common/filter
 
-# Override the default cleanup function.
-_cleanup()
-{
-    echo "*** unmount"
-    _scratch_unmount 2>/dev/null
-    rm -f $tmp.*
-}
-
 _full()
 {
     echo ""            >>$seqfull
diff --git a/tests/xfs/019.out b/tests/xfs/019.out
index 9db157f9..65a0d8b2 100644
--- a/tests/xfs/019.out
+++ b/tests/xfs/019.out
@@ -90,4 +90,3 @@ Device: <DEVICE> Inode: <INODE> Links: 1
 Device: <DEVICE> Inode: <INODE> Links: 1 
 *** unmount FS
 *** done
-*** unmount
diff --git a/tests/xfs/020 b/tests/xfs/020
index d6ee3a15..6e2deb6b 100755
--- a/tests/xfs/020
+++ b/tests/xfs/020
@@ -12,13 +12,12 @@
 . ./common/preamble
 _begin_fstest auto repair
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    rm -f $tmp.*
-    rm -f $fsfile
+	rm -f $fsfile
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/021 b/tests/xfs/021
index 9432e2ac..eed7fa49 100755
--- a/tests/xfs/021
+++ b/tests/xfs/021
@@ -14,14 +14,6 @@ status=0	# success is the default!
 . ./common/filter
 . ./common/attr
 
-# Override the default cleanup function.
-_cleanup()
-{
-	echo "*** unmount"
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 _attr()
 {
 	${ATTR_PROG} $* 2>$tmp.err >$tmp.out
diff --git a/tests/xfs/021.out b/tests/xfs/021.out
index aea4a605..3b9d6e87 100644
--- a/tests/xfs/021.out
+++ b/tests/xfs/021.out
@@ -54,4 +54,3 @@ nvlist[2].namelen = 7
 nvlist[2].name = "a2-----"
 nvlist[2].value = "value_2\d"
 *** done
-*** unmount
diff --git a/tests/xfs/022 b/tests/xfs/022
index 2f011b28..e9310365 100755
--- a/tests/xfs/022
+++ b/tests/xfs/022
@@ -15,13 +15,12 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 . ./common/dump
 
diff --git a/tests/xfs/023 b/tests/xfs/023
index f6f6503a..1019831d 100755
--- a/tests/xfs/023
+++ b/tests/xfs/023
@@ -13,13 +13,12 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/024 b/tests/xfs/024
index 83a8882c..dcb6b9fc 100755
--- a/tests/xfs/024
+++ b/tests/xfs/024
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/025 b/tests/xfs/025
index bafe82d7..dd3c8588 100755
--- a/tests/xfs/025
+++ b/tests/xfs/025
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/026 b/tests/xfs/026
index fba385dc..18529003 100755
--- a/tests/xfs/026
+++ b/tests/xfs/026
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/027 b/tests/xfs/027
index 16cd203d..df6ee2ac 100755
--- a/tests/xfs/027
+++ b/tests/xfs/027
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/028 b/tests/xfs/028
index 1ff9d7d2..d0518317 100755
--- a/tests/xfs/028
+++ b/tests/xfs/028
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/030 b/tests/xfs/030
index 201a9015..617a34e3 100755
--- a/tests/xfs/030
+++ b/tests/xfs/030
@@ -10,14 +10,6 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest repair auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/repair
diff --git a/tests/xfs/033 b/tests/xfs/033
index d47da0d6..06c4c100 100755
--- a/tests/xfs/033
+++ b/tests/xfs/033
@@ -10,14 +10,6 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest repair auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    _scratch_unmount 2>/dev/null
-    rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/repair
diff --git a/tests/xfs/034 b/tests/xfs/034
index 52b0a5f7..5625631c 100755
--- a/tests/xfs/034
+++ b/tests/xfs/034
@@ -9,15 +9,6 @@
 . ./common/preamble
 _begin_fstest other auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    echo "*** unmount"
-    _scratch_unmount 2>/dev/null
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/034.out b/tests/xfs/034.out
index b307447d..040d3b97 100644
--- a/tests/xfs/034.out
+++ b/tests/xfs/034.out
@@ -2,4 +2,3 @@ QA output created by 034
 *** init FS
 *** test
 *** done
-*** unmount
diff --git a/tests/xfs/035 b/tests/xfs/035
index f100bb18..6461884b 100755
--- a/tests/xfs/035
+++ b/tests/xfs/035
@@ -11,12 +11,12 @@ seqfull=$0
 _begin_fstest dump ioctl tape auto
 
 # Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/036 b/tests/xfs/036
index 73eb7cd5..becbc83c 100755
--- a/tests/xfs/036
+++ b/tests/xfs/036
@@ -10,13 +10,12 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/037 b/tests/xfs/037
index b19ba9e9..0cbd0b16 100755
--- a/tests/xfs/037
+++ b/tests/xfs/037
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/038 b/tests/xfs/038
index 397c354d..da5507af 100755
--- a/tests/xfs/038
+++ b/tests/xfs/038
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/039 b/tests/xfs/039
index d54e9975..69a1092d 100755
--- a/tests/xfs/039
+++ b/tests/xfs/039
@@ -10,13 +10,12 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/041 b/tests/xfs/041
index 05de5578..8e584643 100755
--- a/tests/xfs/041
+++ b/tests/xfs/041
@@ -12,14 +12,6 @@ set +x
 . ./common/preamble
 _begin_fstest growfs ioctl auto
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    _scratch_unmount
-    rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/042 b/tests/xfs/042
index d62eb045..8af43671 100755
--- a/tests/xfs/042
+++ b/tests/xfs/042
@@ -13,13 +13,6 @@ set +x
 . ./common/preamble
 _begin_fstest fsr ioctl auto
 
-# Override the default cleanup function.
-_cleanup()
-{
-    _scratch_unmount
-    rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/043 b/tests/xfs/043
index 415ed16e..7ce74539 100755
--- a/tests/xfs/043
+++ b/tests/xfs/043
@@ -12,13 +12,12 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/046 b/tests/xfs/046
index 48daff87..3ac4a180 100755
--- a/tests/xfs/046
+++ b/tests/xfs/046
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/047 b/tests/xfs/047
index 6d0dc5f7..c2f66e31 100755
--- a/tests/xfs/047
+++ b/tests/xfs/047
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/049 b/tests/xfs/049
index 69656a85..fec99386 100755
--- a/tests/xfs/049
+++ b/tests/xfs/049
@@ -9,20 +9,17 @@
 . ./common/preamble
 _begin_fstest rw auto quick
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    umount $SCRATCH_MNT/test2 > /dev/null 2>&1
-    umount $SCRATCH_MNT/test > /dev/null 2>&1
-    rm -f $tmp.*
-
-    if [ -w $seqres.full ]
-    then
-        echo "--- mounts at end (after cleanup)" >> $seqres.full
-        mount >> $seqres.full
-    fi
+	umount $SCRATCH_MNT/test2 > /dev/null 2>&1
+	umount $SCRATCH_MNT/test > /dev/null 2>&1
+	if [ -w $seqres.full ]; then
+		echo "--- mounts at end (after cleanup)" >> $seqres.full
+		mount >> $seqres.full
+	fi
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/050 b/tests/xfs/050
index 2220e470..a020543a 100755
--- a/tests/xfs/050
+++ b/tests/xfs/050
@@ -14,14 +14,6 @@ _begin_fstest quota auto quick
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # real QA test starts here
 _supported_fs xfs
 
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
+	_cleanup
 }
+_register_cleanup fsstress_cleanup
 
 # Import common functions.
 . ./common/dmflakey
diff --git a/tests/xfs/052 b/tests/xfs/052
index 75761022..c8409574 100755
--- a/tests/xfs/052
+++ b/tests/xfs/052
@@ -16,14 +16,6 @@ _begin_fstest quota db auto quick
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # real QA test starts here
 _supported_fs xfs
 
diff --git a/tests/xfs/055 b/tests/xfs/055
index c6ecae3d..d663bfab 100755
--- a/tests/xfs/055
+++ b/tests/xfs/055
@@ -10,13 +10,12 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/056 b/tests/xfs/056
index f742f419..7a4b2423 100755
--- a/tests/xfs/056
+++ b/tests/xfs/056
@@ -12,13 +12,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/057 b/tests/xfs/057
index 9fb3f406..983479ab 100755
--- a/tests/xfs/057
+++ b/tests/xfs/057
@@ -23,16 +23,20 @@
 . ./common/preamble
 _begin_fstest auto log recoveryloop
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
+{
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
+}
+
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	$KILLALL_PROG -9 fsstress > /dev/null 2>&1
 	[ -e /sys/fs/xfs/$sdev/errortag/log_item_pin ] &&
 		echo 0 > /sys/fs/xfs/$sdev/errortag/log_item_pin
-	wait > /dev/null 2>&1
+	_fsstress_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/inject
diff --git a/tests/xfs/059 b/tests/xfs/059
index 515ef2a4..9428a9da 100755
--- a/tests/xfs/059
+++ b/tests/xfs/059
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/060 b/tests/xfs/060
index 0c0dc981..b5939f67 100755
--- a/tests/xfs/060
+++ b/tests/xfs/060
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/061 b/tests/xfs/061
index 0b20cc30..dcaac20c 100755
--- a/tests/xfs/061
+++ b/tests/xfs/061
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/063 b/tests/xfs/063
index 660b300f..9193745a 100755
--- a/tests/xfs/063
+++ b/tests/xfs/063
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump attr auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/064 b/tests/xfs/064
index a81b226b..e332daee 100755
--- a/tests/xfs/064
+++ b/tests/xfs/064
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump auto
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/065 b/tests/xfs/065
index 8485dee6..9b31ff34 100755
--- a/tests/xfs/065
+++ b/tests/xfs/065
@@ -12,13 +12,12 @@
 . ./common/preamble
 _begin_fstest dump auto
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/066 b/tests/xfs/066
index 2c369ad7..22eb10cc 100755
--- a/tests/xfs/066
+++ b/tests/xfs/066
@@ -13,13 +13,12 @@ _begin_fstest dump ioctl auto quick
 . ./common/filter
 . ./common/dump
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
-    _cleanup_dump
-    cd /
-    rm -f $tmp.*
+	_cleanup_dump
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/068 b/tests/xfs/068
index f80b53e5..ed281881 100755
--- a/tests/xfs/068
+++ b/tests/xfs/068
@@ -16,13 +16,12 @@ _begin_fstest auto stress dump
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 . ./common/dump
 
diff --git a/tests/xfs/070 b/tests/xfs/070
index 43ca7f84..b9839597 100755
--- a/tests/xfs/070
+++ b/tests/xfs/070
@@ -21,14 +21,13 @@
 . ./common/preamble
 _begin_fstest auto quick repair
 
-# Override the default cleanup function.
-_cleanup()
+_xfs_repair_cleanup()
 {
-	cd /
-	rm -f $tmp.*
 	$KILLALL_PROG -9 $XFS_REPAIR_PROG > /dev/null 2>&1
 	wait > /dev/null 2>&1
+	_cleanup
 }
+_register_cleanup _xfs_repair_cleanup
 
 # Start and monitor an xfs_repair of the scratch device. This test can induce a
 # time consuming brute force superblock scan. Since a brute force scan means
diff --git a/tests/xfs/071 b/tests/xfs/071
index 8373878a..b43deb75 100755
--- a/tests/xfs/071
+++ b/tests/xfs/071
@@ -9,14 +9,6 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest rw auto
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    _scratch_unmount 2>/dev/null
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/072 b/tests/xfs/072
index 54c1207c..196c4df1 100755
--- a/tests/xfs/072
+++ b/tests/xfs/072
@@ -9,14 +9,6 @@
 . ./common/preamble
 _begin_fstest rw auto prealloc quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.*
-	_scratch_unmount 2>/dev/null
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/073 b/tests/xfs/073
index c7616b9e..f44687c4 100755
--- a/tests/xfs/073
+++ b/tests/xfs/073
@@ -16,17 +16,16 @@ _begin_fstest copy auto
 # don't put fs images in /tmp
 imgs=$TEST_DIR/$$
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
 	_scratch_unmount 2>/dev/null
 	umount $imgs.loop 2>/dev/null
-	[ -d $imgs.loop ] && rmdir $imgs.loop
 	umount $imgs.source_dir 2>/dev/null
-	[ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
-	rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
+	rm -rf $imgs.* /var/tmp/xfs_copy.log.*
+
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 _filter_copy()
 {
diff --git a/tests/xfs/074 b/tests/xfs/074
index f27700ee..cf8dd244 100755
--- a/tests/xfs/074
+++ b/tests/xfs/074
@@ -22,13 +22,13 @@
 . ./common/preamble
 _begin_fstest quick auto prealloc rw
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	_destroy_loop_device $LOOP_DEV
-	rm -f $tmp.* $LOOP_FILE
+	rm -f $LOOP_FILE
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/076 b/tests/xfs/076
index 8eef1367..09fea1d6 100755
--- a/tests/xfs/076
+++ b/tests/xfs/076
@@ -23,14 +23,6 @@ _begin_fstest auto enospc punch
 # Import common functions.
 . ./common/filter
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 _consume_freesp()
 {
 	file=$1
diff --git a/tests/xfs/078 b/tests/xfs/078
index 1f475c96..dbd9af5b 100755
--- a/tests/xfs/078
+++ b/tests/xfs/078
@@ -9,19 +9,16 @@
 . ./common/preamble
 _begin_fstest growfs auto quick
 
-_register_cleanup "_cleanup; rm -f $tmp.*"
-
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
-	rm -f $tmp.*
 	$UMOUNT_PROG $LOOP_MNT 2>/dev/null
 	[ -n "$LOOP_DEV" ] && _destroy_loop_device $LOOP_DEV 2>/dev/null
 	# try to keep the image file if test fails
 	[ $status -eq 0 ] && rm -f $LOOP_IMG
 	rmdir $LOOP_MNT
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/079 b/tests/xfs/079
index dd5dbd35..fc30181b 100755
--- a/tests/xfs/079
+++ b/tests/xfs/079
@@ -17,14 +17,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log quick
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	$KILLALL_PROG -9 fsstress > /dev/null 2>&1
-	wait > /dev/null 2>&1
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
 }
+_register_cleanup fsstress_cleanup
 
 # Import common functions.
 . ./common/log
diff --git a/tests/xfs/080 b/tests/xfs/080
index 20b20a08..3cf5f7ff 100755
--- a/tests/xfs/080
+++ b/tests/xfs/080
@@ -12,13 +12,6 @@ _begin_fstest rw ioctl
 # Import common functions.
 . ./common/filter
 
-# Override the default cleanup function.
-_cleanup()
-{ 
-    cd /
-    rm -f $tmp.*
-}
-
 _supported_fs xfs
 _require_test
 
diff --git a/tests/xfs/083 b/tests/xfs/083
index a9acc9f5..7666d204 100755
--- a/tests/xfs/083
+++ b/tests/xfs/083
@@ -11,12 +11,11 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers punch
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/085 b/tests/xfs/085
index dc82f28d..8aa8f2a0 100755
--- a/tests/xfs/085
+++ b/tests/xfs/085
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/086 b/tests/xfs/086
index c8c6d86e..031cb445 100755
--- a/tests/xfs/086
+++ b/tests/xfs/086
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/087 b/tests/xfs/087
index f7cae328..9d1f59f0 100755
--- a/tests/xfs/087
+++ b/tests/xfs/087
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/088 b/tests/xfs/088
index 156c6669..de824223 100755
--- a/tests/xfs/088
+++ b/tests/xfs/088
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/089 b/tests/xfs/089
index ae8f6564..dae2d0d0 100755
--- a/tests/xfs/089
+++ b/tests/xfs/089
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/091 b/tests/xfs/091
index 85c881ae..c5db3337 100755
--- a/tests/xfs/091
+++ b/tests/xfs/091
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/093 b/tests/xfs/093
index 04b09e85..9fe1799a 100755
--- a/tests/xfs/093
+++ b/tests/xfs/093
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/097 b/tests/xfs/097
index 4cad7216..d66df458 100755
--- a/tests/xfs/097
+++ b/tests/xfs/097
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/098 b/tests/xfs/098
index 1e60271f..21215ee5 100755
--- a/tests/xfs/098
+++ b/tests/xfs/098
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/099 b/tests/xfs/099
index a7eaff6e..2791e2df 100755
--- a/tests/xfs/099
+++ b/tests/xfs/099
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/100 b/tests/xfs/100
index 79da8cb0..e71e760e 100755
--- a/tests/xfs/100
+++ b/tests/xfs/100
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/101 b/tests/xfs/101
index 64f4705a..1cbcc973 100755
--- a/tests/xfs/101
+++ b/tests/xfs/101
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/102 b/tests/xfs/102
index 24dce430..0ce3588a 100755
--- a/tests/xfs/102
+++ b/tests/xfs/102
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/105 b/tests/xfs/105
index 22a8bf9f..8a583da5 100755
--- a/tests/xfs/105
+++ b/tests/xfs/105
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/112 b/tests/xfs/112
index bc1ab628..4362f31c 100755
--- a/tests/xfs/112
+++ b/tests/xfs/112
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/113 b/tests/xfs/113
index e820ed96..e3f4fd4d 100755
--- a/tests/xfs/113
+++ b/tests/xfs/113
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/117 b/tests/xfs/117
index e4195d9b..4962c201 100755
--- a/tests/xfs/117
+++ b/tests/xfs/117
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/120 b/tests/xfs/120
index 0a4d72a0..653948ee 100755
--- a/tests/xfs/120
+++ b/tests/xfs/120
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/123 b/tests/xfs/123
index 81f39b96..e191623a 100755
--- a/tests/xfs/123
+++ b/tests/xfs/123
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/124 b/tests/xfs/124
index 39307218..af738212 100755
--- a/tests/xfs/124
+++ b/tests/xfs/124
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/125 b/tests/xfs/125
index fb5f5695..a7280e2c 100755
--- a/tests/xfs/125
+++ b/tests/xfs/125
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/126 b/tests/xfs/126
index c3a74b1c..55a12178 100755
--- a/tests/xfs/126
+++ b/tests/xfs/126
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/129 b/tests/xfs/129
index 90887d54..ea284049 100755
--- a/tests/xfs/129
+++ b/tests/xfs/129
@@ -11,13 +11,12 @@
 . ./common/preamble
 _begin_fstest auto quick clone metadump
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    _scratch_unmount > /dev/null 2>&1
-    rm -rf $tmp.* $testdir $metadump_file $TEST_DIR/image
+	rm -rf $testdir $metadump_file $TEST_DIR/image
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/130 b/tests/xfs/130
index 9465cbb0..e7a0e6e3 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -10,12 +10,11 @@
 . ./common/preamble
 _begin_fstest fuzzers clone
 
-# Override the default cleanup function.
-_cleanup()
+_no_cleanup()
 {
-    cd /
-    #rm -f $tmp.*
+	cd /
 }
+_register_cleanup _no_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/131 b/tests/xfs/131
index 879e2dc6..57848564 100755
--- a/tests/xfs/131
+++ b/tests/xfs/131
@@ -9,14 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone realtime
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    umount $SCRATCH_MNT > /dev/null 2>&1
-    rm -rf $tmp.* $testdir $metadump_file
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/139 b/tests/xfs/139
index 118930a5..96dce077 100755
--- a/tests/xfs/139
+++ b/tests/xfs/139
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -rf $tmp.* $testdir
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/140 b/tests/xfs/140
index ba7694c3..5b51f540 100755
--- a/tests/xfs/140
+++ b/tests/xfs/140
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -rf $tmp.* $testdir
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/141 b/tests/xfs/141
index d9b2474d..0b0cac81 100755
--- a/tests/xfs/141
+++ b/tests/xfs/141
@@ -14,14 +14,13 @@
 . ./common/preamble
 _begin_fstest auto log metadata
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	$KILLALL_PROG -9 fsstress > /dev/null 2>&1
-	wait > /dev/null 2>&1
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
 }
+_register_cleanup fsstress_cleanup
 
 # Import common functions.
 . ./common/inject
diff --git a/tests/xfs/148 b/tests/xfs/148
index 5d0a0bf4..ce829e20 100755
--- a/tests/xfs/148
+++ b/tests/xfs/148
@@ -10,14 +10,13 @@
 . ./common/preamble
 _begin_fstest auto quick fuzzers
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	$UMOUNT_PROG $mntpt > /dev/null 2>&1
 	_destroy_loop_device $loopdev > /dev/null 2>&1
-	rm -r -f $tmp.*
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/149 b/tests/xfs/149
index 503eff65..82ff6093 100755
--- a/tests/xfs/149
+++ b/tests/xfs/149
@@ -19,15 +19,16 @@ loopfile=$TEST_DIR/fsfile
 mntdir=$TEST_DIR/mntdir
 loop_symlink=$TEST_DIR/loop_symlink.$$
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-    $UMOUNT_PROG $mntdir
-    [ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
-    rmdir $mntdir
-    rm -f $loop_symlink
-    rm -f $loopfile
+	$UMOUNT_PROG $mntdir
+	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
+	rmdir $mntdir
+	rm -f $loop_symlink
+	rm -f $loopfile
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/152 b/tests/xfs/152
index dd33801d..bb136d7c 100755
--- a/tests/xfs/152
+++ b/tests/xfs/152
@@ -13,19 +13,12 @@
 . ./common/preamble
 _begin_fstest auto quick quota idmapped
 
-wipe_mounts()
+_idmapped_cleanup()
 {
 	umount "${SCRATCH_MNT}/idmapped" >/dev/null 2>&1
-	_scratch_unmount >/dev/null 2>&1
-}
-
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	wipe_mounts
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _idmapped_cleanup
 
 # Import common functions.
 . ./common/filter
@@ -232,6 +225,12 @@ test_restore()
 			$SCRATCH_MNT | _filter_scratch
 }
 
+wipe_mounts()
+{
+	umount "${SCRATCH_MNT}/idmapped" >/dev/null 2>&1
+	_scratch_unmount >/dev/null 2>&1
+}
+
 wipe_scratch()
 {
 	wipe_mounts
@@ -367,8 +366,6 @@ idmapped=1
 qmount_idmapped
 test_xfs_quota "gquota,sync"
 
-wipe_mounts
-
 # success, all done
 status=0
 exit
diff --git a/tests/xfs/153 b/tests/xfs/153
index dbe26b68..bb9295c0 100755
--- a/tests/xfs/153
+++ b/tests/xfs/153
@@ -16,14 +16,6 @@ _begin_fstest auto quick quota idmapped
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # real QA test starts here
 _supported_fs xfs
 
diff --git a/tests/xfs/157 b/tests/xfs/157
index 8222d7ee..17b162f3 100755
--- a/tests/xfs/157
+++ b/tests/xfs/157
@@ -20,12 +20,12 @@
 . ./common/preamble
 _begin_fstest auto quick admin
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.* $fake_logfile $fake_rtfile $fake_datafile
+	rm -f $fake_logfile $fake_rtfile $fake_datafile
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/159 b/tests/xfs/159
index eaee590e..709baa2e 100755
--- a/tests/xfs/159
+++ b/tests/xfs/159
@@ -11,14 +11,6 @@
 . ./common/preamble
 _begin_fstest auto quick bigtime
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-}
-
-# Import common functions.
-
 # real QA test starts here
 _supported_fs xfs
 _require_scratch
diff --git a/tests/xfs/167 b/tests/xfs/167
index 5f985010..50d3c41b 100755
--- a/tests/xfs/167
+++ b/tests/xfs/167
@@ -9,12 +9,13 @@
 . ./common/preamble
 _begin_fstest rw metadata auto stress
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
-	$KILLALL_PROG -r -q -TERM fsstress 2> /dev/null
-	wait	# ensures all fsstress processes died
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
 }
+_register_cleanup fsstress_cleanup
 
 workout()
 {
diff --git a/tests/xfs/169 b/tests/xfs/169
index 7ea5af99..84ad7db4 100755
--- a/tests/xfs/169
+++ b/tests/xfs/169
@@ -11,14 +11,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    umount $SCRATCH_MNT > /dev/null 2>&1
-    rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/177 b/tests/xfs/177
index 10891550..0179e37a 100755
--- a/tests/xfs/177
+++ b/tests/xfs/177
@@ -25,12 +25,12 @@
 . ./common/preamble
 _begin_fstest auto ioctl
 
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -r -f $tmp.*
 	test -n "$old_centisecs" && echo "$old_centisecs" > "$xfs_centisecs_file"
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/181 b/tests/xfs/181
index a399ae5a..b6f9760b 100755
--- a/tests/xfs/181
+++ b/tests/xfs/181
@@ -13,12 +13,12 @@
 . ./common/preamble
 _begin_fstest shutdown log auto quick
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    rm -f $tmp.*
-    [ -n "$pid" ] && kill $pid
+	[ -n "$pid" ] && kill $pid
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 pid=""
 
@@ -29,8 +29,6 @@ pid=""
 # real QA test starts here
 _supported_fs xfs
 
-rm -f $tmp.log
-
 _require_scratch
 
 echo "mkfs"
diff --git a/tests/xfs/185 b/tests/xfs/185
index f0e87642..d46bd4bf 100755
--- a/tests/xfs/185
+++ b/tests/xfs/185
@@ -18,17 +18,17 @@
 . ./common/preamble
 _begin_fstest auto fsmap
 
-_cleanup()
+_loop_cleanup()
 {
-	cd /
-	rm -r -f $tmp.*
 	_scratch_unmount
 	test -n "$ddloop" && _destroy_loop_device "$ddloop"
 	test -n "$rtloop" && _destroy_loop_device "$rtloop"
-	test -n "$ddfile" && rm -f "$ddfile"
-	test -n "$rtfile" && rm -f "$rtfile"
+	rm -f "$ddfile"
+	rm -f "$rtfile"
 	test -n "$old_use_external" && USE_EXTERNAL="$old_use_external"
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/188 b/tests/xfs/188
index d40e4123..3111d41b 100755
--- a/tests/xfs/188
+++ b/tests/xfs/188
@@ -18,14 +18,6 @@ _begin_fstest ci dir auto
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    rm -rf $SCRATCH_MNT/$seq
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/189 b/tests/xfs/189
index e601881a..82c94145 100755
--- a/tests/xfs/189
+++ b/tests/xfs/189
@@ -38,14 +38,12 @@ _begin_fstest mount auto quick
 
 tag="added by qa $seq"
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	_scratch_unmount 2>/dev/null
 	_putback_scratch_fstab
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 _scratch_filter()
 {
diff --git a/tests/xfs/194 b/tests/xfs/194
index 5a1dff5d..15739c87 100755
--- a/tests/xfs/194
+++ b/tests/xfs/194
@@ -9,18 +9,6 @@
 . ./common/preamble
 _begin_fstest rw auto
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    # Unmount the V4 filesystem we forcibly created to run this test so that
-    # the post-test wrapup checks won't try to remount the filesystem with
-    # different MOUNT_OPTIONS (specifically, the ones that get screened out by
-    # _force_xfsv4_mount_options) and fail.
-    _scratch_unmount
-    rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/195 b/tests/xfs/195
index 3e388142..65d68b47 100755
--- a/tests/xfs/195
+++ b/tests/xfs/195
@@ -11,13 +11,6 @@
 . ./common/preamble
 _begin_fstest ioctl dump auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	rm -rf $TEST_DIR/d
-	rm -f $TEST_DIR/dumpfile
-}
-
 #
 # Perform a level 0 dump that respects the chattr dump exclude flag,
 # and grep the output for the inode number we expect / do not expect
@@ -46,6 +39,7 @@ _require_user
 _require_command "$XFSDUMP_PROG" xfsdump
 
 echo "Preparing subtree"
+rm -rf $TEST_DIR/d
 mkdir $TEST_DIR/d
 touch $TEST_DIR/d/t
 inum=`stat -c "%i" $TEST_DIR/d/t`
diff --git a/tests/xfs/197 b/tests/xfs/197
index 109bf478..9e5c63d3 100755
--- a/tests/xfs/197
+++ b/tests/xfs/197
@@ -15,12 +15,6 @@
 . ./common/preamble
 _begin_fstest dir auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	rm -rf $TEST_DIR/ttt
-}
-
 # Import common functions.
 . ./common/filter
 
@@ -33,6 +27,7 @@ if [ "$bitsperlong" -ne 32 ]; then
 	_notrun "This test is only valid on 32 bit machines"
 fi
 
+rm -rf $TEST_DIR/ttt
 mkdir $TEST_DIR/ttt
 for n in {1..168}; do
     touch $TEST_DIR/ttt/$n;
diff --git a/tests/xfs/199 b/tests/xfs/199
index 4669f2c3..0485a904 100755
--- a/tests/xfs/199
+++ b/tests/xfs/199
@@ -12,13 +12,6 @@
 . ./common/preamble
 _begin_fstest mount auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount >/dev/null 2>&1
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/201 b/tests/xfs/201
index b9f2aab1..101134e8 100755
--- a/tests/xfs/201
+++ b/tests/xfs/201
@@ -12,12 +12,6 @@
 . ./common/preamble
 _begin_fstest metadata auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	_scratch_unmount
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/206 b/tests/xfs/206
index cb346b6d..71f07be8 100755
--- a/tests/xfs/206
+++ b/tests/xfs/206
@@ -15,14 +15,14 @@
 . ./common/preamble
 _begin_fstest growfs auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-    umount $tmpdir
-    rmdir $tmpdir
-    rm -f $tmp
-    rm -f $tmpfile
+	umount $tmpdir
+	rm -f $tmpfile
+	rmdir $tmpdir
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/220 b/tests/xfs/220
index 88eedf51..9b6c3d0b 100755
--- a/tests/xfs/220
+++ b/tests/xfs/220
@@ -12,13 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quota quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount >/dev/null 2>&1
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/quota
diff --git a/tests/xfs/229 b/tests/xfs/229
index 2221b9c4..a6ce97f1 100755
--- a/tests/xfs/229
+++ b/tests/xfs/229
@@ -15,12 +15,6 @@
 . ./common/preamble
 _begin_fstest auto rw
 
-# Override the default cleanup function.
-_cleanup()
-{
-    rm -rf ${TDIR}
-}
-
 # Import common functions.
 
 # real QA test starts here
@@ -34,6 +28,7 @@ EXTSIZE="256k"
 _xfs_force_bdev data $TEST_DIR
 
 # Create the test directory
+rm -rf ${TDIR}
 mkdir ${TDIR}
 
 # Set the test directory extsize
diff --git a/tests/xfs/231 b/tests/xfs/231
index 8155d0ab..179131ea 100755
--- a/tests/xfs/231
+++ b/tests/xfs/231
@@ -14,14 +14,13 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
 	test -n "$old_cowgc_interval" && \
 		_xfs_set_cowgc_interval $old_cowgc_interval
-	rm -rf $tmp.*
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/232 b/tests/xfs/232
index 06217466..a96502a7 100755
--- a/tests/xfs/232
+++ b/tests/xfs/232
@@ -15,14 +15,13 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
 	test -n "$old_cowgc_interval" && \
 		_xfs_set_cowgc_interval $old_cowgc_interval
-	rm -rf $tmp.*
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/234 b/tests/xfs/234
index 6ff2f228..f1c3222e 100755
--- a/tests/xfs/234
+++ b/tests/xfs/234
@@ -11,13 +11,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap punch metadump
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    _scratch_unmount > /dev/null 2>&1
-    rm -rf $tmp.* $metadump_file $TEST_DIR/image
+	rm -f $metadump_file $TEST_DIR/image
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/236 b/tests/xfs/236
index a66ea2d5..4d23b500 100755
--- a/tests/xfs/236
+++ b/tests/xfs/236
@@ -11,14 +11,6 @@
 . ./common/preamble
 _begin_fstest auto rmap punch
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    umount $SCRATCH_MNT > /dev/null 2>&1
-    rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/237 b/tests/xfs/237
index 34d54a6c..46d72d08 100755
--- a/tests/xfs/237
+++ b/tests/xfs/237
@@ -9,13 +9,13 @@
 . ./common/preamble
 _begin_fstest auto quick clone eio
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    rm -rf $tmp.* $TEST_DIR/moo
-    _dmerror_cleanup
+	rm -rf $TEST_DIR/moo
+	_dmerror_cleanup
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/239 b/tests/xfs/239
index 5143cc2e..bead5d51 100755
--- a/tests/xfs/239
+++ b/tests/xfs/239
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    rm -rf $tmp.* $TEST_DIR/moo
+	rm -rf $TEST_DIR/moo
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/240 b/tests/xfs/240
index e5d35a83..94b1a36d 100755
--- a/tests/xfs/240
+++ b/tests/xfs/240
@@ -9,13 +9,13 @@
 . ./common/preamble
 _begin_fstest auto quick clone eio
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    rm -rf $tmp.* $TEST_DIR/moo
-    _dmerror_cleanup
+	rm -rf $TEST_DIR/moo
+	_dmerror_cleanup
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/241 b/tests/xfs/241
index 7988c2d8..17e41618 100755
--- a/tests/xfs/241
+++ b/tests/xfs/241
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    cd /
-    rm -rf $tmp.* $TEST_DIR/moo
+	rm -rf $TEST_DIR/moo
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/244 b/tests/xfs/244
index 28f1328a..f33f6ecd 100755
--- a/tests/xfs/244
+++ b/tests/xfs/244
@@ -13,14 +13,6 @@ _begin_fstest auto quota quick
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # real QA test starts here
 _supported_fs xfs
 _require_xfs_quota
diff --git a/tests/xfs/250 b/tests/xfs/250
index 8af32711..2575959e 100755
--- a/tests/xfs/250
+++ b/tests/xfs/250
@@ -9,14 +9,14 @@
 . ./common/preamble
 _begin_fstest auto quick rw prealloc metadata
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	umount $LOOP_MNT 2>/dev/null
 	rm -f $LOOP_DEV
 	rmdir $LOOP_MNT
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/253 b/tests/xfs/253
index 1899ce52..884d8a4b 100755
--- a/tests/xfs/253
+++ b/tests/xfs/253
@@ -20,15 +20,6 @@
 . ./common/preamble
 _begin_fstest auto quick metadump
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-    rm -rf "${OUTPUT_DIR}"
-    rm -f "${METADUMP_FILE}"
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/259 b/tests/xfs/259
index 88e2f3ee..bdb6a492 100755
--- a/tests/xfs/259
+++ b/tests/xfs/259
@@ -9,11 +9,13 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-    rm -f "$testfile"
+	losetup -d $lofile 2> /dev/null
+	rm -f "$testfile"
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/260 b/tests/xfs/260
index a780365f..a03520d8 100755
--- a/tests/xfs/260
+++ b/tests/xfs/260
@@ -14,22 +14,13 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.*
-	rm -f $localfile
-}
-
-# Import common functions.
-
 echo 'Silence is golden'
 
 _supported_fs xfs
 _require_test
 
 localfile=$TEST_DIR/$seq.$$
+rm -f $localfile
 
 $XFS_IO_PROG -f -c "truncate 10444800" $localfile
 
diff --git a/tests/xfs/261 b/tests/xfs/261
index eb8a72cd..58d942a9 100755
--- a/tests/xfs/261
+++ b/tests/xfs/261
@@ -17,13 +17,6 @@ my_mtab=${tmp}.mtab
 
 mtab=/proc/self/mounts
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    rm -f ${tmp}.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/quota
diff --git a/tests/xfs/264 b/tests/xfs/264
index 191f57d5..6529cd8f 100755
--- a/tests/xfs/264
+++ b/tests/xfs/264
@@ -10,13 +10,12 @@
 . ./common/preamble
 _begin_fstest auto quick mount eio
 
-# Override the default cleanup function.
-_cleanup()
+_dm_error_cleanup()
 {
-	cd /
-	rm -f $tmp.*
 	_dmerror_cleanup
+	_cleanup
 }
+_register_cleanup _dm_error_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/265 b/tests/xfs/265
index c0edb6d2..9ec03844 100755
--- a/tests/xfs/265
+++ b/tests/xfs/265
@@ -12,14 +12,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-    cd /
-    umount $SCRATCH_MNT > /dev/null 2>&1
-    rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/266 b/tests/xfs/266
index eeca8822..1a57f644 100755
--- a/tests/xfs/266
+++ b/tests/xfs/266
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl auto quick
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 #
 # Add a new file and append a subset of the fill'ed files
diff --git a/tests/xfs/267 b/tests/xfs/267
index 89b968be..19e1f030 100755
--- a/tests/xfs/267
+++ b/tests/xfs/267
@@ -11,13 +11,12 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 #
 # create a 40 MiB file with an extended attr.
diff --git a/tests/xfs/268 b/tests/xfs/268
index 8c991fba..fd668856 100755
--- a/tests/xfs/268
+++ b/tests/xfs/268
@@ -13,15 +13,13 @@ _begin_fstest dump ioctl tape
 
 status=0	# success is the default!
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
-#
 # create two 12 MiB files with extended attrs.
 # xfsdump writes file data in "extent groups", currently 16 MiB in size. After
 # writing an extent group or finishing a file, xfsdump will start a new media
diff --git a/tests/xfs/269 b/tests/xfs/269
index c1477373..d467d08d 100755
--- a/tests/xfs/269
+++ b/tests/xfs/269
@@ -9,13 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick ioctl
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/attr
diff --git a/tests/xfs/271 b/tests/xfs/271
index 14d64cd0..34c40795 100755
--- a/tests/xfs/271
+++ b/tests/xfs/271
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
+	rm -f $TEST_DIR/fsmap $TEST_DIR/testout
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/272 b/tests/xfs/272
index 7ed8b951..43a9ce1b 100755
--- a/tests/xfs/272
+++ b/tests/xfs/272
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
+	rm -f $TEST_DIR/fsmap $TEST_DIR/bmap
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/273 b/tests/xfs/273
index a22e9d47..7f6adbb4 100755
--- a/tests/xfs/273
+++ b/tests/xfs/273
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/a $TEST_DIR/b
+	rm -f $TEST_DIR/a $TEST_DIR/b
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/274 b/tests/xfs/274
index dcaea688..0d1f2d04 100755
--- a/tests/xfs/274
+++ b/tests/xfs/274
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
+	rm -f $TEST_DIR/fsmap $TEST_DIR/bmap
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/275 b/tests/xfs/275
index d22e21e9..f4c22f9e 100755
--- a/tests/xfs/275
+++ b/tests/xfs/275
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
+	rm -f $TEST_DIR/fsmap $TEST_DIR/testout
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/276 b/tests/xfs/276
index 8cc48675..487a3a42 100755
--- a/tests/xfs/276
+++ b/tests/xfs/276
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap realtime
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
+	rm -f $TEST_DIR/fsmap $TEST_DIR/bmap
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/277 b/tests/xfs/277
index 03208ef2..dc2ecd74 100755
--- a/tests/xfs/277
+++ b/tests/xfs/277
@@ -9,12 +9,13 @@
 . ./common/preamble
 _begin_fstest auto quick rmap fsmap
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
+	rm -f $TEST_DIR/fsmap $TEST_DIR/testout
+	_cleanup
 }
+_register_cleanup local_cleanup
+
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/279 b/tests/xfs/279
index 835d187f..09f1a59e 100755
--- a/tests/xfs/279
+++ b/tests/xfs/279
@@ -10,13 +10,12 @@
 . ./common/preamble
 _begin_fstest auto mkfs
 
-# Override the default cleanup function.
-_cleanup()
+_scsi_debug_cleanup()
 {
-    cd /
-    rm -f $tmp.*
-    _put_scsi_debug_dev
+	_put_scsi_debug_dev
+	_cleanup
 }
+_register_cleanup _scsi_debug_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/281 b/tests/xfs/281
index 6b148a94..eba8e39c 100755
--- a/tests/xfs/281
+++ b/tests/xfs/281
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/282 b/tests/xfs/282
index 50303b08..53c7dc49 100755
--- a/tests/xfs/282
+++ b/tests/xfs/282
@@ -11,13 +11,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/283 b/tests/xfs/283
index 59ea5f3b..6d377615 100755
--- a/tests/xfs/283
+++ b/tests/xfs/283
@@ -11,13 +11,12 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/dump
diff --git a/tests/xfs/284 b/tests/xfs/284
index fa7bfdd0..69906f90 100755
--- a/tests/xfs/284
+++ b/tests/xfs/284
@@ -10,14 +10,12 @@
 . ./common/preamble
 _begin_fstest auto quick dump copy db mkfs repair metadump
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	rm -f $METADUMP_FILE 2>/dev/null
-	rm -f $COPY_FILE 2>/dev/null
+	rm -f $METADUMP_FILE $COPY_FILE
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/287 b/tests/xfs/287
index 31bbf0d7..fea453f5 100755
--- a/tests/xfs/287
+++ b/tests/xfs/287
@@ -14,13 +14,12 @@ _begin_fstest auto dump quota quick
 . ./common/quota
 . ./common/dump
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -rf $tmp.*
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 _print_projid()
 {
diff --git a/tests/xfs/289 b/tests/xfs/289
index c722deff..adc6d4db 100755
--- a/tests/xfs/289
+++ b/tests/xfs/289
@@ -10,16 +10,17 @@
 . ./common/preamble
 _begin_fstest growfs auto quick
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-    $UMOUNT_PROG $tmpdir
-    $UMOUNT_PROG $tmpbind
-    rmdir $tmpdir
-    rm -f $tmpsymlink
-    rmdir $tmpbind
-    rm -f $tmpfile
+	$UMOUNT_PROG $tmpdir
+	$UMOUNT_PROG $tmpbind
+	rmdir $tmpdir
+	rm -f $tmpsymlink
+	rmdir $tmpbind
+	rm -f $tmpfile
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/296 b/tests/xfs/296
index efd303e2..96268cee 100755
--- a/tests/xfs/296
+++ b/tests/xfs/296
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest dump auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
-    _cleanup_dump
-    cd /
-    rm -f $tmp.*
+	_cleanup_dump
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/299 b/tests/xfs/299
index 4b9df3c6..9846aef1 100755
--- a/tests/xfs/299
+++ b/tests/xfs/299
@@ -15,14 +15,6 @@ _begin_fstest auto quota
 . ./common/filter
 . ./common/quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount 2>/dev/null
-	rm -f $tmp.*
-}
-
 # real QA test starts here
 _supported_fs xfs
 
diff --git a/tests/xfs/301 b/tests/xfs/301
index 71ec1420..12e8bc1a 100755
--- a/tests/xfs/301
+++ b/tests/xfs/301
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest auto dump
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
-    _cleanup_dump
-    cd /
-    rm -f $tmp.*
+	_cleanup_dump
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/302 b/tests/xfs/302
index 2e16890c..14907273 100755
--- a/tests/xfs/302
+++ b/tests/xfs/302
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest auto dump
 
-# Override the default cleanup function.
-_cleanup()
+_dump_cleanup()
 {
-    _cleanup_dump
-    cd /
-    rm -f $tmp.*
+	_cleanup_dump
+	_cleanup
 }
+_register_cleanup _dump_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/309 b/tests/xfs/309
index 3e909509..f6a2ef20 100755
--- a/tests/xfs/309
+++ b/tests/xfs/309
@@ -12,14 +12,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
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
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/311 b/tests/xfs/311
index d5e3afbf..92d521d0 100755
--- a/tests/xfs/311
+++ b/tests/xfs/311
@@ -13,14 +13,12 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-# Override the default cleanup function.
-_cleanup()
+_dmdelay_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	_scratch_unmount > /dev/null 2>&1
-	_cleanup_delay > /dev/null 2>&1
+	_cleanup_delay
+	_cleanup
 }
+_register_cleanup _dmdelay_cleanup
 
 # Import common functions.
 . ./common/dmdelay
diff --git a/tests/xfs/312 b/tests/xfs/312
index 94f868fe..8a1dff27 100755
--- a/tests/xfs/312
+++ b/tests/xfs/312
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/313 b/tests/xfs/313
index 9c7cf5b9..6501a090 100755
--- a/tests/xfs/313
+++ b/tests/xfs/313
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/314 b/tests/xfs/314
index 9ac311d0..ae0df258 100755
--- a/tests/xfs/314
+++ b/tests/xfs/314
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/315 b/tests/xfs/315
index 105515ab..154e9770 100755
--- a/tests/xfs/315
+++ b/tests/xfs/315
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/316 b/tests/xfs/316
index f0af19d2..2b07346b 100755
--- a/tests/xfs/316
+++ b/tests/xfs/316
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/317 b/tests/xfs/317
index 1ca2672d..49434170 100755
--- a/tests/xfs/317
+++ b/tests/xfs/317
@@ -9,14 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick rmap
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/inject
diff --git a/tests/xfs/318 b/tests/xfs/318
index 38c7aa60..c673d680 100755
--- a/tests/xfs/318
+++ b/tests/xfs/318
@@ -9,14 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick rw
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/inject
diff --git a/tests/xfs/319 b/tests/xfs/319
index d64651fb..97bfeeae 100755
--- a/tests/xfs/319
+++ b/tests/xfs/319
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/320 b/tests/xfs/320
index d22d76d9..2a4303cb 100755
--- a/tests/xfs/320
+++ b/tests/xfs/320
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/321 b/tests/xfs/321
index 06a34347..eb824ca6 100755
--- a/tests/xfs/321
+++ b/tests/xfs/321
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/322 b/tests/xfs/322
index 89a2f741..ca0a39e6 100755
--- a/tests/xfs/322
+++ b/tests/xfs/322
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/323 b/tests/xfs/323
index 66737da0..3c535535 100755
--- a/tests/xfs/323
+++ b/tests/xfs/323
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/324 b/tests/xfs/324
index 9909db62..c753a170 100755
--- a/tests/xfs/324
+++ b/tests/xfs/324
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/325 b/tests/xfs/325
index 5b26b2b3..4046d908 100755
--- a/tests/xfs/325
+++ b/tests/xfs/325
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/326 b/tests/xfs/326
index 8b95a18a..df8c1738 100755
--- a/tests/xfs/326
+++ b/tests/xfs/326
@@ -12,14 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/327 b/tests/xfs/327
index 25855f77..285b6b49 100755
--- a/tests/xfs/327
+++ b/tests/xfs/327
@@ -12,14 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount > /dev/null 2>&1
-	rm -rf $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/336 b/tests/xfs/336
index 6592419d..31df95bf 100755
--- a/tests/xfs/336
+++ b/tests/xfs/336
@@ -9,13 +9,6 @@
 . ./common/preamble
 _begin_fstest auto rmap realtime metadump
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -rf "$tmp".* $metadump_file
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/432 b/tests/xfs/432
index 86012f0b..8206616d 100755
--- a/tests/xfs/432
+++ b/tests/xfs/432
@@ -16,12 +16,12 @@
 . ./common/preamble
 _begin_fstest auto quick dir metadata metadump
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f "$tmp".* $metadump_file $metadump_img
+	rm -f $metadump_file $metadump_img
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/438 b/tests/xfs/438
index c3008b1c..3531e46d 100755
--- a/tests/xfs/438
+++ b/tests/xfs/438
@@ -23,17 +23,21 @@
 . ./common/preamble
 _begin_fstest auto quick quota
 
-# Override the default cleanup function.
-_cleanup()
+_dmflakey_cleanup()
+{
+	_unmount_flakey
+	_cleanup_flakey
+	cleanup
+}
+local_cleanup()
 {
 	[ -z "${interval}" ] || \
 		sysctl -w fs.xfs.xfssyncd_centisecs=${interval} >/dev/null 2>&1
-	cd /
-	rm -f $tmp.*
-	_unmount_flakey >/dev/null 2>&1
-	_cleanup_flakey > /dev/null 2>&1
+	_dmflakey_cleanup
 }
 
+_register_cleanup local_cleanup
+
 # inject IO write error for the XFS filesystem except its log section
 make_xfs_scratch_flakey_table()
 {
diff --git a/tests/xfs/442 b/tests/xfs/442
index b04b1c83..a4a76ce2 100755
--- a/tests/xfs/442
+++ b/tests/xfs/442
@@ -12,13 +12,13 @@
 . ./common/preamble
 _begin_fstest auto stress clone quota
 
-# Override the default cleanup function.
-_cleanup()
+_fsstress_cleanup()
 {
-	cd /
-	rm -f $tmp.*
-	$KILLALL_PROG -9 fsstress > /dev/null 2>&1
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
 }
+_register_cleanup fsstress_cleanup
 
 # Import common functions.
 . ./common/quota
diff --git a/tests/xfs/447 b/tests/xfs/447
index 795c43b9..088c1c4e 100755
--- a/tests/xfs/447
+++ b/tests/xfs/447
@@ -9,13 +9,12 @@
 . ./common/preamble
 _begin_fstest auto mount
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.*
 	echo 0 > /sys/fs/xfs/debug/mount_delay
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/501 b/tests/xfs/501
index a9acf0af..aa74836f 100755
--- a/tests/xfs/501
+++ b/tests/xfs/501
@@ -17,13 +17,12 @@ testfile=$TEST_DIR/$seq.txt
 
 delay_knob="/sys/fs/xfs/debug/log_recovery_delay"
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
 	test -e "$delay_knob" && echo 0 > "$delay_knob"
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/inject
diff --git a/tests/xfs/503 b/tests/xfs/503
index 6c4bfd1c..9dec0ff0 100755
--- a/tests/xfs/503
+++ b/tests/xfs/503
@@ -10,14 +10,12 @@
 . ./common/preamble
 _begin_fstest auto copy metadump
 
-_register_cleanup "_cleanup" BUS
-
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -rf $tmp.* $testdir
+	rm -rf $testdir
+	_cleanup
 }
+_register_cleanup local_cleanup BUS
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/507 b/tests/xfs/507
index b9c9ab29..abd16e38 100755
--- a/tests/xfs/507
+++ b/tests/xfs/507
@@ -16,16 +16,13 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
-	test -n "$loop_mount" && $UMOUNT_PROG $loop_mount > /dev/null 2>&1
-	test -n "$loop_dev" && _destroy_loop_device $loop_dev
-	rm -rf $tmp.*
+	UMOUNT_PROG $loop_mount > /dev/null 2>&1
+	test -n "$loop_dev" &&_destroy_loop_device $loop_dev
+	_cleanup
 }
+_register_cleanup _loop_cleanup BUS
 
 # Import common functions.
 . ./common/reflink
diff --git a/tests/xfs/511 b/tests/xfs/511
index d2550404..a91fde65 100755
--- a/tests/xfs/511
+++ b/tests/xfs/511
@@ -10,14 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick quota
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount
-	rm -f $tmp.*
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/quota
diff --git a/tests/xfs/512 b/tests/xfs/512
index 4595770e..7aee8b78 100755
--- a/tests/xfs/512
+++ b/tests/xfs/512
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick acl attr
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $FILE
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/attr
@@ -31,6 +24,7 @@ _require_attrs
 _require_user
 
 FILE=$TEST_DIR/foo
+rm -f $FILE
 
 echo "This is a test" > ${FILE}
 chmod g-r $FILE
diff --git a/tests/xfs/513 b/tests/xfs/513
index bfdfd4f6..13084f4d 100755
--- a/tests/xfs/513
+++ b/tests/xfs/513
@@ -9,22 +9,17 @@
 . ./common/preamble
 _begin_fstest auto mount
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
-	rm -f $tmp.*
 	$UMOUNT_PROG $LOOP_MNT 2>/dev/null
-	if [ -n "$LOOP_DEV" ];then
-		_destroy_loop_device $LOOP_DEV 2>/dev/null
-	fi
-	if [ -n "$LOOP_SPARE_DEV" ];then
-		_destroy_loop_device $LOOP_SPARE_DEV 2>/dev/null
-	fi
+	[ -n "$LOOP_DEV" ] && _destroy_loop_device $LOOP_DEV
+	[ -n "$LOOP_SPARE_DEV" ] && _destroy_loop_device $LOOP_SPARE_DEV
 	rm -f $LOOP_IMG
 	rm -f $LOOP_SPARE_IMG
 	rmdir $LOOP_MNT
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/514 b/tests/xfs/514
index cf5588f2..431a3f95 100755
--- a/tests/xfs/514
+++ b/tests/xfs/514
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick db
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.* $file
+	rm -f $file
+	_cleanup
 }
-
-# Import common functions.
+_register_cleanup local_cleanup
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/515 b/tests/xfs/515
index 2d7bbb35..4e0d681c 100755
--- a/tests/xfs/515
+++ b/tests/xfs/515
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick quota
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.* $file
+	rm -f $file
+	_cleanup
 }
-
-# Import common functions.
+_register_cleanup local_cleanup
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/516 b/tests/xfs/516
index 9e1b9931..2aa20696 100755
--- a/tests/xfs/516
+++ b/tests/xfs/516
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	rm -f $tmp.*
-	cd /
-}
-
 # Import common functions.
 . ./common/fuzzy
 
diff --git a/tests/xfs/517 b/tests/xfs/517
index 512f795f..015a7a5f 100755
--- a/tests/xfs/517
+++ b/tests/xfs/517
@@ -9,15 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick fsmap freeze
 
-_register_cleanup "_cleanup" BUS
-
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
 	$XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT > /dev/null 2>&1
-	rm -rf $tmp.*
+	_cleanup
 }
+_register_cleanup local_cleanup BUS
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/520 b/tests/xfs/520
index 2fceb07c..b24d4fee 100755
--- a/tests/xfs/520
+++ b/tests/xfs/520
@@ -14,14 +14,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.*
-	_scratch_unmount > /dev/null 2>&1
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/521 b/tests/xfs/521
index 60f28740..d93b74b9 100755
--- a/tests/xfs/521
+++ b/tests/xfs/521
@@ -16,14 +16,14 @@
 . ./common/preamble
 _begin_fstest auto quick realtime growfs
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	_scratch_unmount >> $seqres.full 2>&1
 	test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
-	rm -f $tmp.* $TEST_DIR/$seq.rtvol
+	rm -f $TEST_DIR/$seq.rtvol
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/522 b/tests/xfs/522
index 2475d584..ff0726a9 100755
--- a/tests/xfs/522
+++ b/tests/xfs/522
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.* $def_cfgfile $fsimg
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/523 b/tests/xfs/523
index bd9b7553..ce4cecd6 100755
--- a/tests/xfs/523
+++ b/tests/xfs/523
@@ -10,13 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.* $def_cfgfile $fsimg
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/524 b/tests/xfs/524
index fe4d134b..9811c294 100755
--- a/tests/xfs/524
+++ b/tests/xfs/524
@@ -9,12 +9,12 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
+local_cleanup()
 {
-	cd /
-	rm -f $tmp.* $def_cfgfile $fsimg
+	rm -f $def_cfgfile $fsimg
+	_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/525 b/tests/xfs/525
index a17c9f19..9700f960 100755
--- a/tests/xfs/525
+++ b/tests/xfs/525
@@ -9,13 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.* $def_cfgfile
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/526 b/tests/xfs/526
index 4261e849..edd20826 100755
--- a/tests/xfs/526
+++ b/tests/xfs/526
@@ -9,13 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	rm -f $tmp.* $def_cfgfile
-}
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/528 b/tests/xfs/528
index 29e81228..f76bd15f 100755
--- a/tests/xfs/528
+++ b/tests/xfs/528
@@ -10,14 +10,14 @@
 . ./common/preamble
 _begin_fstest auto quick rw realtime
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	_scratch_unmount >> $seqres.full 2>&1
 	test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
 	rm -f $tmp.* $TEST_DIR/$seq.rtvol
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/530 b/tests/xfs/530
index 9c6f44d7..226ebd2a 100755
--- a/tests/xfs/530
+++ b/tests/xfs/530
@@ -10,14 +10,14 @@
 . ./common/preamble
 _begin_fstest auto quick realtime growfs
 
-# Override the default cleanup function.
-_cleanup()
+_loop_cleanup()
 {
-	cd /
 	_scratch_unmount >> $seqres.full 2>&1
 	test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
 	rm -f $tmp.* $TEST_DIR/$seq.rtvol
+	_cleanup
 }
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/542 b/tests/xfs/542
index 5c45eed7..f4d3ae9d 100755
--- a/tests/xfs/542
+++ b/tests/xfs/542
@@ -13,12 +13,13 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_cleanup()
+_dmflakey_cleanup()
 {
+	_unmount_flakey
 	_cleanup_flakey
-	cd /
-	rm -r -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dmflakey_cleanup
 
 # Import common functions.
 . ./common/reflink
diff --git a/tests/xfs/543 b/tests/xfs/543
index 913276c8..1562f563 100755
--- a/tests/xfs/543
+++ b/tests/xfs/543
@@ -11,13 +11,6 @@
 . ./common/preamble
 _begin_fstest auto quick mkfs
 
-_cleanup()
-{
-	rm -f $TEST_DIR/fubar.img
-	cd /
-	rm -r -f $tmp.*
-}
-
 # Import common functions.
 # . ./common/filter
 
diff --git a/tests/xfs/544 b/tests/xfs/544
index c7251fc3..f76aaa24 100755
--- a/tests/xfs/544
+++ b/tests/xfs/544
@@ -10,15 +10,20 @@
 . ./common/preamble
 _begin_fstest auto quick dump
 
-_cleanup()
+_dump_cleanup()
 {
 	_cleanup_dump
-	cd /
-	rm -r -f $tmp.*
+	_cleanup
+}
+
+local_cleanup()
+{
 	$UMOUNT_PROG $TEST_DIR/dest.$seq 2> /dev/null
 	rmdir $TEST_DIR/src.$seq 2> /dev/null
 	rmdir $TEST_DIR/dest.$seq 2> /dev/null
+	_dump_cleanup
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 4/8] fstests: define a common _dump_cleanup function
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (2 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 3/8] xfs/*: clean up _cleanup override Dave Chinner
@ 2022-05-24  7:34 ` Dave Chinner
  2022-05-24  9:04   ` Amir Goldstein
  2022-05-24  7:34 ` [PATCH 5/8] fstests: use a common fsstress cleanup function Dave Chinner
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Almost all xfsdump tests now use the same cleanup function.
Deduplicate them.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/dump   | 53 ++++++++++++++++++++++++++-------------------------
 tests/xfs/022 | 12 ++----------
 tests/xfs/023 | 13 ++-----------
 tests/xfs/024 | 12 ++----------
 tests/xfs/025 | 12 ++----------
 tests/xfs/026 | 12 ++----------
 tests/xfs/027 | 12 ++----------
 tests/xfs/028 | 12 ++----------
 tests/xfs/035 | 10 +---------
 tests/xfs/036 |  9 +--------
 tests/xfs/037 | 10 +---------
 tests/xfs/038 |  9 +--------
 tests/xfs/039 |  9 +--------
 tests/xfs/043 |  9 +--------
 tests/xfs/046 |  9 +--------
 tests/xfs/047 |  9 +--------
 tests/xfs/055 |  9 +--------
 tests/xfs/056 | 11 +----------
 tests/xfs/059 | 12 ++----------
 tests/xfs/060 | 12 ++----------
 tests/xfs/061 | 12 ++----------
 tests/xfs/063 |  9 ++-------
 tests/xfs/064 |  9 ++-------
 tests/xfs/065 |  9 ++-------
 tests/xfs/066 | 11 +++--------
 tests/xfs/068 | 12 ++----------
 tests/xfs/266 | 14 +++-----------
 tests/xfs/267 | 13 +++----------
 tests/xfs/268 | 12 +++---------
 tests/xfs/281 |  9 +--------
 tests/xfs/282 |  9 +--------
 tests/xfs/283 |  9 +--------
 tests/xfs/287 | 11 +++--------
 tests/xfs/296 | 11 ++---------
 tests/xfs/301 | 11 ++---------
 tests/xfs/302 | 11 ++---------
 tests/xfs/544 | 10 ++--------
 37 files changed, 91 insertions(+), 347 deletions(-)

diff --git a/common/dump b/common/dump
index 0dcc9655..b6001016 100644
--- a/common/dump
+++ b/common/dump
@@ -219,41 +219,42 @@ _require_tape()
 
 #
 # Cleanup created dirs and files
-# Called by trap
-#
+# Called by trap, needs to call generic cleanup when done.
 _cleanup_dump()
 {
-    # Some tests include this before checking _supported_fs xfs
-    # and the sleeps & checks here get annoying
-    if [ "$FSTYP" != "xfs" ]; then
-       return
-    fi
+	# Some tests include this before checking _supported_fs xfs
+	# and the sleeps & checks here get annoying
+	if [ "$FSTYP" != "xfs" ]; then
+		return
+	fi
 
-    cd $here
+	cd $here
+
+	if [ -n "$DEBUGDUMP" ]; then
+		# save it for inspection
+		for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
+			[ -d $dir ] || continue
+			tar -cvf $seqres.inventory.tar $dir
+			ls -nR $dir >$seqres.inventory.ls
+		done
+	fi
 
-    if [ -n "$DEBUGDUMP" ]; then
-	# save it for inspection
+	# put inventory dir back
 	for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
-	    [ -d $dir ] || continue
-	    tar -cvf $seqres.inventory.tar $dir
-	    ls -nR $dir >$seqres.inventory.ls
+		[ -d $dir.$seq ] || continue
+		rm -rf $dir		# get rid of new one
+		mv $dir.$seq $dir
 	done
-    fi
 
-    # put inventory dir back
-    for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
-	[ -d $dir.$seq ] || continue
-	rm -rf $dir		# get rid of new one
-	mv $dir.$seq $dir
-    done
+	if [ -f ${RESULT_DIR}/require_scratch ] && [ $status -ne $NOTRUNSTS ]; then
+		# Sleep added to stop _check_scratch_fs from complaining that
+		# the scratch_dev is still busy
+		sleep 10
 
-    if [ -f ${RESULT_DIR}/require_scratch ] && [ $status -ne $NOTRUNSTS ]; then
-	# Sleep added to stop _check_scratch_fs from complaining that the
-	# scratch_dev is still busy
-	sleep 10
+		_check_scratch_fs
+	fi
 
-	_check_scratch_fs
-    fi
+	_cleanup
 }
 
 #
diff --git a/tests/xfs/022 b/tests/xfs/022
index e9310365..2d124709 100755
--- a/tests/xfs/022
+++ b/tests/xfs/022
@@ -9,20 +9,11 @@
 #
 # Use fsstress to create a directory structure with a mix of files
 #
-seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -42,4 +33,5 @@ _do_restore | sed -e "/entries processed$/s/[0-9][0-9]*/NUM/g"
 _ls_compare_sub
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/023 b/tests/xfs/023
index 1019831d..e2b9ba6f 100755
--- a/tests/xfs/023
+++ b/tests/xfs/023
@@ -7,21 +7,11 @@
 # To test xfsdump/restore to tape using a directory with
 # files with data created by src/fill.
 #
-seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -38,4 +28,5 @@ _diff_compare_sub
 _ls_compare_sub
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/024 b/tests/xfs/024
index dcb6b9fc..920bacb2 100755
--- a/tests/xfs/024
+++ b/tests/xfs/024
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -42,4 +33,5 @@ _do_restore
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/025 b/tests/xfs/025
index dd3c8588..479c51b4 100755
--- a/tests/xfs/025
+++ b/tests/xfs/025
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -35,4 +26,5 @@ _do_restore_min
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/026 b/tests/xfs/026
index 18529003..0daa7c88 100755
--- a/tests/xfs/026
+++ b/tests/xfs/026
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -33,4 +24,5 @@ _do_restore_file
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/027 b/tests/xfs/027
index df6ee2ac..58e9ec68 100755
--- a/tests/xfs/027
+++ b/tests/xfs/027
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -32,4 +23,5 @@ _do_dump_restore
 _diff_compare_sub
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/028 b/tests/xfs/028
index d0518317..be7453d4 100755
--- a/tests/xfs/028
+++ b/tests/xfs/028
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -56,4 +47,5 @@ _do_invutil -F
 _dump_inventory
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/035 b/tests/xfs/035
index 6461884b..29168c5a 100755
--- a/tests/xfs/035
+++ b/tests/xfs/035
@@ -10,16 +10,8 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl tape auto
 
-# Override the default cleanup function.
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/036 b/tests/xfs/036
index becbc83c..ab3cbf3b 100755
--- a/tests/xfs/036
+++ b/tests/xfs/036
@@ -10,15 +10,8 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/037 b/tests/xfs/037
index 0cbd0b16..9deff09e 100755
--- a/tests/xfs/037
+++ b/tests/xfs/037
@@ -9,16 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
-
+_register_cleanup _cleanup_dump
 # real QA test starts here
 _supported_fs xfs
 
diff --git a/tests/xfs/038 b/tests/xfs/038
index da5507af..e868df79 100755
--- a/tests/xfs/038
+++ b/tests/xfs/038
@@ -9,15 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/039 b/tests/xfs/039
index 69a1092d..1499d1ec 100755
--- a/tests/xfs/039
+++ b/tests/xfs/039
@@ -10,15 +10,8 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/043 b/tests/xfs/043
index 7ce74539..6cc264b0 100755
--- a/tests/xfs/043
+++ b/tests/xfs/043
@@ -12,15 +12,8 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/046 b/tests/xfs/046
index 3ac4a180..8db91972 100755
--- a/tests/xfs/046
+++ b/tests/xfs/046
@@ -9,15 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/047 b/tests/xfs/047
index c2f66e31..a0aaf3d2 100755
--- a/tests/xfs/047
+++ b/tests/xfs/047
@@ -9,15 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/055 b/tests/xfs/055
index d663bfab..eaf807d2 100755
--- a/tests/xfs/055
+++ b/tests/xfs/055
@@ -10,15 +10,8 @@ seqfull=$0
 . ./common/preamble
 _begin_fstest dump ioctl remote tape
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/056 b/tests/xfs/056
index 7a4b2423..0ecb8503 100755
--- a/tests/xfs/056
+++ b/tests/xfs/056
@@ -10,17 +10,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/059 b/tests/xfs/059
index 9428a9da..d405bdea 100755
--- a/tests/xfs/059
+++ b/tests/xfs/059
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -36,4 +27,5 @@ _ls_compare_sub
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/060 b/tests/xfs/060
index b5939f67..4aca8943 100755
--- a/tests/xfs/060
+++ b/tests/xfs/060
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -42,4 +33,5 @@ _ls_compare_sub
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/061 b/tests/xfs/061
index dcaac20c..1ff3857a 100755
--- a/tests/xfs/061
+++ b/tests/xfs/061
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -40,4 +31,5 @@ _diff_compare_sub
 _ls_nodate_compare_sub
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/063 b/tests/xfs/063
index 9193745a..a4c2b1ea 100755
--- a/tests/xfs/063
+++ b/tests/xfs/063
@@ -9,16 +9,11 @@
 . ./common/preamble
 _begin_fstest dump attr auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 . ./common/attr
 
 # real QA test starts here
diff --git a/tests/xfs/064 b/tests/xfs/064
index e332daee..19d4d8fc 100755
--- a/tests/xfs/064
+++ b/tests/xfs/064
@@ -9,16 +9,11 @@
 . ./common/preamble
 _begin_fstest dump auto
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 
 _ls_size_filter()
 {
diff --git a/tests/xfs/065 b/tests/xfs/065
index 9b31ff34..f7f2ab35 100755
--- a/tests/xfs/065
+++ b/tests/xfs/065
@@ -12,16 +12,11 @@
 . ./common/preamble
 _begin_fstest dump auto
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 . ./common/quota
 
 #
diff --git a/tests/xfs/066 b/tests/xfs/066
index 22eb10cc..2e7b67e0 100755
--- a/tests/xfs/066
+++ b/tests/xfs/066
@@ -9,16 +9,11 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-# Import common functions.
-. ./common/filter
 . ./common/dump
+_register_cleanup _cleanup_dump
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+# Import common functions.
+. ./common/filter
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/068 b/tests/xfs/068
index ed281881..26957adc 100755
--- a/tests/xfs/068
+++ b/tests/xfs/068
@@ -10,20 +10,11 @@
 # Test for regression caused by
 # c7cb51d xfs: fix error handling at xfs_inumbers
 #
-seqfull=$0
 . ./common/preamble
 _begin_fstest auto stress dump
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
@@ -44,4 +35,5 @@ _count_restoredir_files | tee $tmp.after >> $seqres.full
 diff -u $tmp.before $tmp.after
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/266 b/tests/xfs/266
index 1a57f644..1be1ecc5 100755
--- a/tests/xfs/266
+++ b/tests/xfs/266
@@ -9,14 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 #
 # Add a new file and append a subset of the fill'ed files
@@ -44,9 +38,6 @@ filter_cumulative_quota_updates() {
 	{print}'
 }
 
-# Import common functions.
-. ./common/dump
-
 # real QA test starts here
 _supported_fs xfs
 _require_scratch
@@ -71,4 +62,5 @@ _ls_compare_sub
 _diff_compare
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/267 b/tests/xfs/267
index 19e1f030..4bfffad7 100755
--- a/tests/xfs/267
+++ b/tests/xfs/267
@@ -9,16 +9,9 @@
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
-#
 # create a 40 MiB file with an extended attr.
 # xfsdump writes file data in "extent groups", currently 16 MiB in size. After
 # writing an extent group or finishing a file, xfsdump will start a new media
@@ -38,7 +31,6 @@ End-of-File
 }
 
 # Import common functions.
-. ./common/dump
 . ./common/attr
 
 # real QA test starts here
@@ -59,4 +51,5 @@ _diff_compare
 _diff_compare_eas
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/268 b/tests/xfs/268
index fd668856..77fca55d 100755
--- a/tests/xfs/268
+++ b/tests/xfs/268
@@ -11,14 +11,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl tape
 
-status=0	# success is the default!
-
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # create two 12 MiB files with extended attrs.
 # xfsdump writes file data in "extent groups", currently 16 MiB in size. After
@@ -40,7 +34,6 @@ End-of-File
 }
 
 # Import common functions.
-. ./common/dump
 . ./common/attr
 
 # real QA test starts here
@@ -61,4 +54,5 @@ _diff_compare
 _diff_compare_eas
 
 # success, all done
+status=0
 exit
diff --git a/tests/xfs/281 b/tests/xfs/281
index eba8e39c..b33df7ed 100755
--- a/tests/xfs/281
+++ b/tests/xfs/281
@@ -9,15 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/282 b/tests/xfs/282
index 53c7dc49..5d234de5 100755
--- a/tests/xfs/282
+++ b/tests/xfs/282
@@ -11,15 +11,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/283 b/tests/xfs/283
index 6d377615..7a145d65 100755
--- a/tests/xfs/283
+++ b/tests/xfs/283
@@ -11,15 +11,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
-
-# Import common functions.
 . ./common/dump
+_register_cleanup _cleanup_dump
 
 # real QA test starts here
 _supported_fs xfs
diff --git a/tests/xfs/287 b/tests/xfs/287
index fea453f5..ae97f0cc 100755
--- a/tests/xfs/287
+++ b/tests/xfs/287
@@ -10,16 +10,11 @@
 . ./common/preamble
 _begin_fstest auto dump quota quick
 
-# Import common functions.
-. ./common/quota
 . ./common/dump
+_register_cleanup _cleanup_dump
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+# Import common functions.
+. ./common/quota
 
 _print_projid()
 {
diff --git a/tests/xfs/296 b/tests/xfs/296
index 96268cee..18889788 100755
--- a/tests/xfs/296
+++ b/tests/xfs/296
@@ -9,20 +9,13 @@
 . ./common/preamble
 _begin_fstest dump auto quick
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_scratch
 _require_command "$SETCAP_PROG" setcap
diff --git a/tests/xfs/301 b/tests/xfs/301
index 12e8bc1a..3d94e3a4 100755
--- a/tests/xfs/301
+++ b/tests/xfs/301
@@ -9,21 +9,14 @@
 . ./common/preamble
 _begin_fstest auto dump
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 . ./common/attr
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_scratch
 _scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
diff --git a/tests/xfs/302 b/tests/xfs/302
index 14907273..319ffb62 100755
--- a/tests/xfs/302
+++ b/tests/xfs/302
@@ -9,20 +9,13 @@
 . ./common/preamble
 _begin_fstest auto dump
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
-_register_cleanup _dump_cleanup
+. ./common/dump
+_register_cleanup _cleanup_dump
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_scratch
 _scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
diff --git a/tests/xfs/544 b/tests/xfs/544
index f76aaa24..92036250 100755
--- a/tests/xfs/544
+++ b/tests/xfs/544
@@ -10,27 +10,21 @@
 . ./common/preamble
 _begin_fstest auto quick dump
 
-_dump_cleanup()
-{
-	_cleanup_dump
-	_cleanup
-}
+. ./common/dump
 
 local_cleanup()
 {
 	$UMOUNT_PROG $TEST_DIR/dest.$seq 2> /dev/null
 	rmdir $TEST_DIR/src.$seq 2> /dev/null
 	rmdir $TEST_DIR/dest.$seq 2> /dev/null
-	_dump_cleanup
+	_cleanup_dump
 }
 _register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
-. ./common/dump
 
 # real QA test starts here
-
 _supported_fs xfs
 
 # Setup
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 5/8] fstests: use a common fsstress cleanup function
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (3 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 4/8] fstests: define a common _dump_cleanup function Dave Chinner
@ 2022-05-24  7:34 ` 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
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Lots of tests now have a common cleanup function for fsstress based
tests. Define a common cleanup function in common/preamble and
convert those tests to register it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/preamble | 11 +++++++++++
 tests/xfs/011   |  7 -------
 tests/xfs/013   |  9 +--------
 tests/xfs/051   | 11 ++---------
 tests/xfs/057   |  9 ---------
 tests/xfs/079   | 11 +----------
 tests/xfs/141   | 11 +----------
 tests/xfs/167   |  9 +--------
 tests/xfs/442   | 11 ++---------
 9 files changed, 19 insertions(+), 70 deletions(-)

diff --git a/common/preamble b/common/preamble
index 7aa55dc6..0e8827c3 100644
--- a/common/preamble
+++ b/common/preamble
@@ -13,6 +13,17 @@ _cleanup()
 	rm -r -f $tmp.*
 }
 
+# Standard cleanup function for tests using fsstress. THese tests all need to
+# kill fsstress processes when unexpectedly killed, and wait for them to finish.
+# Those tests can either register this function directly or call it from their
+# own local cleanup functions.
+_fsstress_cleanup()
+{
+	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
+	wait
+	_cleanup
+}
+
 # Install the supplied cleanup code as a signal handler for HUP, INT, QUIT,
 # TERM, or when the test exits.  Extra signals can be specified as subsequent
 # parameters.
diff --git a/tests/xfs/011 b/tests/xfs/011
index 161f263c..b9b0d138 100755
--- a/tests/xfs/011
+++ b/tests/xfs/011
@@ -10,13 +10,6 @@
 #
 . ./common/preamble
 _begin_fstest auto freeze log metadata quick
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 fsstress 2>/dev/null
-	wait
-	_cleanup
-}
 _register_cleanup _fsstress_cleanup
 
 # Use the information exported by XFS to sysfs to determine whether the log has
diff --git a/tests/xfs/013 b/tests/xfs/013
index c451ded3..ce91ed62 100755
--- a/tests/xfs/013
+++ b/tests/xfs/013
@@ -12,18 +12,11 @@
 #
 . ./common/preamble
 _begin_fstest auto metadata stress
+_register_cleanup _fsstress_cleanup
 
 # Import common functions.
 . ./common/filter
 
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 fsstress 2>/dev/null
-	wait
-	_cleanup
-}
-_register_cleanup _fsstress_cleanup
-
 filter_enospc() {
 	sed -e '/^.*No space left on device.*/d'
 }
diff --git a/tests/xfs/051 b/tests/xfs/051
index 4718099d..e2e0e7f2 100755
--- a/tests/xfs/051
+++ b/tests/xfs/051
@@ -10,19 +10,12 @@
 #
 . ./common/preamble
 _begin_fstest shutdown auto log metadata
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-_register_cleanup fsstress_cleanup
+_register_cleanup _fsstress_cleanup
 
 # Import common functions.
 . ./common/dmflakey
 
-# Modify as appropriate.
+# real QA test starts here
 _supported_fs xfs
 
 _require_scratch
diff --git a/tests/xfs/057 b/tests/xfs/057
index 983479ab..432c4836 100755
--- a/tests/xfs/057
+++ b/tests/xfs/057
@@ -23,13 +23,6 @@
 . ./common/preamble
 _begin_fstest auto log recoveryloop
 
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-
 local_cleanup()
 {
 	[ -e /sys/fs/xfs/$sdev/errortag/log_item_pin ] &&
@@ -42,8 +35,6 @@ _register_cleanup local_cleanup
 . ./common/inject
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_xfs_io_error_injection log_item_pin
 _require_xfs_io_error_injection log_bad_crc
diff --git a/tests/xfs/079 b/tests/xfs/079
index fc30181b..d49b699c 100755
--- a/tests/xfs/079
+++ b/tests/xfs/079
@@ -16,21 +16,12 @@
 #
 . ./common/preamble
 _begin_fstest shutdown auto log quick
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-_register_cleanup fsstress_cleanup
+_register_cleanup _fsstress_cleanup
 
 # Import common functions.
 . ./common/log
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_scratch
 _require_v2log
diff --git a/tests/xfs/141 b/tests/xfs/141
index 0b0cac81..18a00058 100755
--- a/tests/xfs/141
+++ b/tests/xfs/141
@@ -13,21 +13,12 @@
 #
 . ./common/preamble
 _begin_fstest auto log metadata
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-_register_cleanup fsstress_cleanup
+_register_cleanup _fsstress_cleanup
 
 # Import common functions.
 . ./common/inject
 
 # real QA test starts here
-
-# Modify as appropriate.
 _supported_fs xfs
 _require_xfs_io_error_injection "log_bad_crc"
 _require_scratch
diff --git a/tests/xfs/167 b/tests/xfs/167
index 50d3c41b..d7b5f378 100755
--- a/tests/xfs/167
+++ b/tests/xfs/167
@@ -8,14 +8,7 @@
 #
 . ./common/preamble
 _begin_fstest rw metadata auto stress
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-_register_cleanup fsstress_cleanup
+_register_cleanup _fsstress_cleanup
 
 workout()
 {
diff --git a/tests/xfs/442 b/tests/xfs/442
index a4a76ce2..dcec4685 100755
--- a/tests/xfs/442
+++ b/tests/xfs/442
@@ -11,21 +11,14 @@
 #
 . ./common/preamble
 _begin_fstest auto stress clone quota
-
-_fsstress_cleanup()
-{
-	$KILLALL_PROG -9 $FSSTRESS_PROG > /dev/null 2>&1
-	wait
-	_cleanup
-}
-_register_cleanup fsstress_cleanup
+_register_cleanup _fsstress_cleanup
 
 # Import common functions.
 . ./common/quota
 . ./common/filter
 . ./common/reflink
 
-# Modify as appropriate.
+# real QA test starts here
 _supported_fs xfs
 
 _require_scratch_reflink
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 6/8] fstests: consolidate no cleanup test setup
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (4 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 5/8] fstests: use a common fsstress cleanup function Dave Chinner
@ 2022-05-24  7:34 ` Dave Chinner
  2022-05-24 12:22   ` Amir Goldstein
  2022-05-24  7:34 ` [PATCH 7/8] fstests: Set up BUS trap for tests by default Dave Chinner
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Many of the XFS fuzzer tests define a "no cleanup" cleanup function.
Consolidate this in common/preamble and deduplicate all the tests
using this setup.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/preamble | 9 +++++++++
 tests/xfs/083   | 5 -----
 tests/xfs/085   | 5 -----
 tests/xfs/086   | 5 -----
 tests/xfs/087   | 5 -----
 tests/xfs/088   | 5 -----
 tests/xfs/089   | 5 -----
 tests/xfs/091   | 5 -----
 tests/xfs/093   | 5 -----
 tests/xfs/097   | 5 -----
 tests/xfs/098   | 5 -----
 tests/xfs/099   | 5 -----
 tests/xfs/100   | 5 -----
 tests/xfs/101   | 5 -----
 tests/xfs/102   | 5 -----
 tests/xfs/105   | 5 -----
 tests/xfs/112   | 5 -----
 tests/xfs/113   | 5 -----
 tests/xfs/117   | 5 -----
 tests/xfs/120   | 5 -----
 tests/xfs/123   | 5 -----
 tests/xfs/124   | 5 -----
 tests/xfs/125   | 5 -----
 tests/xfs/126   | 5 -----
 tests/xfs/130   | 5 -----
 25 files changed, 9 insertions(+), 120 deletions(-)

diff --git a/common/preamble b/common/preamble
index 0e8827c3..99e60a40 100644
--- a/common/preamble
+++ b/common/preamble
@@ -13,6 +13,15 @@ _cleanup()
 	rm -r -f $tmp.*
 }
 
+# Cleanup function for tests that want to leave a warm corpse behind for
+# debugging purposes. This should really only be used on tests that are designed
+# to fail (e.g. fuzzer tests) and not on tests that should always pass in normal
+# circumstances.
+_no_cleanup()
+{
+	cd /
+}
+
 # Standard cleanup function for tests using fsstress. THese tests all need to
 # kill fsstress processes when unexpectedly killed, and wait for them to finish.
 # Those tests can either register this function directly or call it from their
diff --git a/tests/xfs/083 b/tests/xfs/083
index 7666d204..a817c71f 100755
--- a/tests/xfs/083
+++ b/tests/xfs/083
@@ -10,11 +10,6 @@
 #
 . ./common/preamble
 _begin_fstest dangerous_fuzzers punch
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/085 b/tests/xfs/085
index 8aa8f2a0..6d171f5a 100755
--- a/tests/xfs/085
+++ b/tests/xfs/085
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/086 b/tests/xfs/086
index 031cb445..d0e26381 100755
--- a/tests/xfs/086
+++ b/tests/xfs/086
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/087 b/tests/xfs/087
index 9d1f59f0..bca4fdd0 100755
--- a/tests/xfs/087
+++ b/tests/xfs/087
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/088 b/tests/xfs/088
index de824223..b3743151 100755
--- a/tests/xfs/088
+++ b/tests/xfs/088
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/089 b/tests/xfs/089
index dae2d0d0..5567c3f0 100755
--- a/tests/xfs/089
+++ b/tests/xfs/089
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/091 b/tests/xfs/091
index c5db3337..8cda3146 100755
--- a/tests/xfs/091
+++ b/tests/xfs/091
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/093 b/tests/xfs/093
index 9fe1799a..a4308881 100755
--- a/tests/xfs/093
+++ b/tests/xfs/093
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/097 b/tests/xfs/097
index d66df458..8cdf7ce2 100755
--- a/tests/xfs/097
+++ b/tests/xfs/097
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/098 b/tests/xfs/098
index 21215ee5..7d2c5b8a 100755
--- a/tests/xfs/098
+++ b/tests/xfs/098
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/099 b/tests/xfs/099
index 2791e2df..a59022b6 100755
--- a/tests/xfs/099
+++ b/tests/xfs/099
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/100 b/tests/xfs/100
index e71e760e..6f3c36c5 100755
--- a/tests/xfs/100
+++ b/tests/xfs/100
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/101 b/tests/xfs/101
index 1cbcc973..437ba63f 100755
--- a/tests/xfs/101
+++ b/tests/xfs/101
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/102 b/tests/xfs/102
index 0ce3588a..b75883f6 100755
--- a/tests/xfs/102
+++ b/tests/xfs/102
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/105 b/tests/xfs/105
index 8a583da5..66c59c23 100755
--- a/tests/xfs/105
+++ b/tests/xfs/105
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/112 b/tests/xfs/112
index 4362f31c..b3fcf12f 100755
--- a/tests/xfs/112
+++ b/tests/xfs/112
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/113 b/tests/xfs/113
index e3f4fd4d..9d18532f 100755
--- a/tests/xfs/113
+++ b/tests/xfs/113
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/117 b/tests/xfs/117
index 4962c201..c8d1635d 100755
--- a/tests/xfs/117
+++ b/tests/xfs/117
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/120 b/tests/xfs/120
index 653948ee..e427b0c3 100755
--- a/tests/xfs/120
+++ b/tests/xfs/120
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/123 b/tests/xfs/123
index e191623a..48c8dd08 100755
--- a/tests/xfs/123
+++ b/tests/xfs/123
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/124 b/tests/xfs/124
index af738212..e9b04a17 100755
--- a/tests/xfs/124
+++ b/tests/xfs/124
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/125 b/tests/xfs/125
index a7280e2c..f5d28ef3 100755
--- a/tests/xfs/125
+++ b/tests/xfs/125
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/126 b/tests/xfs/126
index 55a12178..88d99227 100755
--- a/tests/xfs/126
+++ b/tests/xfs/126
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
diff --git a/tests/xfs/130 b/tests/xfs/130
index e7a0e6e3..c48858ea 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers clone
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 7/8] fstests: Set up BUS trap for tests by default
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (5 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 6/8] fstests: consolidate no cleanup test setup Dave Chinner
@ 2022-05-24  7:34 ` 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  8:29 ` [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Amir Goldstein
  8 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

About 160 individual tests re-register the cleanup trap just to have
it run on a BUS error signal. Just add the BUS signal to the default
set of traps initialised by _register_cleanup() and get rid of these
extra registrations.

This was mostly done with this script:

$ for f in `git grep -l "register_cleanup.*BUS"` ; do
> sed -i -e '/_register_cleanup "_cleanup" BUS/,+1d'
> done

With a small number of non-matching conversions done by hand.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/preamble   | 4 ++--
 tests/ext4/023    | 2 --
 tests/generic/161 | 2 --
 tests/generic/162 | 2 --
 tests/generic/163 | 2 --
 tests/generic/164 | 2 --
 tests/generic/165 | 2 --
 tests/generic/166 | 2 --
 tests/generic/167 | 2 --
 tests/generic/168 | 2 --
 tests/generic/170 | 2 --
 tests/generic/247 | 2 --
 tests/generic/333 | 2 --
 tests/generic/334 | 2 --
 tests/generic/349 | 2 --
 tests/generic/350 | 2 --
 tests/generic/351 | 2 --
 tests/generic/356 | 2 --
 tests/generic/357 | 2 --
 tests/generic/358 | 2 --
 tests/generic/359 | 2 --
 tests/generic/372 | 2 --
 tests/generic/373 | 2 --
 tests/generic/374 | 2 --
 tests/generic/414 | 2 --
 tests/generic/425 | 2 --
 tests/generic/553 | 2 --
 tests/generic/554 | 2 --
 tests/generic/564 | 2 --
 tests/generic/565 | 2 --
 tests/generic/670 | 2 --
 tests/generic/671 | 2 --
 tests/generic/672 | 2 --
 tests/xfs/017     | 2 --
 tests/xfs/138     | 2 --
 tests/xfs/162     | 2 --
 tests/xfs/262     | 2 --
 tests/xfs/280     | 2 --
 tests/xfs/285     | 2 --
 tests/xfs/286     | 2 --
 tests/xfs/349     | 2 --
 tests/xfs/350     | 2 --
 tests/xfs/351     | 2 --
 tests/xfs/352     | 2 --
 tests/xfs/353     | 2 --
 tests/xfs/354     | 2 --
 tests/xfs/355     | 2 --
 tests/xfs/356     | 2 --
 tests/xfs/357     | 2 --
 tests/xfs/358     | 2 --
 tests/xfs/359     | 2 --
 tests/xfs/360     | 2 --
 tests/xfs/361     | 2 --
 tests/xfs/362     | 2 --
 tests/xfs/363     | 2 --
 tests/xfs/364     | 2 --
 tests/xfs/365     | 2 --
 tests/xfs/366     | 2 --
 tests/xfs/367     | 2 --
 tests/xfs/368     | 2 --
 tests/xfs/369     | 2 --
 tests/xfs/370     | 2 --
 tests/xfs/371     | 2 --
 tests/xfs/372     | 2 --
 tests/xfs/373     | 2 --
 tests/xfs/374     | 2 --
 tests/xfs/375     | 2 --
 tests/xfs/376     | 2 --
 tests/xfs/377     | 2 --
 tests/xfs/378     | 2 --
 tests/xfs/379     | 2 --
 tests/xfs/380     | 2 --
 tests/xfs/381     | 2 --
 tests/xfs/382     | 2 --
 tests/xfs/383     | 2 --
 tests/xfs/384     | 2 --
 tests/xfs/385     | 2 --
 tests/xfs/386     | 2 --
 tests/xfs/387     | 2 --
 tests/xfs/388     | 2 --
 tests/xfs/389     | 2 --
 tests/xfs/390     | 2 --
 tests/xfs/391     | 2 --
 tests/xfs/392     | 2 --
 tests/xfs/393     | 2 --
 tests/xfs/394     | 2 --
 tests/xfs/395     | 2 --
 tests/xfs/396     | 2 --
 tests/xfs/397     | 2 --
 tests/xfs/398     | 2 --
 tests/xfs/399     | 2 --
 tests/xfs/400     | 2 --
 tests/xfs/401     | 2 --
 tests/xfs/402     | 2 --
 tests/xfs/403     | 2 --
 tests/xfs/404     | 2 --
 tests/xfs/405     | 2 --
 tests/xfs/406     | 2 --
 tests/xfs/407     | 2 --
 tests/xfs/408     | 2 --
 tests/xfs/409     | 2 --
 tests/xfs/410     | 2 --
 tests/xfs/411     | 2 --
 tests/xfs/412     | 2 --
 tests/xfs/413     | 2 --
 tests/xfs/414     | 2 --
 tests/xfs/415     | 2 --
 tests/xfs/416     | 2 --
 tests/xfs/417     | 2 --
 tests/xfs/418     | 2 --
 tests/xfs/422     | 2 --
 tests/xfs/423     | 2 --
 tests/xfs/425     | 2 --
 tests/xfs/426     | 2 --
 tests/xfs/427     | 2 --
 tests/xfs/428     | 2 --
 tests/xfs/429     | 2 --
 tests/xfs/430     | 2 --
 tests/xfs/444     | 2 --
 tests/xfs/453     | 2 --
 tests/xfs/454     | 2 --
 tests/xfs/455     | 2 --
 tests/xfs/456     | 2 --
 tests/xfs/457     | 2 --
 tests/xfs/458     | 2 --
 tests/xfs/459     | 2 --
 tests/xfs/460     | 2 --
 tests/xfs/461     | 2 --
 tests/xfs/462     | 2 --
 tests/xfs/463     | 2 --
 tests/xfs/464     | 2 --
 tests/xfs/465     | 2 --
 tests/xfs/466     | 2 --
 tests/xfs/467     | 2 --
 tests/xfs/468     | 2 --
 tests/xfs/469     | 2 --
 tests/xfs/470     | 2 --
 tests/xfs/471     | 2 --
 tests/xfs/472     | 2 --
 tests/xfs/473     | 2 --
 tests/xfs/474     | 2 --
 tests/xfs/475     | 2 --
 tests/xfs/476     | 2 --
 tests/xfs/477     | 2 --
 tests/xfs/478     | 2 --
 tests/xfs/479     | 2 --
 tests/xfs/480     | 2 --
 tests/xfs/481     | 2 --
 tests/xfs/482     | 2 --
 tests/xfs/483     | 2 --
 tests/xfs/484     | 2 --
 tests/xfs/485     | 2 --
 tests/xfs/486     | 2 --
 tests/xfs/487     | 2 --
 tests/xfs/488     | 2 --
 tests/xfs/489     | 2 --
 tests/xfs/495     | 2 --
 tests/xfs/496     | 2 --
 tests/xfs/497     | 2 --
 tests/xfs/498     | 2 --
 tests/xfs/499     | 2 --
 tests/xfs/503     | 2 +-
 tests/xfs/507     | 2 +-
 tests/xfs/517     | 2 +-
 164 files changed, 5 insertions(+), 325 deletions(-)

diff --git a/common/preamble b/common/preamble
index 99e60a40..e96dd36b 100644
--- a/common/preamble
+++ b/common/preamble
@@ -42,10 +42,10 @@ _register_cleanup()
 	shift
 
 	# clear out existing traps first
-	trap - EXIT HUP INT QUIT TERM $*
+	trap - EXIT HUP INT QUIT TERM BUS $*
 
 	test -n "$cleanup" && cleanup="${cleanup}; "
-	trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
+	trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM BUS $*
 }
 
 # Prepare to run a fstest by initializing the required global variables to
diff --git a/tests/ext4/023 b/tests/ext4/023
index ebc5ffe3..06d2aeba 100755
--- a/tests/ext4/023
+++ b/tests/ext4/023
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest auto quick scrub
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/generic/161 b/tests/generic/161
index 44d3d8f0..6f5e5edc 100755
--- a/tests/generic/161
+++ b/tests/generic/161
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/162 b/tests/generic/162
index 0dc17f75..9d35c5bd 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone dedupe
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/163 b/tests/generic/163
index 4a6c341e..157bb090 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone dedupe
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/164 b/tests/generic/164
index 8e0b630b..f0fa74e0 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/165 b/tests/generic/165
index d9e6a6e9..cdfb7f7f 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/166 b/tests/generic/166
index 0eb2ec9c..2f3f4453 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/167 b/tests/generic/167
index ae5fa5eb..a2e3aac3 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/168 b/tests/generic/168
index 575ff08c..f45cda58 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/170 b/tests/generic/170
index d323ab8f..1c1fbe2f 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/247 b/tests/generic/247
index becc89e7..d88038c9 100755
--- a/tests/generic/247
+++ b/tests/generic/247
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick rw
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/333 b/tests/generic/333
index bf1967ce..32f90bdd 100755
--- a/tests/generic/333
+++ b/tests/generic/333
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/334 b/tests/generic/334
index b9c14b87..90102295 100755
--- a/tests/generic/334
+++ b/tests/generic/334
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/349 b/tests/generic/349
index da331b95..b879e866 100755
--- a/tests/generic/349
+++ b/tests/generic/349
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest blockdev rw zero
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/scsi_debug
diff --git a/tests/generic/350 b/tests/generic/350
index d8b2f272..4a65bd87 100755
--- a/tests/generic/350
+++ b/tests/generic/350
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest blockdev rw punch
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/scsi_debug
diff --git a/tests/generic/351 b/tests/generic/351
index fb16da16..8f5af94f 100755
--- a/tests/generic/351
+++ b/tests/generic/351
@@ -13,8 +13,6 @@
 . ./common/preamble
 _begin_fstest blockdev rw punch collapse insert zero
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/scsi_debug
diff --git a/tests/generic/356 b/tests/generic/356
index ffc7bed5..d34255e1 100755
--- a/tests/generic/356
+++ b/tests/generic/356
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone swap
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/357 b/tests/generic/357
index ce748f85..359a2530 100755
--- a/tests/generic/357
+++ b/tests/generic/357
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone swap
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/358 b/tests/generic/358
index 8c73ba36..676e93f3 100755
--- a/tests/generic/358
+++ b/tests/generic/358
@@ -13,8 +13,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/359 b/tests/generic/359
index 25692058..76ba7b15 100755
--- a/tests/generic/359
+++ b/tests/generic/359
@@ -15,8 +15,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/372 b/tests/generic/372
index b83aa598..b502c364 100755
--- a/tests/generic/372
+++ b/tests/generic/372
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/373 b/tests/generic/373
index e85308c7..ad4c9d7f 100755
--- a/tests/generic/373
+++ b/tests/generic/373
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/374 b/tests/generic/374
index f66d1397..f6c8bb54 100755
--- a/tests/generic/374
+++ b/tests/generic/374
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone dedupe
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/414 b/tests/generic/414
index 01b9da8e..3dfee41b 100755
--- a/tests/generic/414
+++ b/tests/generic/414
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/425 b/tests/generic/425
index 13a76563..885d99bf 100755
--- a/tests/generic/425
+++ b/tests/generic/425
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick attr
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/553 b/tests/generic/553
index 4a3d3953..884ac0a5 100755
--- a/tests/generic/553
+++ b/tests/generic/553
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick copy_range
 
-_register_cleanup "_cleanup" BUS
-
 workdir="$TEST_DIR/test-$seq"
 # Override the default cleanup function.
 _cleanup()
diff --git a/tests/generic/554 b/tests/generic/554
index b9efee0d..918ee5c6 100755
--- a/tests/generic/554
+++ b/tests/generic/554
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick copy_range swap
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/generic/564 b/tests/generic/564
index 7ed5ccc1..e47c9868 100755
--- a/tests/generic/564
+++ b/tests/generic/564
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick copy_range
 
-_register_cleanup "_cleanup" BUS
-
 # Override the default cleanup function.
 _cleanup()
 {
diff --git a/tests/generic/565 b/tests/generic/565
index fd71d1e3..20e199bf 100755
--- a/tests/generic/565
+++ b/tests/generic/565
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick copy_range
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/generic/670 b/tests/generic/670
index 4a895d90..49e66d90 100755
--- a/tests/generic/670
+++ b/tests/generic/670
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/generic/671 b/tests/generic/671
index b6cc0573..d72bee2c 100755
--- a/tests/generic/671
+++ b/tests/generic/671
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/generic/672 b/tests/generic/672
index 9e3a97ec..dd4870d2 100755
--- a/tests/generic/672
+++ b/tests/generic/672
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto clone
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/017 b/tests/xfs/017
index 14e29b98..514ca198 100755
--- a/tests/xfs/017
+++ b/tests/xfs/017
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest mount auto quick stress
 
-_register_cleanup "_cleanup; rm -f $tmp.*"
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/138 b/tests/xfs/138
index 966ac03a..a5aca080 100755
--- a/tests/xfs/138
+++ b/tests/xfs/138
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 
 # real QA test starts here
diff --git a/tests/xfs/162 b/tests/xfs/162
index 16922ff6..d3c8f72c 100755
--- a/tests/xfs/162
+++ b/tests/xfs/162
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest auto quick attr repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/262 b/tests/xfs/262
index 78db5e34..a36b947a 100755
--- a/tests/xfs/262
+++ b/tests/xfs/262
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/fuzzy
diff --git a/tests/xfs/280 b/tests/xfs/280
index bc26e629..0552009c 100755
--- a/tests/xfs/280
+++ b/tests/xfs/280
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest auto quick clone
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
diff --git a/tests/xfs/285 b/tests/xfs/285
index 711211d4..e1cd18df 100755
--- a/tests/xfs/285
+++ b/tests/xfs/285
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/fuzzy
diff --git a/tests/xfs/286 b/tests/xfs/286
index 7edc9c42..a6fdcde5 100755
--- a/tests/xfs/286
+++ b/tests/xfs/286
@@ -9,8 +9,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/fuzzy
diff --git a/tests/xfs/349 b/tests/xfs/349
index 76745097..058a8e51 100755
--- a/tests/xfs/349
+++ b/tests/xfs/349
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers scrub
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/350 b/tests/xfs/350
index aeb99578..6ffad920 100755
--- a/tests/xfs/350
+++ b/tests/xfs/350
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/351 b/tests/xfs/351
index 74765aea..7fa8b12c 100755
--- a/tests/xfs/351
+++ b/tests/xfs/351
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/352 b/tests/xfs/352
index 49bd85b2..9dbe5275 100755
--- a/tests/xfs/352
+++ b/tests/xfs/352
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/353 b/tests/xfs/353
index b58dc9cb..346066ed 100755
--- a/tests/xfs/353
+++ b/tests/xfs/353
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/354 b/tests/xfs/354
index b10ce1d6..de7eb31d 100755
--- a/tests/xfs/354
+++ b/tests/xfs/354
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/355 b/tests/xfs/355
index 530c9a97..fa523dfd 100755
--- a/tests/xfs/355
+++ b/tests/xfs/355
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/356 b/tests/xfs/356
index 9d5ff251..9293efba 100755
--- a/tests/xfs/356
+++ b/tests/xfs/356
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/357 b/tests/xfs/357
index 8a2c920e..6f285380 100755
--- a/tests/xfs/357
+++ b/tests/xfs/357
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/358 b/tests/xfs/358
index a00eb6f9..d886f59a 100755
--- a/tests/xfs/358
+++ b/tests/xfs/358
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/359 b/tests/xfs/359
index f0a82db4..4851c9c1 100755
--- a/tests/xfs/359
+++ b/tests/xfs/359
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/360 b/tests/xfs/360
index 3942ffd1..6a5e6031 100755
--- a/tests/xfs/360
+++ b/tests/xfs/360
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/361 b/tests/xfs/361
index b7ee0f6f..1934fd69 100755
--- a/tests/xfs/361
+++ b/tests/xfs/361
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/362 b/tests/xfs/362
index f711661b..553ed2f0 100755
--- a/tests/xfs/362
+++ b/tests/xfs/362
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/363 b/tests/xfs/363
index 6be9109e..a556715c 100755
--- a/tests/xfs/363
+++ b/tests/xfs/363
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/364 b/tests/xfs/364
index fcd18fe6..dc283576 100755
--- a/tests/xfs/364
+++ b/tests/xfs/364
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/365 b/tests/xfs/365
index 6f116f9b..0c017f50 100755
--- a/tests/xfs/365
+++ b/tests/xfs/365
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/366 b/tests/xfs/366
index 4c651288..2630ad69 100755
--- a/tests/xfs/366
+++ b/tests/xfs/366
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/367 b/tests/xfs/367
index c474a9e7..bed1106e 100755
--- a/tests/xfs/367
+++ b/tests/xfs/367
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/368 b/tests/xfs/368
index b1c1f976..926497fa 100755
--- a/tests/xfs/368
+++ b/tests/xfs/368
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/369 b/tests/xfs/369
index 5e6d8d9b..5fda356f 100755
--- a/tests/xfs/369
+++ b/tests/xfs/369
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/370 b/tests/xfs/370
index 0a916242..f8dcb39c 100755
--- a/tests/xfs/370
+++ b/tests/xfs/370
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/371 b/tests/xfs/371
index a9b914d9..e9ebce27 100755
--- a/tests/xfs/371
+++ b/tests/xfs/371
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/372 b/tests/xfs/372
index c39a9175..9525f71f 100755
--- a/tests/xfs/372
+++ b/tests/xfs/372
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/373 b/tests/xfs/373
index 324aa9fe..2876e48e 100755
--- a/tests/xfs/373
+++ b/tests/xfs/373
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/374 b/tests/xfs/374
index e3af7e4b..a5e2182b 100755
--- a/tests/xfs/374
+++ b/tests/xfs/374
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/375 b/tests/xfs/375
index cb0efefe..f0db9223 100755
--- a/tests/xfs/375
+++ b/tests/xfs/375
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/376 b/tests/xfs/376
index 2470e1d9..3334bd1e 100755
--- a/tests/xfs/376
+++ b/tests/xfs/376
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/377 b/tests/xfs/377
index eabb03fb..34d15fc3 100755
--- a/tests/xfs/377
+++ b/tests/xfs/377
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/378 b/tests/xfs/378
index c1fb40e6..84722f2e 100755
--- a/tests/xfs/378
+++ b/tests/xfs/378
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/379 b/tests/xfs/379
index 1b5bfa41..ca45b603 100755
--- a/tests/xfs/379
+++ b/tests/xfs/379
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/380 b/tests/xfs/380
index aba8441c..5581ca9a 100755
--- a/tests/xfs/380
+++ b/tests/xfs/380
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/381 b/tests/xfs/381
index ea0c44db..b7124a98 100755
--- a/tests/xfs/381
+++ b/tests/xfs/381
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/382 b/tests/xfs/382
index 6cbc2bcf..f4e92572 100755
--- a/tests/xfs/382
+++ b/tests/xfs/382
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/383 b/tests/xfs/383
index a7875998..d2a99040 100755
--- a/tests/xfs/383
+++ b/tests/xfs/383
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/384 b/tests/xfs/384
index 409dbbf4..f4cd4c82 100755
--- a/tests/xfs/384
+++ b/tests/xfs/384
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/385 b/tests/xfs/385
index 2133d296..c4bf2084 100755
--- a/tests/xfs/385
+++ b/tests/xfs/385
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/386 b/tests/xfs/386
index edeaa9a0..34d6a43d 100755
--- a/tests/xfs/386
+++ b/tests/xfs/386
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/387 b/tests/xfs/387
index cd46f6fc..c4200aa8 100755
--- a/tests/xfs/387
+++ b/tests/xfs/387
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/388 b/tests/xfs/388
index 42e780c8..59866eb3 100755
--- a/tests/xfs/388
+++ b/tests/xfs/388
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/389 b/tests/xfs/389
index 258c5ef0..8dec5595 100755
--- a/tests/xfs/389
+++ b/tests/xfs/389
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/390 b/tests/xfs/390
index c3fecd44..6f2050d6 100755
--- a/tests/xfs/390
+++ b/tests/xfs/390
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/391 b/tests/xfs/391
index f5b90467..9cdc0f5c 100755
--- a/tests/xfs/391
+++ b/tests/xfs/391
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/392 b/tests/xfs/392
index 9044da0c..f746b842 100755
--- a/tests/xfs/392
+++ b/tests/xfs/392
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/393 b/tests/xfs/393
index 700691e1..c0a05b5c 100755
--- a/tests/xfs/393
+++ b/tests/xfs/393
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/394 b/tests/xfs/394
index c9eabcd8..e4d5c3a6 100755
--- a/tests/xfs/394
+++ b/tests/xfs/394
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/395 b/tests/xfs/395
index dcbfb51e..45c42247 100755
--- a/tests/xfs/395
+++ b/tests/xfs/395
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/396 b/tests/xfs/396
index 3209967d..8b9dff61 100755
--- a/tests/xfs/396
+++ b/tests/xfs/396
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/397 b/tests/xfs/397
index ebfd7f63..df7905d2 100755
--- a/tests/xfs/397
+++ b/tests/xfs/397
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/398 b/tests/xfs/398
index 08573f36..34d807c4 100755
--- a/tests/xfs/398
+++ b/tests/xfs/398
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/399 b/tests/xfs/399
index 0a5a0bd5..3f72b0c0 100755
--- a/tests/xfs/399
+++ b/tests/xfs/399
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/400 b/tests/xfs/400
index f85c04cc..f43b785e 100755
--- a/tests/xfs/400
+++ b/tests/xfs/400
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/401 b/tests/xfs/401
index 4c19665e..6c47354d 100755
--- a/tests/xfs/401
+++ b/tests/xfs/401
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/402 b/tests/xfs/402
index f42b6465..87a75888 100755
--- a/tests/xfs/402
+++ b/tests/xfs/402
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/403 b/tests/xfs/403
index 8e7ab07b..6b3a0154 100755
--- a/tests/xfs/403
+++ b/tests/xfs/403
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/404 b/tests/xfs/404
index c0f5c917..54ec36bf 100755
--- a/tests/xfs/404
+++ b/tests/xfs/404
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/405 b/tests/xfs/405
index e33eb8f1..ab5cdbeb 100755
--- a/tests/xfs/405
+++ b/tests/xfs/405
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/406 b/tests/xfs/406
index 78db1807..0adfdf56 100755
--- a/tests/xfs/406
+++ b/tests/xfs/406
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/407 b/tests/xfs/407
index 5a43775b..1c4665ad 100755
--- a/tests/xfs/407
+++ b/tests/xfs/407
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/408 b/tests/xfs/408
index 8049d6be..45ac8b23 100755
--- a/tests/xfs/408
+++ b/tests/xfs/408
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/409 b/tests/xfs/409
index adac95fe..275ef70d 100755
--- a/tests/xfs/409
+++ b/tests/xfs/409
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/410 b/tests/xfs/410
index e98a63eb..8d14de99 100755
--- a/tests/xfs/410
+++ b/tests/xfs/410
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/411 b/tests/xfs/411
index cfe77961..203670ce 100755
--- a/tests/xfs/411
+++ b/tests/xfs/411
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/412 b/tests/xfs/412
index 8b89dd6a..6007846a 100755
--- a/tests/xfs/412
+++ b/tests/xfs/412
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/413 b/tests/xfs/413
index c4b525c2..ceccc803 100755
--- a/tests/xfs/413
+++ b/tests/xfs/413
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/414 b/tests/xfs/414
index ee5db9c8..5db4f4bf 100755
--- a/tests/xfs/414
+++ b/tests/xfs/414
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/415 b/tests/xfs/415
index ab757629..0725b3de 100755
--- a/tests/xfs/415
+++ b/tests/xfs/415
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/416 b/tests/xfs/416
index 3e213068..77b8e789 100755
--- a/tests/xfs/416
+++ b/tests/xfs/416
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/417 b/tests/xfs/417
index 3d09ec7e..68bdd6c2 100755
--- a/tests/xfs/417
+++ b/tests/xfs/417
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/418 b/tests/xfs/418
index c4ba385c..a9b81952 100755
--- a/tests/xfs/418
+++ b/tests/xfs/418
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/422 b/tests/xfs/422
index 77db492e..09125fa8 100755
--- a/tests/xfs/422
+++ b/tests/xfs/422
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/fuzzy
diff --git a/tests/xfs/423 b/tests/xfs/423
index be56f311..b196e0a4 100755
--- a/tests/xfs/423
+++ b/tests/xfs/423
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest dangerous_scrub
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/fuzzy
diff --git a/tests/xfs/425 b/tests/xfs/425
index c2e16ee8..47639543 100755
--- a/tests/xfs/425
+++ b/tests/xfs/425
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/426 b/tests/xfs/426
index e52b15f2..8df30fbd 100755
--- a/tests/xfs/426
+++ b/tests/xfs/426
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/427 b/tests/xfs/427
index 19f45fbd..9ab28e1b 100755
--- a/tests/xfs/427
+++ b/tests/xfs/427
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/428 b/tests/xfs/428
index 338e659d..10fcf3f7 100755
--- a/tests/xfs/428
+++ b/tests/xfs/428
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/429 b/tests/xfs/429
index a4aeb6e4..1a38c574 100755
--- a/tests/xfs/429
+++ b/tests/xfs/429
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/430 b/tests/xfs/430
index d94f65bd..09086810 100755
--- a/tests/xfs/430
+++ b/tests/xfs/430
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/444 b/tests/xfs/444
index 69158f03..ac63ae13 100755
--- a/tests/xfs/444
+++ b/tests/xfs/444
@@ -13,8 +13,6 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-_register_cleanup "_cleanup; rm -f $tmp.*"
-
 # Import common functions.
 . ./common/filter
 
diff --git a/tests/xfs/453 b/tests/xfs/453
index 62974453..d0084508 100755
--- a/tests/xfs/453
+++ b/tests/xfs/453
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/454 b/tests/xfs/454
index 2540cd01..2f84bf67 100755
--- a/tests/xfs/454
+++ b/tests/xfs/454
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/455 b/tests/xfs/455
index 96820bc3..7628030d 100755
--- a/tests/xfs/455
+++ b/tests/xfs/455
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/456 b/tests/xfs/456
index dca03e10..ecc3999d 100755
--- a/tests/xfs/456
+++ b/tests/xfs/456
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/457 b/tests/xfs/457
index 332eeb98..20d7d2f2 100755
--- a/tests/xfs/457
+++ b/tests/xfs/457
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/458 b/tests/xfs/458
index ce03d687..c9ffe967 100755
--- a/tests/xfs/458
+++ b/tests/xfs/458
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/459 b/tests/xfs/459
index d166160f..f980b2c8 100755
--- a/tests/xfs/459
+++ b/tests/xfs/459
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/460 b/tests/xfs/460
index 0daafa30..be2016d3 100755
--- a/tests/xfs/460
+++ b/tests/xfs/460
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/461 b/tests/xfs/461
index 2d20c69d..effb7933 100755
--- a/tests/xfs/461
+++ b/tests/xfs/461
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/462 b/tests/xfs/462
index 587facc0..067bfd6a 100755
--- a/tests/xfs/462
+++ b/tests/xfs/462
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/463 b/tests/xfs/463
index 7270f701..dc197cf4 100755
--- a/tests/xfs/463
+++ b/tests/xfs/463
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/464 b/tests/xfs/464
index 59d25ae1..a0c5766e 100755
--- a/tests/xfs/464
+++ b/tests/xfs/464
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/465 b/tests/xfs/465
index 71399300..095b98f5 100755
--- a/tests/xfs/465
+++ b/tests/xfs/465
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/466 b/tests/xfs/466
index c1a1628a..5d435fa0 100755
--- a/tests/xfs/466
+++ b/tests/xfs/466
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/467 b/tests/xfs/467
index 42b820d1..ecd73223 100755
--- a/tests/xfs/467
+++ b/tests/xfs/467
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/468 b/tests/xfs/468
index 34612c88..58ad0a77 100755
--- a/tests/xfs/468
+++ b/tests/xfs/468
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/469 b/tests/xfs/469
index 630b3329..85aa832e 100755
--- a/tests/xfs/469
+++ b/tests/xfs/469
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/470 b/tests/xfs/470
index acc43ba7..d1285a52 100755
--- a/tests/xfs/470
+++ b/tests/xfs/470
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/471 b/tests/xfs/471
index 7883a00a..a8e29d72 100755
--- a/tests/xfs/471
+++ b/tests/xfs/471
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/472 b/tests/xfs/472
index a4ab9d75..60bee9a5 100755
--- a/tests/xfs/472
+++ b/tests/xfs/472
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/473 b/tests/xfs/473
index cbeed345..4ce19861 100755
--- a/tests/xfs/473
+++ b/tests/xfs/473
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/474 b/tests/xfs/474
index 746e3531..a10edcbb 100755
--- a/tests/xfs/474
+++ b/tests/xfs/474
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/475 b/tests/xfs/475
index 20053afe..2d843b9b 100755
--- a/tests/xfs/475
+++ b/tests/xfs/475
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/476 b/tests/xfs/476
index f8f79e4f..8ff03331 100755
--- a/tests/xfs/476
+++ b/tests/xfs/476
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/477 b/tests/xfs/477
index 0c2e2b36..de12b8df 100755
--- a/tests/xfs/477
+++ b/tests/xfs/477
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/478 b/tests/xfs/478
index 44e42e3e..9d867b12 100755
--- a/tests/xfs/478
+++ b/tests/xfs/478
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/479 b/tests/xfs/479
index 9101d651..ef91f5c2 100755
--- a/tests/xfs/479
+++ b/tests/xfs/479
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/480 b/tests/xfs/480
index 4f3ae6dc..3cc3adbf 100755
--- a/tests/xfs/480
+++ b/tests/xfs/480
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/481 b/tests/xfs/481
index 48c7580c..43a32ce5 100755
--- a/tests/xfs/481
+++ b/tests/xfs/481
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/482 b/tests/xfs/482
index 0192b94c..35e1edc8 100755
--- a/tests/xfs/482
+++ b/tests/xfs/482
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair realtime
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/483 b/tests/xfs/483
index d7b0101a..f4a141cb 100755
--- a/tests/xfs/483
+++ b/tests/xfs/483
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/484 b/tests/xfs/484
index 27522bbd..9284d7fa 100755
--- a/tests/xfs/484
+++ b/tests/xfs/484
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/485 b/tests/xfs/485
index efffbb85..015d93c9 100755
--- a/tests/xfs/485
+++ b/tests/xfs/485
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/486 b/tests/xfs/486
index 6d7f4031..474f05a0 100755
--- a/tests/xfs/486
+++ b/tests/xfs/486
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/487 b/tests/xfs/487
index 337541bb..38909b53 100755
--- a/tests/xfs/487
+++ b/tests/xfs/487
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/488 b/tests/xfs/488
index 43477689..fb1e7e4c 100755
--- a/tests/xfs/488
+++ b/tests/xfs/488
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/489 b/tests/xfs/489
index c70e674c..c1886888 100755
--- a/tests/xfs/489
+++ b/tests/xfs/489
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/495 b/tests/xfs/495
index 8da61f23..d0cc51a5 100755
--- a/tests/xfs/495
+++ b/tests/xfs/495
@@ -12,8 +12,6 @@
 . ./common/preamble
 _begin_fstest auto quick repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/496 b/tests/xfs/496
index a2624d2e..c09e5a75 100755
--- a/tests/xfs/496
+++ b/tests/xfs/496
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/497 b/tests/xfs/497
index 9a985d8c..f16eb5c6 100755
--- a/tests/xfs/497
+++ b/tests/xfs/497
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/498 b/tests/xfs/498
index 20bd326a..4543a5e8 100755
--- a/tests/xfs/498
+++ b/tests/xfs/498
@@ -10,8 +10,6 @@
 . ./common/preamble
 _begin_fstest dangerous_fuzzers dangerous_norepair
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 . ./common/filter
 . ./common/populate
diff --git a/tests/xfs/499 b/tests/xfs/499
index b5597708..34728cf4 100755
--- a/tests/xfs/499
+++ b/tests/xfs/499
@@ -11,8 +11,6 @@
 . ./common/preamble
 _begin_fstest auto quick
 
-_register_cleanup "_cleanup" BUS
-
 # Import common functions.
 
 # real QA test starts here
diff --git a/tests/xfs/503 b/tests/xfs/503
index 9dec0ff0..c23a0dbb 100755
--- a/tests/xfs/503
+++ b/tests/xfs/503
@@ -15,7 +15,7 @@ local_cleanup()
 	rm -rf $testdir
 	_cleanup
 }
-_register_cleanup local_cleanup BUS
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/xfs/507 b/tests/xfs/507
index abd16e38..a180290b 100755
--- a/tests/xfs/507
+++ b/tests/xfs/507
@@ -22,7 +22,7 @@ _loop_cleanup()
 	test -n "$loop_dev" &&_destroy_loop_device $loop_dev
 	_cleanup
 }
-_register_cleanup _loop_cleanup BUS
+_register_cleanup _loop_cleanup
 
 # Import common functions.
 . ./common/reflink
diff --git a/tests/xfs/517 b/tests/xfs/517
index 015a7a5f..bab0efa8 100755
--- a/tests/xfs/517
+++ b/tests/xfs/517
@@ -14,7 +14,7 @@ local_cleanup()
 	$XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT > /dev/null 2>&1
 	_cleanup
 }
-_register_cleanup local_cleanup BUS
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 8/8] fstests: cleanup _cleanup usage in shared
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (6 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 7/8] fstests: Set up BUS trap for tests by default Dave Chinner
@ 2022-05-24  7:34 ` 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
  8 siblings, 2 replies; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  7:34 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

To match the cleanup of tests/xfs

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/shared/002 |  7 ++++---
 tests/shared/298 | 22 +++++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/tests/shared/002 b/tests/shared/002
index d99539c9..0a92dcc2 100755
--- a/tests/shared/002
+++ b/tests/shared/002
@@ -15,12 +15,13 @@
 . ./common/preamble
 _begin_fstest auto metadata quick log
 
-# Override the default cleanup function.
-_cleanup()
+_dmflakey_cleanup()
 {
+	_unmount_flakey
 	_cleanup_flakey
-	rm -f $tmp.*
+	_cleanup
 }
+_register_cleanup _dmflakey_cleanup
 
 # Import common functions.
 . ./common/filter
diff --git a/tests/shared/298 b/tests/shared/298
index bd52b6a0..797ac7a8 100755
--- a/tests/shared/298
+++ b/tests/shared/298
@@ -9,6 +9,17 @@
 . ./common/preamble
 _begin_fstest auto trim
 
+_loop_cleanup()
+{
+	UMOUNT_PROG $loop_dev &> /dev/null
+	_destroy_loop_device $loop_dev
+	if [ $status -eq 0 ]; then
+		rm $img_file
+	fi
+	_cleanup
+}
+_register_cleanup _loop_cleanup
+
 _supported_fs ext4 xfs btrfs
 _require_test
 _require_loop
@@ -27,17 +38,6 @@ fi
 [ "$FSTYP" = "btrfs" ] && _require_btrfs_command inspect-internal dump-super
 [ "$FSTYP" = "btrfs" ] && _require_btrfs_command inspect-internal dump-tree
 
-# Override the default cleanup function.
-_cleanup()
-{
-	$UMOUNT_PROG $loop_dev &> /dev/null
-	_destroy_loop_device $loop_dev
-	if [ $status -eq 0 ]; then
-		rm -rf $tmp
-		rm $img_file
-	fi
-}
-
 get_holes()
 {
 	# It's not a good idea to be running tools against the image file
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
                   ` (7 preceding siblings ...)
  2022-05-24  7:34 ` [PATCH 8/8] fstests: cleanup _cleanup usage in shared Dave Chinner
@ 2022-05-24  8:29 ` Amir Goldstein
  2022-05-24  9:57   ` Dave Chinner
  8 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24  8:29 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

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 $*
 }

 # Prepare to run a fstest by initializing the required global variables to
@@ -46,7 +46,7 @@ _begin_fstest()
        tmp=/tmp/$$
        status=1        # failure is the default!

-       _register_cleanup _cleanup
+       _register_cleanup

        . ./common/rc


It could be a bit weird for tests that call
_register_cleanup _cleanup

But you removed most of those in the SIGBUS patch
and even if they do exists, _cleanup() is re-entrant.


>
> While this looks more verbose, it means we can actually reuse the
> same cleanup function across lots of tests.
>
> A large number of xfsdump tests were all using the same override
> cleanup function to call _cleanup_dump. These are all changed to:
>
> . ./common/dump
> _register_cleanup _cleanup_dump
>
> and _cleanup_dump stacks like this:
>
> _cleanup_dump()
> {
>         #do xfsdump cleanup stuff
>
>         _cleanup
> }
>
> and we don't need to do anything else. There is one xfsdump test
> that needs it's own cleanup. It stacks like this:
>
> local_cleanup()
> {
>         rm -f $testfile
>         _cleanup_dump
> }
> _register_cleanup local_cleanup
>
> All the tests that run fsstress in the background now have a common
> cleanup function that kills fsstress processes defined in
> common/preamble. They just do:
>
> _register_cleanup _cleanup_fsstress
>
> And now every test that puts fsstress in the background behaves
> correctly and kills all the background fsstree processes when
> interrupted.
>
> The conversion is by no means complete. I've named the local cleanup
> functions by what they do so we can go back and derive commonality
> between them. The number of different variations on tearing down
> loops devices is crazy, and half of them are buggy. I haven't worked
> through these yet, so you'll see lots of tests with:
>
> _loop_cleanup()
> {
>         ......
>         _cleanup
> }
> _register_cleanup _loop_cleanup
>
> That have similar but different ways of cleaning up loop devices.
>
> I also added a _no_cleanup() function, as there are a large number
> of xfs fuzzer tests that want to leave a warm corpse behind so that
> debugging what just happened is easy.
>
> I also added BUS to the default signal trap set - well over a 100
> tests in tests/xfs had a line like:
>
> _register_cleanup "_cleanup" BUS
>
> just to add BUS signals to the set that would cause the cleanup
> function to run. Just make it the default!
>
> Overall, this significantly reduces the amount of boiler plate in
> tests, and sets us down the path of common cleanup functions that
> tests may not even need to define. e.g. just including
> ./common/dmflakey registers the _cleanup_dmflakey() trap that will
> do all the necessary cleanup when the test exists. This makes the
> tests simpler, more robust and reduces the maintenance burden of
> over 1700 individual tests....
>
> I won't put the full diffstat in this mail, but the benefits should
> be clean from the summary:
>
> 360 files changed, 420 insertions(+), 1781 deletions(-)
>
> I've lost count of the number of test bugs I killed in removing
> all this code, and that's largely just in the tests/xfs directory.
> So before I go spend another couple of days on converting the rest
> of fstests, I figured I better make sure everyone is OK with these
> changes.
>
> Thoughts, comments?
>

Thank you for taking this on!

Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 7/8] fstests: Set up BUS trap for tests by default
  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
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24  8:48 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 11:08 AM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> About 160 individual tests re-register the cleanup trap just to have
> it run on a BUS error signal. Just add the BUS signal to the default
> set of traps initialised by _register_cleanup() and get rid of these
> extra registrations.
>
> This was mostly done with this script:
>
> $ for f in `git grep -l "register_cleanup.*BUS"` ; do
> > sed -i -e '/_register_cleanup "_cleanup" BUS/,+1d'
> > done
>
> With a small number of non-matching conversions done by hand.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  common/preamble   | 4 ++--
>  tests/ext4/023    | 2 --
>  tests/generic/161 | 2 --
>  tests/generic/162 | 2 --
>  tests/generic/163 | 2 --
>  tests/generic/164 | 2 --
>  tests/generic/165 | 2 --
>  tests/generic/166 | 2 --
>  tests/generic/167 | 2 --
>  tests/generic/168 | 2 --
>  tests/generic/170 | 2 --
>  tests/generic/247 | 2 --
>  tests/generic/333 | 2 --
>  tests/generic/334 | 2 --
>  tests/generic/349 | 2 --
>  tests/generic/350 | 2 --
>  tests/generic/351 | 2 --
>  tests/generic/356 | 2 --
>  tests/generic/357 | 2 --
>  tests/generic/358 | 2 --
>  tests/generic/359 | 2 --
>  tests/generic/372 | 2 --
>  tests/generic/373 | 2 --
>  tests/generic/374 | 2 --
>  tests/generic/414 | 2 --
>  tests/generic/425 | 2 --
>  tests/generic/553 | 2 --
>  tests/generic/554 | 2 --
>  tests/generic/564 | 2 --
>  tests/generic/565 | 2 --
>  tests/generic/670 | 2 --
>  tests/generic/671 | 2 --
>  tests/generic/672 | 2 --
>  tests/xfs/017     | 2 --
>  tests/xfs/138     | 2 --
>  tests/xfs/162     | 2 --
>  tests/xfs/262     | 2 --
>  tests/xfs/280     | 2 --
>  tests/xfs/285     | 2 --
>  tests/xfs/286     | 2 --
>  tests/xfs/349     | 2 --
>  tests/xfs/350     | 2 --
>  tests/xfs/351     | 2 --
>  tests/xfs/352     | 2 --
>  tests/xfs/353     | 2 --
>  tests/xfs/354     | 2 --
>  tests/xfs/355     | 2 --
>  tests/xfs/356     | 2 --
>  tests/xfs/357     | 2 --
>  tests/xfs/358     | 2 --
>  tests/xfs/359     | 2 --
>  tests/xfs/360     | 2 --
>  tests/xfs/361     | 2 --
>  tests/xfs/362     | 2 --
>  tests/xfs/363     | 2 --
>  tests/xfs/364     | 2 --
>  tests/xfs/365     | 2 --
>  tests/xfs/366     | 2 --
>  tests/xfs/367     | 2 --
>  tests/xfs/368     | 2 --
>  tests/xfs/369     | 2 --
>  tests/xfs/370     | 2 --
>  tests/xfs/371     | 2 --
>  tests/xfs/372     | 2 --
>  tests/xfs/373     | 2 --
>  tests/xfs/374     | 2 --
>  tests/xfs/375     | 2 --
>  tests/xfs/376     | 2 --
>  tests/xfs/377     | 2 --
>  tests/xfs/378     | 2 --
>  tests/xfs/379     | 2 --
>  tests/xfs/380     | 2 --
>  tests/xfs/381     | 2 --
>  tests/xfs/382     | 2 --
>  tests/xfs/383     | 2 --
>  tests/xfs/384     | 2 --
>  tests/xfs/385     | 2 --
>  tests/xfs/386     | 2 --
>  tests/xfs/387     | 2 --
>  tests/xfs/388     | 2 --
>  tests/xfs/389     | 2 --
>  tests/xfs/390     | 2 --
>  tests/xfs/391     | 2 --
>  tests/xfs/392     | 2 --
>  tests/xfs/393     | 2 --
>  tests/xfs/394     | 2 --
>  tests/xfs/395     | 2 --
>  tests/xfs/396     | 2 --
>  tests/xfs/397     | 2 --
>  tests/xfs/398     | 2 --
>  tests/xfs/399     | 2 --
>  tests/xfs/400     | 2 --
>  tests/xfs/401     | 2 --
>  tests/xfs/402     | 2 --
>  tests/xfs/403     | 2 --
>  tests/xfs/404     | 2 --
>  tests/xfs/405     | 2 --
>  tests/xfs/406     | 2 --
>  tests/xfs/407     | 2 --
>  tests/xfs/408     | 2 --
>  tests/xfs/409     | 2 --
>  tests/xfs/410     | 2 --
>  tests/xfs/411     | 2 --
>  tests/xfs/412     | 2 --
>  tests/xfs/413     | 2 --
>  tests/xfs/414     | 2 --
>  tests/xfs/415     | 2 --
>  tests/xfs/416     | 2 --
>  tests/xfs/417     | 2 --
>  tests/xfs/418     | 2 --
>  tests/xfs/422     | 2 --
>  tests/xfs/423     | 2 --
>  tests/xfs/425     | 2 --
>  tests/xfs/426     | 2 --
>  tests/xfs/427     | 2 --
>  tests/xfs/428     | 2 --
>  tests/xfs/429     | 2 --
>  tests/xfs/430     | 2 --
>  tests/xfs/444     | 2 --
>  tests/xfs/453     | 2 --
>  tests/xfs/454     | 2 --
>  tests/xfs/455     | 2 --
>  tests/xfs/456     | 2 --
>  tests/xfs/457     | 2 --
>  tests/xfs/458     | 2 --
>  tests/xfs/459     | 2 --
>  tests/xfs/460     | 2 --
>  tests/xfs/461     | 2 --
>  tests/xfs/462     | 2 --
>  tests/xfs/463     | 2 --
>  tests/xfs/464     | 2 --
>  tests/xfs/465     | 2 --
>  tests/xfs/466     | 2 --
>  tests/xfs/467     | 2 --
>  tests/xfs/468     | 2 --
>  tests/xfs/469     | 2 --
>  tests/xfs/470     | 2 --
>  tests/xfs/471     | 2 --
>  tests/xfs/472     | 2 --
>  tests/xfs/473     | 2 --
>  tests/xfs/474     | 2 --
>  tests/xfs/475     | 2 --
>  tests/xfs/476     | 2 --
>  tests/xfs/477     | 2 --
>  tests/xfs/478     | 2 --
>  tests/xfs/479     | 2 --
>  tests/xfs/480     | 2 --
>  tests/xfs/481     | 2 --
>  tests/xfs/482     | 2 --
>  tests/xfs/483     | 2 --
>  tests/xfs/484     | 2 --
>  tests/xfs/485     | 2 --
>  tests/xfs/486     | 2 --
>  tests/xfs/487     | 2 --
>  tests/xfs/488     | 2 --
>  tests/xfs/489     | 2 --
>  tests/xfs/495     | 2 --
>  tests/xfs/496     | 2 --
>  tests/xfs/497     | 2 --
>  tests/xfs/498     | 2 --
>  tests/xfs/499     | 2 --
>  tests/xfs/503     | 2 +-
>  tests/xfs/507     | 2 +-
>  tests/xfs/517     | 2 +-
>  164 files changed, 5 insertions(+), 325 deletions(-)
>

Nice cleanup!

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 4/8] fstests: define a common _dump_cleanup function
  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
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24  9:04 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 11:32 AM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> Almost all xfsdump tests now use the same cleanup function.
> Deduplicate them.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  common/dump   | 53 ++++++++++++++++++++++++++-------------------------
>  tests/xfs/022 | 12 ++----------
>  tests/xfs/023 | 13 ++-----------
>  tests/xfs/024 | 12 ++----------
>  tests/xfs/025 | 12 ++----------
>  tests/xfs/026 | 12 ++----------
>  tests/xfs/027 | 12 ++----------
>  tests/xfs/028 | 12 ++----------
>  tests/xfs/035 | 10 +---------
>  tests/xfs/036 |  9 +--------
>  tests/xfs/037 | 10 +---------
>  tests/xfs/038 |  9 +--------
>  tests/xfs/039 |  9 +--------
>  tests/xfs/043 |  9 +--------
>  tests/xfs/046 |  9 +--------
>  tests/xfs/047 |  9 +--------
>  tests/xfs/055 |  9 +--------
>  tests/xfs/056 | 11 +----------
>  tests/xfs/059 | 12 ++----------
>  tests/xfs/060 | 12 ++----------
>  tests/xfs/061 | 12 ++----------
>  tests/xfs/063 |  9 ++-------
>  tests/xfs/064 |  9 ++-------
>  tests/xfs/065 |  9 ++-------
>  tests/xfs/066 | 11 +++--------
>  tests/xfs/068 | 12 ++----------
>  tests/xfs/266 | 14 +++-----------
>  tests/xfs/267 | 13 +++----------
>  tests/xfs/268 | 12 +++---------
>  tests/xfs/281 |  9 +--------
>  tests/xfs/282 |  9 +--------
>  tests/xfs/283 |  9 +--------
>  tests/xfs/287 | 11 +++--------
>  tests/xfs/296 | 11 ++---------
>  tests/xfs/301 | 11 ++---------
>  tests/xfs/302 | 11 ++---------
>  tests/xfs/544 | 10 ++--------
>  37 files changed, 91 insertions(+), 347 deletions(-)
>

Nice cleanup!

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

See one question below...
[...]

> diff --git a/tests/xfs/026 b/tests/xfs/026
> index 18529003..0daa7c88 100755
> --- a/tests/xfs/026
> +++ b/tests/xfs/026
> @@ -9,17 +9,8 @@
>  . ./common/preamble
>  _begin_fstest dump ioctl auto quick
>
> -status=0       # success is the default!
> -

All those tests that you change from success is the default
to failure is the default, that makes sense, but
1. Should be documented in the commit message?
2. Why were those tests written this way? Do you know?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 1/8] generic/038: kill background threads on interrupt
  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
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24  9:41 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 12:12 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> When I ctrl-c g/038, it either does nothing or it leaves processes
> running in the background. It is not cleaning up it's background
> processes correctly, so add kill vectors into the cleanup. Make sure
> we only kill in the cleanup trap if the background processes are
> running.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  tests/generic/038 | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/tests/generic/038 b/tests/generic/038
> index c6cea94e..0462ea13 100755
> --- a/tests/generic/038
> +++ b/tests/generic/038
> @@ -36,6 +36,10 @@ _begin_fstest auto stress trim
>  # Override the default cleanup function.
>  _cleanup()
>  {
> +       [ -n "${create_pids}" ] && kill ${create_pids[@]}
> +       [ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
> +       [ -n "${trim_pids}" ] && kill ${trim_pids[@]}
> +       wait

Following the pattern of recently fixed generic/019,
Please redirect stderr of kill to /dev/null
and I think we would rather not wait in cleanup callbacks
which could potentially block forever?

>         rm -fr $tmp

I suppose another patch is going to replace that with the proper _cleanup()?
Patches from vger have been VERY slowly trickling into my mailbox.

>  }
>
> @@ -47,6 +51,8 @@ _supported_fs generic
>  _require_scratch
>  _require_xfs_io_command "falloc"
>
> +echo "Silence is golden"
> +
>  # Keep allocating and deallocating 1G of data space with the goal of creating
>  # and deleting 1 block group constantly. The intention is to race with the
>  # fstrim loop below.
> @@ -121,6 +127,7 @@ _scratch_mount
>  _require_fs_space $SCRATCH_MNT $((10 * 1024 * 1024))
>  _require_batched_discard $SCRATCH_MNT
>
> +
>  for ((i = 0; i < $((4 * $LOAD_FACTOR)); i++)); do
>         trim_loop &
>         trim_pids[$i]=$!
> @@ -136,12 +143,9 @@ create_files "foobar"
>  kill ${fallocate_pids[@]}
>  kill ${trim_pids[@]}
>  wait
> +unset create_pids

This one should be moved up to after the wait in  create_files()

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 4/8] fstests: define a common _dump_cleanup function
  2022-05-24  9:04   ` Amir Goldstein
@ 2022-05-24  9:52     ` Dave Chinner
  2022-05-24  9:59       ` Amir Goldstein
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  9:52 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 12:04:36PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 11:32 AM Dave Chinner <david@fromorbit.com> wrote:
> > diff --git a/tests/xfs/026 b/tests/xfs/026
> > index 18529003..0daa7c88 100755
> > --- a/tests/xfs/026
> > +++ b/tests/xfs/026
> > @@ -9,17 +9,8 @@
> >  . ./common/preamble
> >  _begin_fstest dump ioctl auto quick
> >
> > -status=0       # success is the default!
> > -
> 
> All those tests that you change from success is the default
> to failure is the default, that makes sense, but
> 1. Should be documented in the commit message?

I cleaned up a bunch of random stuff like this as I went along. If I
try to document every little change that gets done, I'll be spending
more time on describing the changes than actually doing them. I
don't have the time to rigourously document this stuff - I've got
the time to modify the code, write an overview of the changes and
that's about it.

What does the fstests community want: better test infrastructure or
perfect commits?

> 2. Why were those tests written this way? Do you know?

That's just the pattern that was used by the team that wrote these
dump tests 20-odd years ago. At the time nobody cared that much
about little inconsistencies like this as long as the test failed
when something went wrong. i.e. test works, merge it, move on to the
next thing. 

Now that we have ~1700 tests to maintain, little inconsistencies are
a big deal. That's why I cleaned up the simple ones as I saw them...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  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
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24  9:57 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

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.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 4/8] fstests: define a common _dump_cleanup function
  2022-05-24  9:52     ` Dave Chinner
@ 2022-05-24  9:59       ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24  9:59 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, Luis R. Rodriguez

On Tue, May 24, 2022 at 12:52 PM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 12:04:36PM +0300, Amir Goldstein wrote:
> > On Tue, May 24, 2022 at 11:32 AM Dave Chinner <david@fromorbit.com> wrote:
> > > diff --git a/tests/xfs/026 b/tests/xfs/026
> > > index 18529003..0daa7c88 100755
> > > --- a/tests/xfs/026
> > > +++ b/tests/xfs/026
> > > @@ -9,17 +9,8 @@
> > >  . ./common/preamble
> > >  _begin_fstest dump ioctl auto quick
> > >
> > > -status=0       # success is the default!
> > > -
> >
> > All those tests that you change from success is the default
> > to failure is the default, that makes sense, but
> > 1. Should be documented in the commit message?
>
> I cleaned up a bunch of random stuff like this as I went along. If I
> try to document every little change that gets done, I'll be spending
> more time on describing the changes than actually doing them. I
> don't have the time to rigourously document this stuff - I've got
> the time to modify the code, write an overview of the changes and
> that's about it.
>
> What does the fstests community want: better test infrastructure or
> perfect commits?

The former :)

>
> > 2. Why were those tests written this way? Do you know?
>
> That's just the pattern that was used by the team that wrote these
> dump tests 20-odd years ago. At the time nobody cared that much
> about little inconsistencies like this as long as the test failed
> when something went wrong. i.e. test works, merge it, move on to the
> next thing.
>
> Now that we have ~1700 tests to maintain, little inconsistencies are
> a big deal. That's why I cleaned up the simple ones as I saw them...
>

That's super.
Thank you for that.

The reason I am asking is that with kdevops, we observed
some inconsistencies between xunit reported failures and overall run
success/failure.

I was wondering if tests that initialize status=0 could be the source
of these inconsistencies.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24  9:57   ` Dave Chinner
@ 2022-05-24 10:01     ` Amir Goldstein
  2022-05-24 10:13       ` Dave Chinner
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 10:01 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

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.*?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24 10:01     ` Amir Goldstein
@ 2022-05-24 10:13       ` Dave Chinner
  2022-05-24 12:14         ` Amir Goldstein
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 10:13 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

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

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  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 17:13     ` Zorro Lang
  0 siblings, 2 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 10:42 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

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.

>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  tests/xfs/004     |  7 -------
>  tests/xfs/006     |  7 ++++---
>  tests/xfs/008     |  9 ++-------
>  tests/xfs/009     |  7 -------
>  tests/xfs/009.out |  1 -
>  tests/xfs/010     |  8 --------
>  tests/xfs/011     | 12 +++---------
>  tests/xfs/012     | 10 ++--------
>  tests/xfs/013     |  8 +++-----
>  tests/xfs/014     |  8 +++-----
>  tests/xfs/016     |  9 ---------
>  tests/xfs/016.out |  1 -
>  tests/xfs/017     |  7 -------
>  tests/xfs/019     |  8 --------
>  tests/xfs/019.out |  1 -
>  tests/xfs/020     |  9 ++++-----
>  tests/xfs/021     |  8 --------
>  tests/xfs/021.out |  1 -
>  tests/xfs/022     |  7 +++----
>  tests/xfs/023     |  7 +++----
>  tests/xfs/024     |  7 +++----
>  tests/xfs/025     |  7 +++----
>  tests/xfs/026     |  7 +++----
>  tests/xfs/027     |  7 +++----
>  tests/xfs/028     |  7 +++----
>  tests/xfs/030     |  8 --------
>  tests/xfs/033     |  8 --------
>  tests/xfs/034     |  9 ---------
>  tests/xfs/034.out |  1 -
>  tests/xfs/035     |  6 +++---
>  tests/xfs/036     |  7 +++----
>  tests/xfs/037     |  7 +++----
>  tests/xfs/038     |  7 +++----
>  tests/xfs/039     |  7 +++----
>  tests/xfs/041     |  8 --------
>  tests/xfs/042     |  7 -------
>  tests/xfs/043     |  7 +++----
>  tests/xfs/046     |  7 +++----
>  tests/xfs/047     |  7 +++----
>  tests/xfs/049     | 21 +++++++++------------
>  tests/xfs/050     |  8 --------
>  tests/xfs/051     |  9 ++++-----
>  tests/xfs/052     |  8 --------
>  tests/xfs/055     |  7 +++----
>  tests/xfs/056     |  7 +++----
>  tests/xfs/057     | 16 ++++++++++------
>  tests/xfs/059     |  7 +++----
>  tests/xfs/060     |  7 +++----
>  tests/xfs/061     |  7 +++----
>  tests/xfs/063     |  7 +++----
>  tests/xfs/064     |  7 +++----
>  tests/xfs/065     |  7 +++----
>  tests/xfs/066     |  9 ++++-----
>  tests/xfs/068     |  7 +++----
>  tests/xfs/070     |  7 +++----
>  tests/xfs/071     |  8 --------
>  tests/xfs/072     |  8 --------
>  tests/xfs/073     | 11 +++++------
>  tests/xfs/074     |  8 ++++----
>  tests/xfs/076     |  8 --------
>  tests/xfs/078     |  9 +++------
>  tests/xfs/079     | 11 +++++------
>  tests/xfs/080     |  7 -------
>  tests/xfs/083     |  7 +++----
>  tests/xfs/085     |  7 +++----
>  tests/xfs/086     |  7 +++----
>  tests/xfs/087     |  7 +++----
>  tests/xfs/088     |  7 +++----
>  tests/xfs/089     |  7 +++----
>  tests/xfs/091     |  7 +++----
>  tests/xfs/093     |  7 +++----
>  tests/xfs/097     |  7 +++----
>  tests/xfs/098     |  7 +++----
>  tests/xfs/099     |  7 +++----
>  tests/xfs/100     |  7 +++----
>  tests/xfs/101     |  7 +++----
>  tests/xfs/102     |  7 +++----
>  tests/xfs/105     |  7 +++----
>  tests/xfs/112     |  7 +++----
>  tests/xfs/113     |  7 +++----
>  tests/xfs/117     |  7 +++----
>  tests/xfs/120     |  7 +++----
>  tests/xfs/123     |  7 +++----
>  tests/xfs/124     |  7 +++----
>  tests/xfs/125     |  7 +++----
>  tests/xfs/126     |  7 +++----
>  tests/xfs/129     |  9 ++++-----
>  tests/xfs/130     |  7 +++----
>  tests/xfs/131     |  8 --------
>  tests/xfs/139     |  7 -------
>  tests/xfs/140     |  7 -------
>  tests/xfs/141     | 11 +++++------
>  tests/xfs/148     |  7 +++----
>  tests/xfs/149     | 15 ++++++++-------
>  tests/xfs/152     | 21 +++++++++------------
>  tests/xfs/153     |  8 --------
>  tests/xfs/157     |  8 ++++----
>  tests/xfs/159     |  8 --------
>  tests/xfs/167     |  9 +++++----
>  tests/xfs/169     |  8 --------
>  tests/xfs/177     |  6 +++---
>  tests/xfs/181     | 10 ++++------
>  tests/xfs/185     | 10 +++++-----
>  tests/xfs/188     |  8 --------
>  tests/xfs/189     |  8 +++-----
>  tests/xfs/194     | 12 ------------
>  tests/xfs/195     |  8 +-------
>  tests/xfs/197     |  7 +------
>  tests/xfs/199     |  7 -------
>  tests/xfs/201     |  6 ------
>  tests/xfs/206     | 12 ++++++------
>  tests/xfs/220     |  7 -------
>  tests/xfs/229     |  7 +------
>  tests/xfs/231     |  7 +++----
>  tests/xfs/232     |  7 +++----
>  tests/xfs/234     |  9 ++++-----
>  tests/xfs/236     |  8 --------
>  tests/xfs/237     | 10 +++++-----
>  tests/xfs/239     |  8 ++++----
>  tests/xfs/240     | 10 +++++-----
>  tests/xfs/241     |  8 ++++----
>  tests/xfs/244     |  8 --------
>  tests/xfs/250     |  6 +++---
>  tests/xfs/253     |  9 ---------
>  tests/xfs/259     |  8 +++++---
>  tests/xfs/260     | 11 +----------
>  tests/xfs/261     |  7 -------
>  tests/xfs/264     |  7 +++----
>  tests/xfs/265     |  8 --------
>  tests/xfs/266     |  7 +++----
>  tests/xfs/267     |  7 +++----
>  tests/xfs/268     |  8 +++-----
>  tests/xfs/269     |  7 -------
>  tests/xfs/271     |  8 ++++----
>  tests/xfs/272     |  8 ++++----
>  tests/xfs/273     |  8 ++++----
>  tests/xfs/274     |  8 ++++----
>  tests/xfs/275     |  8 ++++----
>  tests/xfs/276     |  8 ++++----
>  tests/xfs/277     |  9 +++++----
>  tests/xfs/279     |  9 ++++-----
>  tests/xfs/281     |  7 +++----
>  tests/xfs/282     |  7 +++----
>  tests/xfs/283     |  7 +++----
>  tests/xfs/284     | 10 ++++------
>  tests/xfs/287     |  7 +++----
>  tests/xfs/289     | 17 +++++++++--------
>  tests/xfs/296     |  9 ++++-----
>  tests/xfs/299     |  8 --------
>  tests/xfs/301     |  9 ++++-----
>  tests/xfs/302     |  9 ++++-----
>  tests/xfs/309     |  8 --------
>  tests/xfs/310     |  8 +++-----
>  tests/xfs/311     | 10 ++++------
>  tests/xfs/312     |  8 --------
>  tests/xfs/313     |  8 --------
>  tests/xfs/314     |  8 --------
>  tests/xfs/315     |  8 --------
>  tests/xfs/316     |  8 --------
>  tests/xfs/317     |  8 --------
>  tests/xfs/318     |  8 --------
>  tests/xfs/319     |  8 --------
>  tests/xfs/320     |  8 --------
>  tests/xfs/321     |  8 --------
>  tests/xfs/322     |  8 --------
>  tests/xfs/323     |  8 --------
>  tests/xfs/324     |  8 --------
>  tests/xfs/325     |  8 --------
>  tests/xfs/326     |  8 --------
>  tests/xfs/327     |  8 --------
>  tests/xfs/336     |  7 -------
>  tests/xfs/432     |  8 ++++----
>  tests/xfs/438     | 16 ++++++++++------
>  tests/xfs/442     | 10 +++++-----
>  tests/xfs/447     |  7 +++----
>  tests/xfs/501     |  7 +++----
>  tests/xfs/503     | 10 ++++------
>  tests/xfs/507     | 13 +++++--------
>  tests/xfs/511     |  8 --------
>  tests/xfs/512     |  8 +-------
>  tests/xfs/513     | 15 +++++----------
>  tests/xfs/514     | 10 ++++------
>  tests/xfs/515     | 10 ++++------
>  tests/xfs/516     |  7 -------
>  tests/xfs/517     |  9 +++------
>  tests/xfs/520     |  8 --------
>  tests/xfs/521     |  8 ++++----
>  tests/xfs/522     |  7 -------
>  tests/xfs/523     |  7 -------
>  tests/xfs/524     |  8 ++++----
>  tests/xfs/525     |  7 -------
>  tests/xfs/526     |  7 -------
>  tests/xfs/528     |  6 +++---
>  tests/xfs/530     |  6 +++---
>  tests/xfs/542     |  7 ++++---
>  tests/xfs/543     |  7 -------
>  tests/xfs/544     | 11 ++++++++---
>  197 files changed, 477 insertions(+), 1106 deletions(-)
>

Wow! that cleanup is awesome and huge and was very hard to review!

> diff --git a/tests/xfs/004 b/tests/xfs/004
> index f18316b3..f8cfeb6a 100755
> --- a/tests/xfs/004
> +++ b/tests/xfs/004
> @@ -11,13 +11,6 @@ _begin_fstest db auto quick
>
>  status=0
>
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -       _scratch_unmount
> -       rm -f $tmp.*
> -}
> -
>  _populate_scratch()
>  {
>         echo "=== mkfs output ===" >>$seqres.full
> 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().

> +       _cleanup
>  }
>
>  # Import common functions.
> @@ -28,6 +27,8 @@ _require_scratch
>  _require_dm_target error
>  _require_fs_sysfs error/fail_at_unmount
>
> +_register_cleanup _dmerror_cleanup
> +
>  _scratch_mkfs > $seqres.full 2>&1
>  _dmerror_init
>  _dmerror_mount
> 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.

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.

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.

[...]

> 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.

[...]

> 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.

I'd rather keep the local function name local_cleanup
in unclear cases like this one.

Thanks,
Amir.

>  }
> +_register_cleanup local_cleanup
>
>  # Import common functions.
>  . ./common/filter
> --
> 2.35.1
>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 8/8] fstests: cleanup _cleanup usage in shared
  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
  1 sibling, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 10:49 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 1:17 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> To match the cleanup of tests/xfs
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Makes sense.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 8/8] fstests: cleanup _cleanup usage in shared
  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
  1 sibling, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 11:11 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 1:17 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> To match the cleanup of tests/xfs
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  tests/shared/002 |  7 ++++---
>  tests/shared/298 | 22 +++++++++++-----------
>  2 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/tests/shared/002 b/tests/shared/002
> index d99539c9..0a92dcc2 100755
> --- a/tests/shared/002
> +++ b/tests/shared/002
> @@ -15,12 +15,13 @@
>  . ./common/preamble
>  _begin_fstest auto metadata quick log
>
> -# Override the default cleanup function.
> -_cleanup()
> +_dmflakey_cleanup()
>  {
> +       _unmount_flakey
>         _cleanup_flakey

Wait a minute, why was _unmount_flakey() added here?
I see that most dmflakey cleaners do not call unmount_flakey
and it could be for a good reason.
_cleanup_flakey already doesn umount only after doing:

_cleanup_flakey()
{
        # If dmsetup load fails then we need to make sure to do resume here
        # otherwise the umount will hang

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 1/8] generic/038: kill background threads on interrupt
  2022-05-24  9:41   ` Amir Goldstein
@ 2022-05-24 12:10     ` Dave Chinner
  2022-05-24 12:30       ` Amir Goldstein
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 12:10 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 12:41:25PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 12:12 PM Dave Chinner <david@fromorbit.com> wrote:
> >
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > When I ctrl-c g/038, it either does nothing or it leaves processes
> > running in the background. It is not cleaning up it's background
> > processes correctly, so add kill vectors into the cleanup. Make sure
> > we only kill in the cleanup trap if the background processes are
> > running.
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> >  tests/generic/038 | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/tests/generic/038 b/tests/generic/038
> > index c6cea94e..0462ea13 100755
> > --- a/tests/generic/038
> > +++ b/tests/generic/038
> > @@ -36,6 +36,10 @@ _begin_fstest auto stress trim
> >  # Override the default cleanup function.
> >  _cleanup()
> >  {
> > +       [ -n "${create_pids}" ] && kill ${create_pids[@]}
> > +       [ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
> > +       [ -n "${trim_pids}" ] && kill ${trim_pids[@]}
> > +       wait
> 
> Following the pattern of recently fixed generic/019,
> Please redirect stderr of kill to /dev/null

No. Redirecting errors to /dev/null to hide them is poor behaviour
- g/019 does not test if the pids variables are still valid even
though they get unset. Hence the normal exit trap
runs an empty `kill` command which outputs a help message. The
redirect to /dev/null hides this broken behaviour - it's poor,
buggy code, and an example how buggy and broken a lot of the cleanup
code actually is.

The code above will not run kill with an empty pid list, hence it
should not fail when it is run. If it does fail then we've got a
problem that needs to be captured and analysed and so redirecting
that error to /dev/null is exactly the wrong thing to be doing.

> and I think we would rather not wait in cleanup callbacks
> which could potentially block forever?

We do that in many, many tests - that's how we stop the test leaving
background processes running after the test exits. And if it hangs
here waiting on a hung process, then as a developer using this to
find bugs in my code, I really do want the test to hang hard so I
notice it and can capture the failure and analyse it.

Leaving a warm corpse to post-morten is the desired behaviour of a
failed test.

> >         rm -fr $tmp
> 
> I suppose another patch is going to replace that with the proper _cleanup()?
> Patches from vger have been VERY slowly trickling into my mailbox.

Not in this patch series. When I tackle the generic tests I'll
address these bugs. This patch is just fixing broken ctrl-c
behaviour.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24 10:13       ` Dave Chinner
@ 2022-05-24 12:14         ` Amir Goldstein
  2022-05-24 12:28           ` Dave Chinner
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:14 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 6/8] fstests: consolidate no cleanup test setup
  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
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:22 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 2:42 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> Many of the XFS fuzzer tests define a "no cleanup" cleanup function.
> Consolidate this in common/preamble and deduplicate all the tests
> using this setup.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  common/preamble | 9 +++++++++
>  tests/xfs/083   | 5 -----
>  tests/xfs/085   | 5 -----
>  tests/xfs/086   | 5 -----
>  tests/xfs/087   | 5 -----
>  tests/xfs/088   | 5 -----
>  tests/xfs/089   | 5 -----
>  tests/xfs/091   | 5 -----
>  tests/xfs/093   | 5 -----
>  tests/xfs/097   | 5 -----
>  tests/xfs/098   | 5 -----
>  tests/xfs/099   | 5 -----
>  tests/xfs/100   | 5 -----
>  tests/xfs/101   | 5 -----
>  tests/xfs/102   | 5 -----
>  tests/xfs/105   | 5 -----
>  tests/xfs/112   | 5 -----
>  tests/xfs/113   | 5 -----
>  tests/xfs/117   | 5 -----
>  tests/xfs/120   | 5 -----
>  tests/xfs/123   | 5 -----
>  tests/xfs/124   | 5 -----
>  tests/xfs/125   | 5 -----
>  tests/xfs/126   | 5 -----
>  tests/xfs/130   | 5 -----
>  25 files changed, 9 insertions(+), 120 deletions(-)
>

I propose to use a dedicated helper _unregister_cleanup to opt out
of _cleanup and still leave _cleanup implicit for all the rest of the tests,
but I will not stop merging this cleanup on account of this suggestion.
It could be done by a followup cleanup as well, so unless you want to
take my suggestion

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/8] fstests: use a common fsstress cleanup function
  2022-05-24  7:34 ` [PATCH 5/8] fstests: use a common fsstress cleanup function Dave Chinner
@ 2022-05-24 12:25   ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:25 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 2:16 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> Lots of tests now have a common cleanup function for fsstress based
> tests. Define a common cleanup function in common/preamble and
> convert those tests to register it.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Makes sense.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 10:42   ` Amir Goldstein
@ 2022-05-24 12:27     ` Dave Chinner
  2022-05-24 12:55       ` Amir Goldstein
  2022-05-24 17:13     ` Zorro Lang
  1 sibling, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 12:27 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

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

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24 12:14         ` Amir Goldstein
@ 2022-05-24 12:28           ` Dave Chinner
  2022-05-24 12:34             ` Amir Goldstein
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 12:28 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 03:14:39PM +0300, Amir Goldstein wrote:
> 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

Premature optimisation. 

-Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 1/8] generic/038: kill background threads on interrupt
  2022-05-24 12:10     ` Dave Chinner
@ 2022-05-24 12:30       ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:30 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 3:10 PM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 12:41:25PM +0300, Amir Goldstein wrote:
> > On Tue, May 24, 2022 at 12:12 PM Dave Chinner <david@fromorbit.com> wrote:
> > >
> > > From: Dave Chinner <dchinner@redhat.com>
> > >
> > > When I ctrl-c g/038, it either does nothing or it leaves processes
> > > running in the background. It is not cleaning up it's background
> > > processes correctly, so add kill vectors into the cleanup. Make sure
> > > we only kill in the cleanup trap if the background processes are
> > > running.
> > >
> > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > > ---
> > >  tests/generic/038 | 16 ++++++++++------
> > >  1 file changed, 10 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/tests/generic/038 b/tests/generic/038
> > > index c6cea94e..0462ea13 100755
> > > --- a/tests/generic/038
> > > +++ b/tests/generic/038
> > > @@ -36,6 +36,10 @@ _begin_fstest auto stress trim
> > >  # Override the default cleanup function.
> > >  _cleanup()
> > >  {
> > > +       [ -n "${create_pids}" ] && kill ${create_pids[@]}
> > > +       [ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
> > > +       [ -n "${trim_pids}" ] && kill ${trim_pids[@]}
> > > +       wait
> >
> > Following the pattern of recently fixed generic/019,
> > Please redirect stderr of kill to /dev/null
>
> No. Redirecting errors to /dev/null to hide them is poor behaviour
> - g/019 does not test if the pids variables are still valid even
> though they get unset. Hence the normal exit trap
> runs an empty `kill` command which outputs a help message. The
> redirect to /dev/null hides this broken behaviour - it's poor,
> buggy code, and an example how buggy and broken a lot of the cleanup
> code actually is.
>
> The code above will not run kill with an empty pid list, hence it
> should not fail when it is run. If it does fail then we've got a
> problem that needs to be captured and analysed and so redirecting
> that error to /dev/null is exactly the wrong thing to be doing.
>
> > and I think we would rather not wait in cleanup callbacks
> > which could potentially block forever?
>
> We do that in many, many tests - that's how we stop the test leaving

Yes, I've seen that.

> background processes running after the test exits. And if it hangs
> here waiting on a hung process, then as a developer using this to
> find bugs in my code, I really do want the test to hang hard so I
> notice it and can capture the failure and analyse it.

Makes sense to me, but I think the practice for cleanup should be
(like in fsstress_cleanup) to send SIGKILL and wait in case
the processes are ignoring or already handling SIGTERM.

>
> Leaving a warm corpse to post-morten is the desired behaviour of a
> failed test.
>
> > >         rm -fr $tmp
> >
> > I suppose another patch is going to replace that with the proper _cleanup()?
> > Patches from vger have been VERY slowly trickling into my mailbox.
>
> Not in this patch series. When I tackle the generic tests I'll
> address these bugs. This patch is just fixing broken ctrl-c
> behaviour.
>

Great.
So w.r.t this patch there are only minor comments of kill -9
and move unset of create_pids.
Take it or leave it, either way you may add:

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess
  2022-05-24 12:28           ` Dave Chinner
@ 2022-05-24 12:34             ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:34 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 3:28 PM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 03:14:39PM +0300, Amir Goldstein wrote:
> > 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
>
> Premature optimisation.
>

It's not an optimization at all.

The purpose of doing it this way would be to eliminate the human mistakes
(from which you found so many in this work) and create a situation where
_cleanup() is called for all tests, unless the test author really
wants to avoid it.

But anyway, no need to fix everything at one go.
There will still be plenty of ways that a test author can write a
test that does not clean after itself.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 12:27     ` Dave Chinner
@ 2022-05-24 12:55       ` Amir Goldstein
  2022-05-24 13:24         ` Dave Chinner
  0 siblings, 1 reply; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 12:55 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

> > > 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?

I 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.
>

Ah, I missed that.

> > > 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.

Excellent.


>
> > > 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.

I understand. It makes a lot of sense to do that.
It is still VERY confusing that there is a helper _dmhugedisk_cleanup
that SHOULD NOT be used as a trap and a helper _dmhuge_cleanup
that SHOULD be used as a trap, so a better convention is needed.

I suggest that all consolidated helpers for trap will be called
either _cleanup_* (like cleanup_dump) or _*_cleanup (like _fsstress_cleanup)

The problem is that there is no convetion in the common/* helpers.
there are _dmhugedisk_cleanup() _dmerror_cleanup() and there are
_cleanup_dump() _cleanup_delay().

Since you already converted _cleanup_dump() to be a trap trigger itself
it looks like the easier way to go is to have _cleanup_* as the convention
to trap callbacks, which seems like the more clear choice to me.

Hence in this patch that would be _cleanup_dmhugedisk.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 6/8] fstests: consolidate no cleanup test setup
  2022-05-24 12:22   ` Amir Goldstein
@ 2022-05-24 13:07     ` Dave Chinner
  0 siblings, 0 replies; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 13:07 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 03:22:45PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 2:42 PM Dave Chinner <david@fromorbit.com> wrote:
> >
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > Many of the XFS fuzzer tests define a "no cleanup" cleanup function.
> > Consolidate this in common/preamble and deduplicate all the tests
> > using this setup.
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> >  common/preamble | 9 +++++++++
> >  tests/xfs/083   | 5 -----
> >  tests/xfs/085   | 5 -----
> >  tests/xfs/086   | 5 -----
> >  tests/xfs/087   | 5 -----
> >  tests/xfs/088   | 5 -----
> >  tests/xfs/089   | 5 -----
> >  tests/xfs/091   | 5 -----
> >  tests/xfs/093   | 5 -----
> >  tests/xfs/097   | 5 -----
> >  tests/xfs/098   | 5 -----
> >  tests/xfs/099   | 5 -----
> >  tests/xfs/100   | 5 -----
> >  tests/xfs/101   | 5 -----
> >  tests/xfs/102   | 5 -----
> >  tests/xfs/105   | 5 -----
> >  tests/xfs/112   | 5 -----
> >  tests/xfs/113   | 5 -----
> >  tests/xfs/117   | 5 -----
> >  tests/xfs/120   | 5 -----
> >  tests/xfs/123   | 5 -----
> >  tests/xfs/124   | 5 -----
> >  tests/xfs/125   | 5 -----
> >  tests/xfs/126   | 5 -----
> >  tests/xfs/130   | 5 -----
> >  25 files changed, 9 insertions(+), 120 deletions(-)
> >
> 
> I propose to use a dedicated helper _unregister_cleanup to opt out
> of _cleanup and still leave _cleanup implicit for all the rest of the tests,
> but I will not stop merging this cleanup on account of this suggestion.
> It could be done by a followup cleanup as well, so unless you want to
> take my suggestion

Cart before the horse.  There's another 1000 tests I haven't even
looked at yet, and there's still a heap of work to derive
commonality from the remaining 100 xfs tests that have a random
assortment of loop, local, dm, etc cleanup functions.

I'm trying to focus on cleaning up and deduplicating the tests, not
whether there's an exactly optimal API for a specific cleanup
function. Once everything is deduplicated, changing the cleanup API
is a much, much simpler proposition. So that's the first prioirty
and trivialities like "_register_cleanup _no_cleanup" vs
"_unregister_cleanup" aren't even on my radar.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 12:55       ` Amir Goldstein
@ 2022-05-24 13:24         ` Dave Chinner
  2022-05-24 14:17           ` Amir Goldstein
  0 siblings, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 13:24 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 03:55:47PM +0300, Amir Goldstein wrote:
> > > > 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.
> 
> I understand. It makes a lot of sense to do that.
> It is still VERY confusing that there is a helper _dmhugedisk_cleanup
> that SHOULD NOT be used as a trap and a helper _dmhuge_cleanup
> that SHOULD be used as a trap, so a better convention is needed.

I think you missed my point.

_dmhuge_cleanup() is a *temporary name*.

It will *go away* once I've processed the other 1000 tests which
will also classify anything using dmhugedisk with a _dmhuge_cleanup
function. It's a temporary token I can use for further
classification and deduplication, nothing more, nothing less.

> I suggest that all consolidated helpers for trap will be called
> either _cleanup_* (like cleanup_dump) or _*_cleanup (like _fsstress_cleanup)
> 
> The problem is that there is no convetion in the common/* helpers.
> there are _dmhugedisk_cleanup() _dmerror_cleanup() and there are
> _cleanup_dump() _cleanup_delay().

Exactly the reason why I've used simple names and the only
consistency I care about is that I use the same name for the same
subsystem cleanup functions. I can't give them globally consistent
names at this point and because they are temporary tokens I simply
have not tried. I give it a name, copy the function into a register
buffer, and then paste it into any other test that uses the same
subsystem and has the same cleanup requirements.

Once I have all the tests that use dmhugedisk converted to use a
local _dmhuge_cleanup function, I'll derive the commonality from
them, move it into the existing cleanup function for that subsystem,
and register the subsystem cleanup in those tests. _dmhuge_cleanup()
then goes away forever.

Once everythign is deduplicated and common, changing names will be
simple and straight forward. That's when you can argue all you want
over the names of functions and I won't care one bit.

-Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  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
  0 siblings, 2 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 14:17 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 4:24 PM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 03:55:47PM +0300, Amir Goldstein wrote:
> > > > > 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.
> >
> > I understand. It makes a lot of sense to do that.
> > It is still VERY confusing that there is a helper _dmhugedisk_cleanup
> > that SHOULD NOT be used as a trap and a helper _dmhuge_cleanup
> > that SHOULD be used as a trap, so a better convention is needed.
>
> I think you missed my point.
>
> _dmhuge_cleanup() is a *temporary name*.
>
> It will *go away* once I've processed the other 1000 tests which
> will also classify anything using dmhugedisk with a _dmhuge_cleanup
> function. It's a temporary token I can use for further
> classification and deduplication, nothing more, nothing less.
>

Ok if the two confusing names are not going to co-exists I'm fine
with either name.

> > I suggest that all consolidated helpers for trap will be called
> > either _cleanup_* (like cleanup_dump) or _*_cleanup (like _fsstress_cleanup)
> >
> > The problem is that there is no convetion in the common/* helpers.
> > there are _dmhugedisk_cleanup() _dmerror_cleanup() and there are
> > _cleanup_dump() _cleanup_delay().
>
> Exactly the reason why I've used simple names and the only
> consistency I care about is that I use the same name for the same
> subsystem cleanup functions. I can't give them globally consistent
> names at this point and because they are temporary tokens I simply
> have not tried. I give it a name, copy the function into a register
> buffer, and then paste it into any other test that uses the same
> subsystem and has the same cleanup requirements.
>
> Once I have all the tests that use dmhugedisk converted to use a
> local _dmhuge_cleanup function, I'll derive the commonality from
> them, move it into the existing cleanup function for that subsystem,
> and register the subsystem cleanup in those tests. _dmhuge_cleanup()
> then goes away forever.
>
> Once everythign is deduplicated and common, changing names will be
> simple and straight forward. That's when you can argue all you want
> over the names of functions and I won't care one bit.
>

All right, please bear in mind that I try to do this review with as little
nit picking as I can while still doing a professional review, so some
questions need to be raised.
The work you did is huge and impressive and the review is not easy.

Anyway, after fixing the recursive _dmerror_cleanup typo, you may add:

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/8] fstests: _cleanup overrides are messy
  2022-05-24  7:34 ` [PATCH 2/8] fstests: _cleanup overrides are messy Dave Chinner
@ 2022-05-24 16:16   ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-24 16:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 6:39 PM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> Most _cleanup() function overrides look like:
>
> _cleanup()
> {
>         # do something test specific
>         cd /
>         rm -rf $tmp.*
> }
>
> But they often get the last two lines either wrong or omit them.
> These are the lines the common/preamble::_cleanup() define.
>
> The problem here is that we are just overriding the generic _cleanup
> function by redeclaring it after calling _begin_fstest. What we
> should be doing is registering a new local cleanup function that
> calls the generic cleanup function when we have finished the local
> cleanup. i.e.:
>
> _local_cleanup()
> {
>         # do something test specific
>
>         _cleanup
> }
>
> Make _register_cleanup() function to cancel the existing
> cleanup trap and register the new trap function so that local
> cleanups can be done cleanly.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 14:17           ` Amir Goldstein
@ 2022-05-24 16:32             ` Zorro Lang
  2022-05-24 23:34             ` Dave Chinner
  1 sibling, 0 replies; 40+ messages in thread
From: Zorro Lang @ 2022-05-24 16:32 UTC (permalink / raw)
  To: Amir Goldstein, Dave Chinner; +Cc: fstests

On Tue, May 24, 2022 at 05:17:44PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 4:24 PM Dave Chinner <david@fromorbit.com> wrote:
> >
> > On Tue, May 24, 2022 at 03:55:47PM +0300, Amir Goldstein wrote:
> > > > > > 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.
> > >
> > > I understand. It makes a lot of sense to do that.
> > > It is still VERY confusing that there is a helper _dmhugedisk_cleanup
> > > that SHOULD NOT be used as a trap and a helper _dmhuge_cleanup
> > > that SHOULD be used as a trap, so a better convention is needed.
> >
> > I think you missed my point.
> >
> > _dmhuge_cleanup() is a *temporary name*.
> >
> > It will *go away* once I've processed the other 1000 tests which
> > will also classify anything using dmhugedisk with a _dmhuge_cleanup
> > function. It's a temporary token I can use for further
> > classification and deduplication, nothing more, nothing less.
> >
> 
> Ok if the two confusing names are not going to co-exists I'm fine
> with either name.
> 
> > > I suggest that all consolidated helpers for trap will be called
> > > either _cleanup_* (like cleanup_dump) or _*_cleanup (like _fsstress_cleanup)
> > >
> > > The problem is that there is no convetion in the common/* helpers.
> > > there are _dmhugedisk_cleanup() _dmerror_cleanup() and there are
> > > _cleanup_dump() _cleanup_delay().
> >
> > Exactly the reason why I've used simple names and the only
> > consistency I care about is that I use the same name for the same
> > subsystem cleanup functions. I can't give them globally consistent
> > names at this point and because they are temporary tokens I simply
> > have not tried. I give it a name, copy the function into a register
> > buffer, and then paste it into any other test that uses the same
> > subsystem and has the same cleanup requirements.
> >
> > Once I have all the tests that use dmhugedisk converted to use a
> > local _dmhuge_cleanup function, I'll derive the commonality from
> > them, move it into the existing cleanup function for that subsystem,
> > and register the subsystem cleanup in those tests. _dmhuge_cleanup()
> > then goes away forever.
> >
> > Once everythign is deduplicated and common, changing names will be
> > simple and straight forward. That's when you can argue all you want
> > over the names of functions and I won't care one bit.
> >
> 
> All right, please bear in mind that I try to do this review with as little
> nit picking as I can while still doing a professional review, so some
> questions need to be raised.
> The work you did is huge and impressive and the review is not easy.

Thanks Dave and Amir!

Dave did a huge and impressive change again:) The purpose of this change makes
sense to me, so there's not objections from me. But it really changed too many
cases, and are going to change more. So if anyone has any concern, please show
your review points as early as better. Thanks.

Really appreciate Amir's help, I was bothered by COVID-19 issues during the day,
just got time to read emails. You did give it a careful review line by line,
and asked lots of questions (than I thought) :) That helps a lot! Compare with
"it's fine but not perfect", I care about "it won't break any cases" more.
So if Dave can force on his main work, keep the code stable, we can do later
improvement bit by bit. As you can see, this patchset nearly affect the
whole fstests, more time we take to change it, more patch conflicts might
happen. Then Dave might need to do more 'rebase' jobs.

I'll give it lots of testing (although I'm sure Dave did test) before merging.
I'll try to help it catch the fstests release of this week. But that depends
on when we have the lastest version, and how stable this patchset is :)

Thanks,
Zorro

> 
> Anyway, after fixing the recursive _dmerror_cleanup typo, you may add:
> 
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> 
> Thanks,
> Amir.
> 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 10:42   ` Amir Goldstein
  2022-05-24 12:27     ` Dave Chinner
@ 2022-05-24 17:13     ` Zorro Lang
  2022-05-26 15:04       ` Zorro Lang
  1 sibling, 1 reply; 40+ messages in thread
From: Zorro Lang @ 2022-05-24 17:13 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Dave Chinner, fstests

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.
> 
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> >  tests/xfs/004     |  7 -------
> >  tests/xfs/006     |  7 ++++---

[snap]

> > 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.

Yes, but this _dmerror_cleanup() won't be run. This function will be covered by
the _dmerror_cleanup() in common/dmerror, when this case ". ./common/dmerror"
several lines later. So the later _cleanup won't be run. So this place and other
places similar with this need to change.

Thanks,
Zorro

> Again, if the call to _cleanup is implicitly chained then
> the local function is not needed and trap can call
> the global _dmerror_cleanup().
> 
> > +       _cleanup
> >  }
> >
> >  # Import common functions.
> > @@ -28,6 +27,8 @@ _require_scratch
> >  _require_dm_target error
> >  _require_fs_sysfs error/fail_at_unmount
> >
> > +_register_cleanup _dmerror_cleanup
> > +
> >  _scratch_mkfs > $seqres.full 2>&1
> >  _dmerror_init
> >  _dmerror_mount
> > 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.
> 
> 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.
> 
> 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.
> 
> [...]
> 
> > 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.
> 
> [...]
> 
> > 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.
> 
> I'd rather keep the local function name local_cleanup
> in unclear cases like this one.
> 
> Thanks,
> Amir.
> 
> >  }
> > +_register_cleanup local_cleanup
> >
> >  # Import common functions.
> >  . ./common/filter
> > --
> > 2.35.1
> >
> 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  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
  1 sibling, 1 reply; 40+ messages in thread
From: Dave Chinner @ 2022-05-24 23:34 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests

On Tue, May 24, 2022 at 05:17:44PM +0300, Amir Goldstein wrote:
> On Tue, May 24, 2022 at 4:24 PM Dave Chinner <david@fromorbit.com> wrote:
> > On Tue, May 24, 2022 at 03:55:47PM +0300, Amir Goldstein wrote:
> The work you did is huge and impressive and the review is not easy.

I disagree - it's not huge or impressive, it's just 4 hours of
*basic grunt work*. It's not difficult, it's not complex, it's just
time consuming. *Anyone* can do this.

The problem fstests has is *nobody* is doing these sorts of
maintenance tasks. We keep adding more tests and with them mountains
of technical debt, yet nobody wants to take any responsibility for
addressing the technical debt.

I'm doing this because over the past year auto group runtimes on my
test machines have increased by about 40%. What took a little over 2
hours is now taking 3.5 hours on the same machines running on the
same hardware with the same VM configs. That's not sustainable - we
have to address the problems that ever increasing number of tests is
causing, otherwise fstests slowly loses it's utility for filesysetm
developers. Iteration speed is everything when developing new code,
and fstests runtime is now my biggest impediment to ongoing
productivity.

Everyone should be looking to improve fstests infrastructure and
address tests that take too long on their systems. I've haven't got
to that yet, but about a dozen tests are now responsible for 30% of
the total auto group runtime. Those tests need to be refined so they
don't take 5-10 minutes to run each - they need to be adjusted to
work with TIME_FACTOR and/or LOAD_FACTOR so that they run in a
minute on normal tests and can then run for long times/under high
load when asked to do so with TIME_FACTOR/LOAD_FACTOR.

This is the day-to-day maintenance stuff that just isn't getting
done. Creating new tests is all well and good, but they don't come
for free. As the test count goes up, everyone needs to do their
little bit to streamline the way tests run. Otherwise we just end up
where we are now with ongoing runtime creep and no easy way to
address it.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 23:34             ` Dave Chinner
@ 2022-05-25  2:54               ` Amir Goldstein
  0 siblings, 0 replies; 40+ messages in thread
From: Amir Goldstein @ 2022-05-25  2:54 UTC (permalink / raw)
  To: Dave Chinner
  Cc: fstests, Theodore Tso, Josef Bacik, Chris Mason, Darrick J. Wong,
	Luis R. Rodriguez

On Wed, May 25, 2022 at 2:34 AM Dave Chinner <david@fromorbit.com> wrote:
>
> On Tue, May 24, 2022 at 05:17:44PM +0300, Amir Goldstein wrote:
> > On Tue, May 24, 2022 at 4:24 PM Dave Chinner <david@fromorbit.com> wrote:
> > > On Tue, May 24, 2022 at 03:55:47PM +0300, Amir Goldstein wrote:
> > The work you did is huge and impressive and the review is not easy.
>
> I disagree - it's not huge or impressive, it's just 4 hours of
> *basic grunt work*. It's not difficult, it's not complex, it's just
> time consuming. *Anyone* can do this.
>
> The problem fstests has is *nobody* is doing these sorts of
> maintenance tasks. We keep adding more tests and with them mountains
> of technical debt, yet nobody wants to take any responsibility for
> addressing the technical debt.
>

Well said.

And it is a sad reality that xfs maintainers are the ones having to clean up
the mess. I'd imagine the xfs maintainer's pile is large enough as it is...

It doesn't have to be this way.
I have said it in LSFMM in "Maintainers don't scale" session lead by Josef
(who stood in for Darrick) - Tech companies have many filesystem developers
on the payroll. They also contribute resources to KernelCI and LTP.
I think it is a matter of communicating to our managers that full/part time
fstests developers on the payroll are a good way to meet their goals.

Coming from fstests, when I first started working with LTP (for fanotify tests)
I was amazed by the different experience:
- Several LTP developers constantly working to improve the infrastructure
- LTP developers reviewing merging and later improving the tests that you post
- At some point, I saw a statement encouraging kernel developers to post
   reproducer in any form they see fit and the LTP developers will make it
   into an LTP test

Good will of developers and weekend projects can only get us so far.
If we want fstests to scale as a project, we need to nudge our managers
to allocate headcount for dedicated fstests work.

For that matter, I also consider the work on "fstests runners'' (i.e.
fstests-bld
and kdevops) as "fstests work", because making fstest more accessible
to a wide audience will encourage more people to improve fstests itself.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-24 17:13     ` Zorro Lang
@ 2022-05-26 15:04       ` Zorro Lang
  2022-05-26 23:39         ` Dave Chinner
  0 siblings, 1 reply; 40+ messages in thread
From: Zorro Lang @ 2022-05-26 15:04 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Wed, May 25, 2022 at 01:13:36AM +0800, Zorro Lang wrote:
> 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.
> > 
> > >
> > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > > ---
> > >  tests/xfs/004     |  7 -------
> > >  tests/xfs/006     |  7 ++++---
> 
> [snap]
> 
> > > 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.
> 
> Yes, but this _dmerror_cleanup() won't be run. This function will be covered by
> the _dmerror_cleanup() in common/dmerror, when this case ". ./common/dmerror"
> several lines later. So the later _cleanup won't be run. So this place and other
> places similar with this need to change.

Hi Dave,

Are you going to fix this issue or making more changes on this patchset?
If not, I'll merge this patchset tomorrow (Friday) by changing above
_dmerror_cleanup to _dm_error_cleanup. Then give merged patches a regression
on Saturday. What do you think?

Thanks,
Zorro

> 
> Thanks,
> Zorro
> 
> > Again, if the call to _cleanup is implicitly chained then
> > the local function is not needed and trap can call
> > the global _dmerror_cleanup().
> > 
> > > +       _cleanup
> > >  }
> > >
> > >  # Import common functions.
> > > @@ -28,6 +27,8 @@ _require_scratch
> > >  _require_dm_target error
> > >  _require_fs_sysfs error/fail_at_unmount
> > >
> > > +_register_cleanup _dmerror_cleanup
> > > +
> > >  _scratch_mkfs > $seqres.full 2>&1
> > >  _dmerror_init
> > >  _dmerror_mount
> > > 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.
> > 
> > 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.
> > 
> > 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.
> > 
> > [...]
> > 
> > > 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.
> > 
> > [...]
> > 
> > > 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.
> > 
> > I'd rather keep the local function name local_cleanup
> > in unclear cases like this one.
> > 
> > Thanks,
> > Amir.
> > 
> > >  }
> > > +_register_cleanup local_cleanup
> > >
> > >  # Import common functions.
> > >  . ./common/filter
> > > --
> > > 2.35.1
> > >
> > 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/8] xfs/*: clean up _cleanup override
  2022-05-26 15:04       ` Zorro Lang
@ 2022-05-26 23:39         ` Dave Chinner
  0 siblings, 0 replies; 40+ messages in thread
From: Dave Chinner @ 2022-05-26 23:39 UTC (permalink / raw)
  To: Zorro Lang; +Cc: fstests

On Thu, May 26, 2022 at 11:04:17PM +0800, Zorro Lang wrote:
> On Wed, May 25, 2022 at 01:13:36AM +0800, Zorro Lang wrote:
> > 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.
> > > 
> > > >
> > > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > > > ---
> > > >  tests/xfs/004     |  7 -------
> > > >  tests/xfs/006     |  7 ++++---
> > 
> > [snap]
> > 
> > > > 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.
> > 
> > Yes, but this _dmerror_cleanup() won't be run. This function will be covered by
> > the _dmerror_cleanup() in common/dmerror, when this case ". ./common/dmerror"
> > several lines later. So the later _cleanup won't be run. So this place and other
> > places similar with this need to change.
> 
> Hi Dave,
> 
> Are you going to fix this issue or making more changes on this patchset?
> If not, I'll merge this patchset tomorrow (Friday) by changing above
> _dmerror_cleanup to _dm_error_cleanup. Then give merged patches a regression
> on Saturday. What do you think?

I posted this patchset as an RFC, not as a candidate for merging.
It's not ready for merging yet.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2022-05-26 23:39 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-05-24 12:28           ` Dave Chinner
2022-05-24 12:34             ` Amir Goldstein

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.