Skip to contentSkip to conversation

fstests: _cleanup() overrides are a mess

RFC PATCH In review Dave Chinner 3 participants 40 messages May 24, 2022 – May 26, 2022

lore
Share & tools
lore
#0 lore raw

cover fstests: _cleanup() overrides are a mess

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.

#1 lore raw

PATCH 1/8 generic/038: kill background threads on interrupt

From: Dave Chinner <[email protected]>

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.

---
 tests/generic/038 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tests/generic/038 +10 -6
index c6cea94e..0462ea13 100755
@@ -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
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH 1/8] generic/038: kill background threads on interrupt

Quoted 19 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 tests/generic/038 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tests/generic/038 +0 -0
index c6cea94e..0462ea13 100755

tests/generic/038 _begin_fstest auto stress trim · line 42

Quoted 7 lines
tests/generic/038 +4 -0
@@ -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?

tests/generic/038 _begin_fstest auto stress trim · line 43

Quoted 1 line
tests/generic/038 +0 -0
        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.

Quoted 20 lines
tests/generic/038 +3 -0
 }
 
@@ -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]=$!

tests/generic/038 create_files "foobar" · line 146

Quoted 4 lines
tests/generic/038 +1 -0
@@ -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.

#3 lore raw

Re: [PATCH 1/8] generic/038: kill background threads on interrupt

Quoted 15 lines · Amir Goldstein
Quoted 14 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 tests/generic/038 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
Quoted 15 lines

tests/generic/038 _begin_fstest auto stress trim · line 42

Quoted 12 lines
tests/generic/038 +4 -0
index c6cea94e..0462ea13 100755
@@ -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.

Quoted 2 lines

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.

Quoted 4 lines

tests/generic/038 _begin_fstest auto stress trim · line 43

Quoted 1 line
tests/generic/038 +0 -0
        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.

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by
#4 lore raw

Re: [PATCH 1/8] generic/038: kill background threads on interrupt

Quoted 46 lines · Dave Chinner
Quoted 15 lines · Amir Goldstein
Quoted 14 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 tests/generic/038 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
Quoted 15 lines

tests/generic/038 _begin_fstest auto stress trim · line 42

Quoted 12 lines
tests/generic/038 +4 -0
index c6cea94e..0462ea13 100755
@@ -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.

Quoted 4 lines
Quoted 2 lines

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.

Quoted 4 lines

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.

Quoted 4 lines

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

Quoted 9 lines
Quoted 4 lines

tests/generic/038 _begin_fstest auto stress trim · line 43

Quoted 1 line
tests/generic/038 +0 -0
        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:

Thanks,
Amir.

#5 lore raw

PATCH 2/8 fstests: _cleanup overrides are messy

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 common/preamble | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/preamble +6 -1
index e60cd949..7aa55dc6 100644
@@ -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 $*
 }
Signature · 1 line
2.35.1
Reviewed-by on v1 2/8
#6 lore raw

Re: [PATCH 2/8] fstests: _cleanup overrides are messy

Quoted 25 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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
Quoted 8 lines

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

Thanks,
Amir.

#7 lore raw

