diff mbox series

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

Message ID 20220524073411.1943480-9-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>

To match the cleanup of tests/xfs

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

Comments

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

Makes sense.

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

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

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

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

Thanks,
Amir.
diff mbox series

Patch

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