From: Dave Chinner <dchinner@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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