PATCH 3/8 xfs/*: clean up _cleanup override

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 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(-)
tests/xfs/004 +0 -7
index f18316b3..f8cfeb6a 100755
@@ -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
tests/xfs/006 +4 -3
index cecceaa3..fd8d8071 100755
@@ -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
tests/xfs/008 +2 -7
index a53f6c92..5bef44bb 100755
@@ -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
tests/xfs/009 +0 -7
index 54270243..186ba5b3 100755
@@ -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"
tests/xfs/009.out +0 -1
index 02b5d82a..596c686f 100644
@@ -111,4 +111,3 @@ filesize = 500
         [ofs,count]: start..end
         [0,1000]: BLOCKRANGE
 filesize = 500
-*** unmount
tests/xfs/010 +0 -8
index 16c08b85..bdca950c 100755
@@ -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
tests/xfs/011 +3 -9
index d6e9099e..161f263c 100755
@@ -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
tests/xfs/012 +2 -8
index 5ebc9058..c5569f6d 100755
@@ -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
 
tests/xfs/013 +3 -5
index 2d005753..c451ded3 100755
@@ -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'
tests/xfs/014 +3 -5
index 1f0ebac3..1e099df6 100755
@@ -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
tests/xfs/016 +0 -9
index 6337bb1f..04c7ce95 100755
@@ -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'
tests/xfs/016.out +0 -1
index f4c8f88d..7c2bd144 100644
@@ -117,4 +117,3 @@ Wrote 51200.00Kb (value 0xc6)
    *** fiddle
    *** unmount
 *** check for corruption
-*** unmount
tests/xfs/017 +0 -7
index 8a20e592..14e29b98 100755
@@ -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
 
tests/xfs/019 +0 -8
index 790a6821..9aa02f22 100755
@@ -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
tests/xfs/019.out +0 -1
index 9db157f9..65a0d8b2 100644
@@ -90,4 +90,3 @@ Device: <DEVICE> Inode: <INODE> Links: 1
 Device: <DEVICE> Inode: <INODE> Links: 1 
 *** unmount FS
 *** done
-*** unmount
tests/xfs/020 +4 -5
index d6ee3a15..6e2deb6b 100755
@@ -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
tests/xfs/021 +0 -8
index 9432e2ac..eed7fa49 100755
@@ -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
tests/xfs/021.out +0 -1
index aea4a605..3b9d6e87 100644
@@ -54,4 +54,3 @@ nvlist[2].namelen = 7
 nvlist[2].name = "a2-----"
 nvlist[2].value = "value_2\d"
 *** done
-*** unmount
tests/xfs/022 +3 -4
index 2f011b28..e9310365 100755
@@ -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
 
tests/xfs/023 +3 -4
index f6f6503a..1019831d 100755
@@ -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
tests/xfs/024 +3 -4
index 83a8882c..dcb6b9fc 100755
@@ -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
tests/xfs/025 +3 -4
index bafe82d7..dd3c8588 100755
@@ -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
tests/xfs/026 +3 -4
index fba385dc..18529003 100755
@@ -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
tests/xfs/027 +3 -4
index 16cd203d..df6ee2ac 100755
@@ -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
tests/xfs/028 +3 -4
index 1ff9d7d2..d0518317 100755
@@ -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
tests/xfs/030 +0 -8
index 201a9015..617a34e3 100755
@@ -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
tests/xfs/033 +0 -8
index d47da0d6..06c4c100 100755
@@ -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
tests/xfs/034 +0 -9
index 52b0a5f7..5625631c 100755
@@ -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
 
tests/xfs/034.out +0 -1
index b307447d..040d3b97 100644
@@ -2,4 +2,3 @@ QA output created by 034
 *** init FS
 *** test
 *** done
-*** unmount
tests/xfs/035 +3 -3
index f100bb18..6461884b 100755
@@ -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
tests/xfs/036 +3 -4
index 73eb7cd5..becbc83c 100755
@@ -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
tests/xfs/037 +3 -4
index b19ba9e9..0cbd0b16 100755
@@ -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
tests/xfs/038 +3 -4
index 397c354d..da5507af 100755
@@ -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
tests/xfs/039 +3 -4
index d54e9975..69a1092d 100755
@@ -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
tests/xfs/041 +0 -8
index 05de5578..8e584643 100755
@@ -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
 
tests/xfs/042 +0 -7
index d62eb045..8af43671 100755
@@ -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
 
tests/xfs/043 +3 -4
index 415ed16e..7ce74539 100755
@@ -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
tests/xfs/046 +3 -4
index 48daff87..3ac4a180 100755
@@ -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
tests/xfs/047 +3 -4
index 6d0dc5f7..c2f66e31 100755
@@ -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
tests/xfs/049 +9 -12
index 69656a85..fec99386 100755
@@ -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
tests/xfs/050 +0 -8
index 2220e470..a020543a 100755
@@ -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
 
tests/xfs/051 +4 -5
index ea70cb50..4718099d 100755
@@ -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
tests/xfs/052 +0 -8
index 75761022..c8409574 100755
@@ -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
 
tests/xfs/055 +3 -4
index c6ecae3d..d663bfab 100755
@@ -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
tests/xfs/056 +3 -4
index f742f419..7a4b2423 100755
@@ -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
tests/xfs/057 +10 -6
index 9fb3f406..983479ab 100755
@@ -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
tests/xfs/059 +3 -4
index 515ef2a4..9428a9da 100755
@@ -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
tests/xfs/060 +3 -4
index 0c0dc981..b5939f67 100755
@@ -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
tests/xfs/061 +3 -4
index 0b20cc30..dcaac20c 100755
@@ -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
tests/xfs/063 +3 -4
index 660b300f..9193745a 100755
@@ -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
tests/xfs/064 +3 -4
index a81b226b..e332daee 100755
@@ -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
tests/xfs/065 +3 -4
index 8485dee6..9b31ff34 100755
@@ -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
tests/xfs/066 +4 -5
index 2c369ad7..22eb10cc 100755
@@ -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
tests/xfs/068 +3 -4
index f80b53e5..ed281881 100755
@@ -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
 
tests/xfs/070 +3 -4
index 43ca7f84..b9839597 100755
@@ -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
tests/xfs/071 +0 -8
index 8373878a..b43deb75 100755
@@ -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
 
tests/xfs/072 +0 -8
index 54c1207c..196c4df1 100755
@@ -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
 
tests/xfs/073 +5 -6
index c7616b9e..f44687c4 100755
@@ -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()
 {
tests/xfs/074 +4 -4
index f27700ee..cf8dd244 100755
@@ -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
tests/xfs/076 +0 -8
index 8eef1367..09fea1d6 100755
@@ -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
tests/xfs/078 +3 -6
index 1f475c96..dbd9af5b 100755
@@ -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
tests/xfs/079 +5 -6
index dd5dbd35..fc30181b 100755
@@ -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
tests/xfs/080 +0 -7
index 20b20a08..3cf5f7ff 100755
@@ -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
 
tests/xfs/083 +3 -4
index a9acc9f5..7666d204 100755
@@ -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
tests/xfs/085 +3 -4
index dc82f28d..8aa8f2a0 100755
@@ -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
tests/xfs/086 +3 -4
index c8c6d86e..031cb445 100755
@@ -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
tests/xfs/087 +3 -4
index f7cae328..9d1f59f0 100755
@@ -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
tests/xfs/088 +3 -4
index 156c6669..de824223 100755
@@ -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
tests/xfs/089 +3 -4
index ae8f6564..dae2d0d0 100755
@@ -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
tests/xfs/091 +3 -4
index 85c881ae..c5db3337 100755
@@ -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
tests/xfs/093 +3 -4
index 04b09e85..9fe1799a 100755
@@ -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
tests/xfs/097 +3 -4
index 4cad7216..d66df458 100755
@@ -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
tests/xfs/098 +3 -4
index 1e60271f..21215ee5 100755
@@ -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
tests/xfs/099 +3 -4
index a7eaff6e..2791e2df 100755
@@ -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
tests/xfs/100 +3 -4
index 79da8cb0..e71e760e 100755
@@ -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
tests/xfs/101 +3 -4
index 64f4705a..1cbcc973 100755
@@ -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
tests/xfs/102 +3 -4
index 24dce430..0ce3588a 100755
@@ -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
tests/xfs/105 +3 -4
index 22a8bf9f..8a583da5 100755
@@ -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
tests/xfs/112 +3 -4
index bc1ab628..4362f31c 100755
@@ -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
tests/xfs/113 +3 -4
index e820ed96..e3f4fd4d 100755
@@ -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
tests/xfs/117 +3 -4
index e4195d9b..4962c201 100755
@@ -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
tests/xfs/120 +3 -4
index 0a4d72a0..653948ee 100755
@@ -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
tests/xfs/123 +3 -4
index 81f39b96..e191623a 100755
@@ -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
tests/xfs/124 +3 -4
index 39307218..af738212 100755
@@ -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
tests/xfs/125 +3 -4
index fb5f5695..a7280e2c 100755
@@ -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
tests/xfs/126 +3 -4
index c3a74b1c..55a12178 100755
@@ -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
tests/xfs/129 +4 -5
index 90887d54..ea284049 100755
@@ -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
tests/xfs/130 +3 -4
index 9465cbb0..e7a0e6e3 100755
@@ -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
tests/xfs/131 +0 -8
index 879e2dc6..57848564 100755
@@ -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
tests/xfs/139 +0 -7
index 118930a5..96dce077 100755
@@ -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
tests/xfs/140 +0 -7
index ba7694c3..5b51f540 100755
@@ -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
tests/xfs/141 +5 -6
index d9b2474d..0b0cac81 100755
@@ -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
tests/xfs/148 +3 -4
index 5d0a0bf4..ce829e20 100755
@@ -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
tests/xfs/149 +8 -7
index 503eff65..82ff6093 100755
@@ -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
tests/xfs/152 +9 -12
index dd33801d..bb136d7c 100755
@@ -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
tests/xfs/153 +0 -8
index dbe26b68..bb9295c0 100755
@@ -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
 
tests/xfs/157 +4 -4
index 8222d7ee..17b162f3 100755
@@ -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
tests/xfs/159 +0 -8
index eaee590e..709baa2e 100755
@@ -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
tests/xfs/167 +5 -4
index 5f985010..50d3c41b 100755
@@ -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()
 {
tests/xfs/169 +0 -8
index 7ea5af99..84ad7db4 100755
@@ -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
tests/xfs/177 +3 -3
index 10891550..0179e37a 100755
@@ -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
tests/xfs/181 +4 -6
index a399ae5a..b6f9760b 100755
@@ -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"
tests/xfs/185 +5 -5
index f0e87642..d46bd4bf 100755
@@ -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
tests/xfs/188 +0 -8
index d40e4123..3111d41b 100755
@@ -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
 
tests/xfs/189 +3 -5
index e601881a..82c94145 100755
@@ -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()
 {
tests/xfs/194 +0 -12
index 5a1dff5d..15739c87 100755
@@ -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
 
tests/xfs/195 +1 -7
index 3e388142..65d68b47 100755
@@ -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`
tests/xfs/197 +1 -6
index 109bf478..9e5c63d3 100755
@@ -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;
tests/xfs/199 +0 -7
index 4669f2c3..0485a904 100755
@@ -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
 
tests/xfs/201 +0 -6
index b9f2aab1..101134e8 100755
@@ -12,12 +12,6 @@
 . ./common/preamble
 _begin_fstest metadata auto quick
 
-# Override the default cleanup function.
-_cleanup()
-{
-	_scratch_unmount
-}
-
 # Import common functions.
 . ./common/filter
 
tests/xfs/206 +6 -6
index cb346b6d..71f07be8 100755
@@ -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
tests/xfs/220 +0 -7
index 88eedf51..9b6c3d0b 100755
@@ -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
tests/xfs/229 +1 -6
index 2221b9c4..a6ce97f1 100755
@@ -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
tests/xfs/231 +3 -4
index 8155d0ab..179131ea 100755
@@ -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
tests/xfs/232 +3 -4
index 06217466..a96502a7 100755
@@ -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
tests/xfs/234 +4 -5
index 6ff2f228..f1c3222e 100755
@@ -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
tests/xfs/236 +0 -8
index a66ea2d5..4d23b500 100755
@@ -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
 
tests/xfs/237 +5 -5
index 34d54a6c..46d72d08 100755
@@ -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
tests/xfs/239 +4 -4
index 5143cc2e..bead5d51 100755
@@ -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
tests/xfs/240 +5 -5
index e5d35a83..94b1a36d 100755
@@ -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
tests/xfs/241 +4 -4
index 7988c2d8..17e41618 100755
@@ -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
tests/xfs/244 +0 -8
index 28f1328a..f33f6ecd 100755
@@ -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
tests/xfs/250 +3 -3
index 8af32711..2575959e 100755
@@ -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
tests/xfs/253 +0 -9
index 1899ce52..884d8a4b 100755
@@ -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
 
tests/xfs/259 +5 -3
index 88e2f3ee..bdb6a492 100755
@@ -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
tests/xfs/260 +1 -10
index a780365f..a03520d8 100755
@@ -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
 
tests/xfs/261 +0 -7
index eb8a72cd..58d942a9 100755
@@ -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
tests/xfs/264 +3 -4
index 191f57d5..6529cd8f 100755
@@ -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
tests/xfs/265 +0 -8
index c0edb6d2..9ec03844 100755
@@ -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
tests/xfs/266 +3 -4
index eeca8822..1a57f644 100755
@@ -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
tests/xfs/267 +3 -4
index 89b968be..19e1f030 100755
@@ -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.
tests/xfs/268 +3 -5
index 8c991fba..fd668856 100755
@@ -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
tests/xfs/269 +0 -7
index c1477373..d467d08d 100755
@@ -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
tests/xfs/271 +4 -4
index 14d64cd0..34c40795 100755
@@ -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
tests/xfs/272 +4 -4
index 7ed8b951..43a9ce1b 100755
@@ -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
tests/xfs/273 +4 -4
index a22e9d47..7f6adbb4 100755
@@ -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
tests/xfs/274 +4 -4
index dcaea688..0d1f2d04 100755
@@ -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
tests/xfs/275 +4 -4
index d22e21e9..f4c22f9e 100755
@@ -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
tests/xfs/276 +4 -4
index 8cc48675..487a3a42 100755
@@ -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
tests/xfs/277 +5 -4
index 03208ef2..dc2ecd74 100755
@@ -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
tests/xfs/279 +4 -5
index 835d187f..09f1a59e 100755
@@ -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
tests/xfs/281 +3 -4
index 6b148a94..eba8e39c 100755
@@ -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
tests/xfs/282 +3 -4
index 50303b08..53c7dc49 100755
@@ -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
tests/xfs/283 +3 -4
index 59ea5f3b..6d377615 100755
@@ -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
tests/xfs/284 +4 -6
index fa7bfdd0..69906f90 100755
@@ -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
tests/xfs/287 +3 -4
index 31bbf0d7..fea453f5 100755
@@ -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()
 {
tests/xfs/289 +9 -8
index c722deff..adc6d4db 100755
@@ -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
tests/xfs/296 +4 -5
index efd303e2..96268cee 100755
@@ -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
tests/xfs/299 +0 -8
index 4b9df3c6..9846aef1 100755
@@ -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
 
tests/xfs/301 +4 -5
index 71ec1420..12e8bc1a 100755
@@ -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
tests/xfs/302 +4 -5
index 2e16890c..14907273 100755
@@ -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
tests/xfs/309 +0 -8
index 3e909509..f6a2ef20 100755
@@ -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
tests/xfs/310 +3 -5
index 3214e04b..c635b39a 100755
@@ -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
tests/xfs/311 +4 -6
index d5e3afbf..92d521d0 100755
@@ -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
tests/xfs/312 +0 -8
index 94f868fe..8a1dff27 100755
@@ -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
tests/xfs/313 +0 -8
index 9c7cf5b9..6501a090 100755
@@ -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
tests/xfs/314 +0 -8
index 9ac311d0..ae0df258 100755
@@ -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
tests/xfs/315 +0 -8
index 105515ab..154e9770 100755
@@ -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
tests/xfs/316 +0 -8
index f0af19d2..2b07346b 100755
@@ -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
tests/xfs/317 +0 -8
index 1ca2672d..49434170 100755
@@ -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
tests/xfs/318 +0 -8
index 38c7aa60..c673d680 100755
@@ -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
tests/xfs/319 +0 -8
index d64651fb..97bfeeae 100755
@@ -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
tests/xfs/320 +0 -8
index d22d76d9..2a4303cb 100755
@@ -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
tests/xfs/321 +0 -8
index 06a34347..eb824ca6 100755
@@ -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
tests/xfs/322 +0 -8
index 89a2f741..ca0a39e6 100755
@@ -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
tests/xfs/323 +0 -8
index 66737da0..3c535535 100755
@@ -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
tests/xfs/324 +0 -8
index 9909db62..c753a170 100755
@@ -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
tests/xfs/325 +0 -8
index 5b26b2b3..4046d908 100755
@@ -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
tests/xfs/326 +0 -8
index 8b95a18a..df8c1738 100755
@@ -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
tests/xfs/327 +0 -8
index 25855f77..285b6b49 100755
@@ -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
tests/xfs/336 +0 -7
index 6592419d..31df95bf 100755
@@ -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
 
tests/xfs/432 +4 -4
index 86012f0b..8206616d 100755
@@ -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
tests/xfs/438 +10 -6
index c3008b1c..3531e46d 100755
@@ -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()
 {
tests/xfs/442 +5 -5
index b04b1c83..a4a76ce2 100755
@@ -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
tests/xfs/447 +3 -4
index 795c43b9..088c1c4e 100755
@@ -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
tests/xfs/501 +3 -4
index a9acf0af..aa74836f 100755
@@ -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
tests/xfs/503 +4 -6
index 6c4bfd1c..9dec0ff0 100755
@@ -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
tests/xfs/507 +5 -8
index b9c9ab29..abd16e38 100755
@@ -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
tests/xfs/511 +0 -8
index d2550404..a91fde65 100755
@@ -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
tests/xfs/512 +1 -7
index 4595770e..7aee8b78 100755
@@ -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
tests/xfs/513 +5 -10
index bfdfd4f6..13084f4d 100755
@@ -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
tests/xfs/514 +4 -6
index cf5588f2..431a3f95 100755
@@ -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
tests/xfs/515 +4 -6
index 2d7bbb35..4e0d681c 100755
@@ -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
tests/xfs/516 +0 -7
index 9e1b9931..2aa20696 100755
@@ -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
 
tests/xfs/517 +3 -6
index 512f795f..015a7a5f 100755
@@ -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
tests/xfs/520 +0 -8
index 2fceb07c..b24d4fee 100755
@@ -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
 
tests/xfs/521 +4 -4
index 60f28740..d93b74b9 100755
@@ -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
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

tests/xfs/522 +0 -7
index 2475d584..ff0726a9 100755

Lines of this file are not shown. View the raw message.

tests/xfs/523 +0 -7
index bd9b7553..ce4cecd6 100755

Lines of this file are not shown. View the raw message.

tests/xfs/524 +4 -4
index fe4d134b..9811c294 100755

Lines of this file are not shown. View the raw message.

tests/xfs/525 +0 -7
index a17c9f19..9700f960 100755

Lines of this file are not shown. View the raw message.

tests/xfs/526 +0 -7
index 4261e849..edd20826 100755

Lines of this file are not shown. View the raw message.

tests/xfs/528 +3 -3
index 29e81228..f76bd15f 100755

Lines of this file are not shown. View the raw message.

tests/xfs/530 +3 -3
index 9c6f44d7..226ebd2a 100755

Lines of this file are not shown. View the raw message.

tests/xfs/542 +4 -3
index 5c45eed7..f4d3ae9d 100755

Lines of this file are not shown. View the raw message.

tests/xfs/543 +0 -7
index 913276c8..1562f563 100755

Lines of this file are not shown. View the raw message.

tests/xfs/544 +8 -3
index c7251fc3..f76aaa24 100755

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.35.1

Part of the diff is not shown here. View the raw message.

#8 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 10 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

Quoted 193 lines
---
 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 ++++----
Quoted 9 lines
 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!

Quoted 23 lines
tests/xfs/004 +0 -7
index f18316b3..f8cfeb6a 100755
@@ -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
tests/xfs/006 +0 -0
index cecceaa3..fd8d8071 100755

tests/xfs/006 line 16

Quoted 9 lines
tests/xfs/006 +1 -3
@@ -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().

Quoted 18 lines
tests/xfs/006 +3 -0
+       _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
tests/xfs/008 +0 -0
index a53f6c92..5bef44bb 100755

tests/xfs/008 _begin_fstest rw ioctl auto quick · line 19

Quoted 8 lines
tests/xfs/008 +0 -5
@@ -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.

[...]

Quoted 7 lines
tests/xfs/051 +0 -0
index ea70cb50..4718099d 100755
@@ -11,14 +11,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log metadata

tests/xfs/051 line 17

Quoted 10 lines
tests/xfs/051 +2 -5
 
-# 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.

[...]

Quoted 10 lines
tests/xfs/310 +0 -2
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
-# Override the default cleanup function.
-_cleanup()

tests/xfs/310 line 18

Quoted 10 lines
tests/xfs/310 +3 -3
+_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.

Quoted 8 lines
tests/xfs/310 +1 -1
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
--

2.35.1

#9 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Use a local cleanup function and _register_cleanup properly.

Remove local cleanups that just do what the standard _cleanup and test exist does.

Quoted 7 lines
Quoted 2 lines

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/[email protected]/T/#u

Quoted 7 lines
Quoted 7 lines
tests/xfs/006 +0 -0
index cecceaa3..fd8d8071 100755
@@ -11,11 +11,10 @@
 _begin_fstest auto quick mount eio
 
Quoted 12 lines

tests/xfs/006 line 16

Quoted 7 lines
tests/xfs/006 +1 -3
 # 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.

Quoted 19 lines

tests/xfs/008 _begin_fstest rw ioctl auto quick · line 19

Quoted 13 lines
tests/xfs/008 +0 -5
index a53f6c92..5bef44bb 100755
@@ -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.

Quoted 2 lines

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?

Quoted 4 lines

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.

Quoted 4 lines

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.

Quoted 8 lines
Quoted 8 lines
tests/xfs/051 +0 -0
index ea70cb50..4718099d 100755
@@ -11,14 +11,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log metadata
 
Quoted 13 lines

tests/xfs/051 line 17

Quoted 9 lines
tests/xfs/051 +2 -5
-# 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.

Quoted 8 lines
Quoted 8 lines
tests/xfs/310 +0 -0
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
Quoted 15 lines

tests/xfs/310 line 17

Quoted 11 lines
tests/xfs/310 +3 -5
-# 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.

Quoted 2 lines

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.

Signature · 2 lines
Dave Chinner
[email protected]
#10 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 28 lines
Quoted 19 lines

tests/xfs/008 _begin_fstest rw ioctl auto quick · line 19

Quoted 13 lines
tests/xfs/008 +0 -5
index a53f6c92..5bef44bb 100755
@@ -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.

Quoted 2 lines

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.

Quoted 6 lines

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.

Quoted 12 lines
Quoted 5 lines

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.

Quoted 9 lines
Quoted 4 lines

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.

Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
tests/xfs/051 +0 -0
index ea70cb50..4718099d 100755
@@ -11,14 +11,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log metadata
 
Quoted 13 lines

tests/xfs/051 line 17

Quoted 9 lines
tests/xfs/051 +2 -5
-# 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.

Quoted 3 lines

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.

Quoted 31 lines
Quoted 9 lines
Quoted 9 lines
tests/xfs/310 +0 -0
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
Quoted 15 lines

tests/xfs/310 line 17

Quoted 11 lines
tests/xfs/310 +3 -5
-# 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.

Quoted 5 lines
Quoted 2 lines

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.

#11 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 33 lines · Amir Goldstein
Quoted 33 lines
Quoted 8 lines
Quoted 8 lines
tests/xfs/310 +0 -0
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
Quoted 15 lines

tests/xfs/310 line 17

Quoted 11 lines
tests/xfs/310 +3 -5
-# 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.

Quoted 2 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 6 lines

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.

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by
#12 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 43 lines · Dave Chinner
Quoted 33 lines · Amir Goldstein
Quoted 33 lines
Quoted 8 lines
Quoted 8 lines
tests/xfs/310 +0 -0
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
Quoted 15 lines

tests/xfs/310 line 17

Quoted 11 lines
tests/xfs/310 +3 -5
-# 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.

Quoted 2 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 9 lines

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.

Quoted 21 lines
Quoted 6 lines

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.

Quoted 4 lines

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:

Thanks,
Amir.

#13 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 83 lines · Amir Goldstein
Quoted 43 lines · Dave Chinner
Quoted 33 lines · Amir Goldstein
Quoted 33 lines
Quoted 8 lines
Quoted 8 lines
tests/xfs/310 +0 -0
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
Quoted 15 lines

tests/xfs/310 line 17

Quoted 11 lines
tests/xfs/310 +3 -5
-# 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.

Quoted 2 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 9 lines

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.

Quoted 21 lines
Quoted 6 lines

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.

Quoted 4 lines

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.

Quoted 4 lines

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

Quoted 8 lines

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

Thanks,
Amir.

#14 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

In reply to Amir Goldstein
Quoted 3 lines · Amir Goldstein
Quoted 1 line · Dave Chinner

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.

Signature · 2 lines
Dave Chinner
[email protected]
#15 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 6 lines · Dave Chinner
Quoted 3 lines · Amir Goldstein
Quoted 1 line · Dave Chinner

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.

Quoted 9 lines

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.

#16 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

In reply to Amir Goldstein
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Use a local cleanup function and _register_cleanup properly.

Remove local cleanups that just do what the standard _cleanup and test exist does.

Quoted 13 lines
Quoted 2 lines

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.

Quoted 5 lines
---
 tests/xfs/004     |  7 -------
 tests/xfs/006     |  7 ++++---

[snap]

Quoted 7 lines
Quoted 7 lines
tests/xfs/006 +0 -0
index cecceaa3..fd8d8071 100755
@@ -11,11 +11,10 @@
 _begin_fstest auto quick mount eio
 
Quoted 9 lines

tests/xfs/006 line 16

Quoted 7 lines
tests/xfs/006 +1 -3
 # 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

Quoted 116 lines

Again, if the call to _cleanup is implicitly chained then the local function is not needed and trap can call the global _dmerror_cleanup().

Quoted 18 lines
tests/xfs/006 +3 -0
+       _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
tests/xfs/008 +0 -0
index a53f6c92..5bef44bb 100755

tests/xfs/008 _begin_fstest rw ioctl auto quick · line 19

Quoted 8 lines
tests/xfs/008 +0 -5
@@ -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.

[...]

Quoted 7 lines
tests/xfs/051 +0 -0
index ea70cb50..4718099d 100755
@@ -11,14 +11,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log metadata

tests/xfs/051 line 17

Quoted 10 lines
tests/xfs/051 +2 -5
 
-# 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.

[...]

Quoted 10 lines
tests/xfs/310 +0 -2
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
-# Override the default cleanup function.
-_cleanup()

tests/xfs/310 line 18

Quoted 10 lines
tests/xfs/310 +3 -3
+_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.

Quoted 8 lines
tests/xfs/310 +1 -1
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
--

2.35.1

#17 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 43 lines · Zorro Lang
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Use a local cleanup function and _register_cleanup properly.

Remove local cleanups that just do what the standard _cleanup and test exist does.

Quoted 13 lines
Quoted 2 lines

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.

Quoted 5 lines
---
 tests/xfs/004     |  7 -------
 tests/xfs/006     |  7 ++++---

[snap]

Quoted 7 lines
Quoted 7 lines
tests/xfs/006 +0 -0
index cecceaa3..fd8d8071 100755
@@ -11,11 +11,10 @@
 _begin_fstest auto quick mount eio
 
Quoted 9 lines

tests/xfs/006 line 16

Quoted 7 lines
tests/xfs/006 +1 -3
 # Override the default cleanup function.
-_cleanup()
+_dmerror_cleanup()
 {
-       cd /
-       rm -f $tmp.*
        _dmerror_cleanup

That looks recursive.

Quoted 4 lines

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

Quoted 120 lines

Thanks,
Zorro

Quoted 116 lines

Again, if the call to _cleanup is implicitly chained then the local function is not needed and trap can call the global _dmerror_cleanup().

Quoted 18 lines
tests/xfs/006 +3 -0
+       _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
tests/xfs/008 +0 -0
index a53f6c92..5bef44bb 100755

tests/xfs/008 _begin_fstest rw ioctl auto quick · line 19

Quoted 8 lines
tests/xfs/008 +0 -5
@@ -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.

[...]

Quoted 7 lines
tests/xfs/051 +0 -0
index ea70cb50..4718099d 100755
@@ -11,14 +11,13 @@
 . ./common/preamble
 _begin_fstest shutdown auto log metadata

tests/xfs/051 line 17

Quoted 10 lines
tests/xfs/051 +2 -5
 
-# 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.

[...]

Quoted 10 lines
tests/xfs/310 +0 -2
index 3214e04b..c635b39a 100755
@@ -9,14 +9,12 @@
 . ./common/preamble
 _begin_fstest auto clone rmap
 
-# Override the default cleanup function.
-_cleanup()

tests/xfs/310 line 18

Quoted 10 lines
tests/xfs/310 +3 -3
+_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.

Quoted 8 lines
tests/xfs/310 +1 -1
 }
+_register_cleanup local_cleanup
 
 # Import common functions.
 . ./common/filter
--

2.35.1

#18 lore raw

Re: [PATCH 3/8] xfs/*: clean up _cleanup override

Quoted 49 lines · Zorro Lang
Quoted 43 lines · Zorro Lang
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Use a local cleanup function and _register_cleanup properly.

Remove local cleanups that just do what the standard _cleanup and test exist does.

Quoted 13 lines
Quoted 2 lines

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.

Quoted 5 lines
---
 tests/xfs/004     |  7 -------
 tests/xfs/006     |  7 ++++---

[snap]

Quoted 7 lines
Quoted 7 lines
tests/xfs/006 +0 -0
index cecceaa3..fd8d8071 100755
@@ -11,11 +11,10 @@
 _begin_fstest auto quick mount eio
 
Quoted 9 lines

tests/xfs/006 line 16

Quoted 7 lines
tests/xfs/006 +1 -3
 # Override the default cleanup function.
-_cleanup()
+_dmerror_cleanup()
 {
-       cd /
-       rm -f $tmp.*
        _dmerror_cleanup

That looks recursive.

Quoted 4 lines

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.

Quoted 6 lines

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.

Signature · 2 lines
Dave Chinner
[email protected]
#19 lore raw

PATCH 4/8 fstests: define a common _dump_cleanup function

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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

---
 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(-)
common/dump +27 -26
index 0dcc9655..b6001016 100644
@@ -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
 }
 
 #
tests/xfs/022 +2 -10
index e9310365..2d124709 100755
@@ -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
tests/xfs/023 +2 -11
index 1019831d..e2b9ba6f 100755
@@ -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
tests/xfs/024 +2 -10
index dcb6b9fc..920bacb2 100755
@@ -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
tests/xfs/025 +2 -10
index dd3c8588..479c51b4 100755
@@ -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
tests/xfs/026 +2 -10
index 18529003..0daa7c88 100755
@@ -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
tests/xfs/027 +2 -10
index df6ee2ac..58e9ec68 100755
@@ -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
tests/xfs/028 +2 -10
index d0518317..be7453d4 100755
@@ -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
tests/xfs/035 +1 -9
index 6461884b..29168c5a 100755
@@ -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
tests/xfs/036 +1 -8
index becbc83c..ab3cbf3b 100755
@@ -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
tests/xfs/037 +1 -9
index 0cbd0b16..9deff09e 100755
@@ -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
 
tests/xfs/038 +1 -8
index da5507af..e868df79 100755
@@ -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
tests/xfs/039 +1 -8
index 69a1092d..1499d1ec 100755
@@ -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
tests/xfs/043 +1 -8
index 7ce74539..6cc264b0 100755
@@ -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
tests/xfs/046 +1 -8
index 3ac4a180..8db91972 100755
@@ -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
tests/xfs/047 +1 -8
index c2f66e31..a0aaf3d2 100755
@@ -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
tests/xfs/055 +1 -8
index d663bfab..eaf807d2 100755
@@ -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
tests/xfs/056 +1 -10
index 7a4b2423..0ecb8503 100755
@@ -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
tests/xfs/059 +2 -10
index 9428a9da..d405bdea 100755
@@ -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
tests/xfs/060 +2 -10
index b5939f67..4aca8943 100755
@@ -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
tests/xfs/061 +2 -10
index dcaac20c..1ff3857a 100755
@@ -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
tests/xfs/063 +2 -7
index 9193745a..a4c2b1ea 100755
@@ -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
tests/xfs/064 +2 -7
index e332daee..19d4d8fc 100755
@@ -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()
 {
tests/xfs/065 +2 -7
index 9b31ff34..f7f2ab35 100755
@@ -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
 
 #
tests/xfs/066 +3 -8
index 22eb10cc..2e7b67e0 100755
@@ -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
tests/xfs/068 +2 -10
index ed281881..26957adc 100755
@@ -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
tests/xfs/266 +3 -11
index 1a57f644..1be1ecc5 100755
@@ -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
tests/xfs/267 +3 -10
index 19e1f030..4bfffad7 100755
@@ -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
tests/xfs/268 +3 -9
index fd668856..77fca55d 100755
@@ -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
tests/xfs/281 +1 -8
index eba8e39c..b33df7ed 100755
@@ -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
tests/xfs/282 +1 -8
index 53c7dc49..5d234de5 100755
@@ -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
tests/xfs/283 +1 -8
index 6d377615..7a145d65 100755
@@ -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
tests/xfs/287 +3 -8
index fea453f5..ae97f0cc 100755
@@ -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()
 {
tests/xfs/296 +2 -9
index 96268cee..18889788 100755
@@ -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
tests/xfs/301 +2 -9
index 12e8bc1a..3d94e3a4 100755
@@ -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"
tests/xfs/302 +2 -9
index 14907273..319ffb62 100755
@@ -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"
tests/xfs/544 +2 -8
index f76aaa24..92036250 100755
@@ -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
Signature · 1 line
2.35.1
Reviewed-by on v1 4/8
#20 lore raw

Re: [PATCH 4/8] fstests: define a common _dump_cleanup function

Quoted 38 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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

---
 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 +--------
Quoted 9 lines
 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!

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

tests/xfs/026 line 13

Quoted 10 lines
tests/xfs/026 +0 -2
index 18529003..0daa7c88 100755
@@ -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.

#21 lore raw

Re: [PATCH 4/8] fstests: define a common _dump_cleanup function

Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner
tests/xfs/026 +0 -0
index 18529003..0daa7c88 100755
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
Quoted 6 lines

tests/xfs/026 line 13

Quoted 2 lines
tests/xfs/026 +0 -2
-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?

Quoted 1 line

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.

Signature · 2 lines
Dave Chinner
[email protected]
#22 lore raw

Re: [PATCH 4/8] fstests: define a common _dump_cleanup function

Quoted 25 lines · Dave Chinner
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Dave Chinner
tests/xfs/026 +0 -0
index 18529003..0daa7c88 100755
@@ -9,17 +9,8 @@
 . ./common/preamble
 _begin_fstest dump ioctl auto quick
 
Quoted 6 lines

tests/xfs/026 line 13

Quoted 2 lines
tests/xfs/026 +0 -2
-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.

Quoted 2 lines

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

The former :)

Quoted 12 lines
Quoted 2 lines

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.

#23 lore raw

PATCH 5/8 fstests: use a common fsstress cleanup function

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 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(-)
common/preamble +11 -0
index 7aa55dc6..0e8827c3 100644
@@ -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.
tests/xfs/011 +0 -7
index 161f263c..b9b0d138 100755
@@ -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
tests/xfs/013 +1 -8
index c451ded3..ce91ed62 100755
@@ -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'
 }
tests/xfs/051 +2 -9
index 4718099d..e2e0e7f2 100755
@@ -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
tests/xfs/057 +0 -9
index 983479ab..432c4836 100755
@@ -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
tests/xfs/079 +1 -10
index fc30181b..d49b699c 100755
@@ -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
tests/xfs/141 +1 -10
index 0b0cac81..18a00058 100755
@@ -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
tests/xfs/167 +1 -8
index 50d3c41b..d7b5f378 100755
@@ -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()
 {
tests/xfs/442 +2 -9
index a4a76ce2..dcec4685 100755
@@ -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
Signature · 1 line
2.35.1
#25 lore raw

PATCH 6/8 fstests: consolidate no cleanup test setup

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 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(-)
common/preamble +9 -0
index 0e8827c3..99e60a40 100644
@@ -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
tests/xfs/083 +0 -5
index 7666d204..a817c71f 100755
@@ -10,11 +10,6 @@
 #
 . ./common/preamble
 _begin_fstest dangerous_fuzzers punch
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/085 +0 -5
index 8aa8f2a0..6d171f5a 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/086 +0 -5
index 031cb445..d0e26381 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/087 +0 -5
index 9d1f59f0..bca4fdd0 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/088 +0 -5
index de824223..b3743151 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/089 +0 -5
index dae2d0d0..5567c3f0 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/091 +0 -5
index c5db3337..8cda3146 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/093 +0 -5
index 9fe1799a..a4308881 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/097 +0 -5
index d66df458..8cdf7ce2 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/098 +0 -5
index 21215ee5..7d2c5b8a 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/099 +0 -5
index 2791e2df..a59022b6 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/100 +0 -5
index e71e760e..6f3c36c5 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/101 +0 -5
index 1cbcc973..437ba63f 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/102 +0 -5
index 0ce3588a..b75883f6 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/105 +0 -5
index 8a583da5..66c59c23 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/112 +0 -5
index 4362f31c..b3fcf12f 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/113 +0 -5
index e3f4fd4d..9d18532f 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/117 +0 -5
index 4962c201..c8d1635d 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/120 +0 -5
index 653948ee..e427b0c3 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/123 +0 -5
index e191623a..48c8dd08 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/124 +0 -5
index af738212..e9b04a17 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/125 +0 -5
index a7280e2c..f5d28ef3 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/126 +0 -5
index 55a12178..88d99227 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
tests/xfs/130 +0 -5
index e7a0e6e3..c48858ea 100755
@@ -9,11 +9,6 @@
 #
 . ./common/preamble
 _begin_fstest fuzzers clone
-
-_no_cleanup()
-{
-	cd /
-}
 _register_cleanup _no_cleanup
 
 # Import common functions.
Signature · 1 line
2.35.1
Reviewed-by on v1 6/8
#26 lore raw

Re: [PATCH 6/8] fstests: consolidate no cleanup test setup

Quoted 27 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 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 -----
Quoted 9 lines
 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

Thanks,
Amir.

#27 lore raw

Re: [PATCH 6/8] fstests: consolidate no cleanup test setup

Quoted 38 lines · Amir Goldstein
Quoted 27 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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.

---
 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 -----
Quoted 9 lines
 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(-)
Quoted 5 lines

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.

Signature · 2 lines
Dave Chinner
[email protected]
#28 lore raw

PATCH 7/8 fstests: Set up BUS trap for tests by default

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

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
Quoted 2 lines

sed -i -e '/_register_cleanup "_cleanup" BUS/,+1d' done

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

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

Re: [PATCH 7/8] fstests: Set up BUS trap for tests by default

Quoted 175 lines · Dave Chinner

From: Dave Chinner <[email protected]>

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
Quoted 2 lines

sed -i -e '/_register_cleanup "_cleanup" BUS/,+1d' done

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

---
 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 --
Quoted 9 lines
 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!

Thanks,
Amir.

#30 lore raw

PATCH 8/8 fstests: cleanup _cleanup usage in shared

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

To match the cleanup of tests/xfs

---
 tests/shared/002 |  7 ++++---
 tests/shared/298 | 22 +++++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)
tests/shared/002 +4 -3
index d99539c9..0a92dcc2 100755
@@ -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
tests/shared/298 +11 -11
index bd52b6a0..797ac7a8 100755
@@ -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
Signature · 1 line
2.35.1
#32 lore raw

Re: [PATCH 8/8] fstests: cleanup _cleanup usage in shared

In reply to Dave Chinner
Quoted 16 lines · Dave Chinner

From: Dave Chinner <[email protected]>

To match the cleanup of tests/xfs

---
 tests/shared/002 |  7 ++++---
 tests/shared/298 | 22 +++++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)
tests/shared/002 +0 -0
index d99539c9..0a92dcc2 100755

tests/shared/002 line 21

Quoted 9 lines
tests/shared/002 +2 -2
@@ -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.

#33 lore raw
In reply to Dave Chinner
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble +2 -2
@@ -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.

Quoted 79 lines

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(-)
Quoted 8 lines

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.

#34 lore raw
Quoted 51 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble _register_cleanup() · line 24

Quoted 6 lines
common/preamble +1 -1
@@ -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.

Signature · 2 lines
Dave Chinner
[email protected]
#35 lore raw
Quoted 55 lines · Dave Chinner
Quoted 53 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble +0 -0
@@ -20,7 +20,7 @@ _register_cleanup()
        shift
 
Quoted 11 lines

common/preamble _register_cleanup() · line 24

Quoted 4 lines
common/preamble +1 -1
        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.

#36 lore raw
Quoted 68 lines · Amir Goldstein
Quoted 55 lines · Dave Chinner
Quoted 53 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble +0 -0
@@ -20,7 +20,7 @@ _register_cleanup()
        shift
 
Quoted 11 lines

common/preamble _register_cleanup() · line 24

Quoted 4 lines
common/preamble +1 -1
        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.

Quoted 3 lines

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.

Signature · 2 lines
Dave Chinner
[email protected]
#37 lore raw
Quoted 70 lines · Dave Chinner
Quoted 68 lines · Amir Goldstein
Quoted 66 lines · Dave Chinner
Quoted 51 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble _register_cleanup() · line 24

Quoted 6 lines
common/preamble +1 -1
@@ -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.

Quoted 6 lines
Quoted 3 lines

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.

#38 lore raw
Quoted 75 lines · Amir Goldstein
Quoted 74 lines · Dave Chinner
Quoted 71 lines · Amir Goldstein
Quoted 55 lines · Dave Chinner
Quoted 53 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble +0 -0
@@ -20,7 +20,7 @@ _register_cleanup()
        shift
 
Quoted 11 lines

common/preamble _register_cleanup() · line 24

Quoted 4 lines
common/preamble +1 -1
        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.*?

Quoted 6 lines
Quoted 2 lines

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

Signature · 2 lines
Dave Chinner
[email protected]
#39 lore raw
Quoted 77 lines · Dave Chinner
Quoted 75 lines · Amir Goldstein
Quoted 74 lines · Dave Chinner
Quoted 71 lines · Amir Goldstein
Quoted 55 lines · Dave Chinner
Quoted 53 lines · Amir Goldstein
Quoted 13 lines · Dave Chinner

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.

Quoted 9 lines

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!

Quoted 10 lines

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:

Quoted 6 lines

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():

common/preamble +0 -0
@@ -20,7 +20,7 @@ _register_cleanup()
        shift
 
Quoted 11 lines

common/preamble _register_cleanup() · line 24

Quoted 4 lines
common/preamble +1 -1
        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.*?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

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