public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: fstests@vger.kernel.org
Subject: [PATCH 5/8] fstests: use a common fsstress cleanup function
Date: Tue, 24 May 2022 17:34:08 +1000	[thread overview]
Message-ID: <20220524073411.1943480-6-david@fromorbit.com> (raw)
In-Reply-To: <20220524073411.1943480-1-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

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

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

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


  parent reply	other threads:[~2022-05-24  7:34 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24  7:34 [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Dave Chinner
2022-05-24  7:34 ` [PATCH 1/8] generic/038: kill background threads on interrupt Dave Chinner
2022-05-24  9:41   ` Amir Goldstein
2022-05-24 12:10     ` Dave Chinner
2022-05-24 12:30       ` Amir Goldstein
2022-05-24  7:34 ` [PATCH 2/8] fstests: _cleanup overrides are messy Dave Chinner
2022-05-24 16:16   ` Amir Goldstein
2022-05-24  7:34 ` [PATCH 3/8] xfs/*: clean up _cleanup override Dave Chinner
2022-05-24 10:42   ` Amir Goldstein
2022-05-24 12:27     ` Dave Chinner
2022-05-24 12:55       ` Amir Goldstein
2022-05-24 13:24         ` Dave Chinner
2022-05-24 14:17           ` Amir Goldstein
2022-05-24 16:32             ` Zorro Lang
2022-05-24 23:34             ` Dave Chinner
2022-05-25  2:54               ` Amir Goldstein
2022-05-24 17:13     ` Zorro Lang
2022-05-26 15:04       ` Zorro Lang
2022-05-26 23:39         ` Dave Chinner
2022-05-24  7:34 ` [PATCH 4/8] fstests: define a common _dump_cleanup function Dave Chinner
2022-05-24  9:04   ` Amir Goldstein
2022-05-24  9:52     ` Dave Chinner
2022-05-24  9:59       ` Amir Goldstein
2022-05-24  7:34 ` Dave Chinner [this message]
2022-05-24 12:25   ` [PATCH 5/8] fstests: use a common fsstress cleanup function Amir Goldstein
2022-05-24  7:34 ` [PATCH 6/8] fstests: consolidate no cleanup test setup Dave Chinner
2022-05-24 12:22   ` Amir Goldstein
2022-05-24 13:07     ` Dave Chinner
2022-05-24  7:34 ` [PATCH 7/8] fstests: Set up BUS trap for tests by default Dave Chinner
2022-05-24  8:48   ` Amir Goldstein
2022-05-24  7:34 ` [PATCH 8/8] fstests: cleanup _cleanup usage in shared Dave Chinner
2022-05-24 10:49   ` Amir Goldstein
2022-05-24 11:11   ` Amir Goldstein
2022-05-24  8:29 ` [RFC PATCH 0/8] fstests: _cleanup() overrides are a mess Amir Goldstein
2022-05-24  9:57   ` Dave Chinner
2022-05-24 10:01     ` Amir Goldstein
2022-05-24 10:13       ` Dave Chinner
2022-05-24 12:14         ` Amir Goldstein
2022-05-24 12:28           ` Dave Chinner
2022-05-24 12:34             ` Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220524073411.1943480-6-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox