diff mbox series

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

Message ID 20220524073411.1943480-7-david@fromorbit.com (mailing list archive)
State New, archived
Headers show
Series fstests: _cleanup() overrides are a mess | expand

Commit Message

Dave Chinner May 24, 2022, 7:34 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

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

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

Comments

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

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

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

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

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

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

Cheers,

Dave.
diff mbox series

Patch

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