diff mbox series

[v2] tests: _fail on _scratch_mkfs_sized failure

Message ID 20240429115826.9171-1-ddiss@suse.de (mailing list archive)
State New, archived
Headers show
Series [v2] tests: _fail on _scratch_mkfs_sized failure | expand

Commit Message

David Disseldorp April 29, 2024, 11:58 a.m. UTC
If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the
provided size, tests may subsequently mount and run atop a previously
created (e.g. non-size-bound) filesystem.
This can lead to difficult to debug failures, or for some -ENOSPC
exercising tests, near infinite runtimes. Avoid this by renaming the
current function to _try_scratch_mkfs_sized() and _fail in the parent
_scratch_mkfs_sized() wrapper.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Suggested-by: Darrick J. Wong <djwong@kernel.org>
---
Changes since v1:
- call _fail in a wrapper function, instead of adding failure handlers
  to individual test _scratch_mkfs_sized() callers.

 common/rc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Zorro Lang April 29, 2024, 1:44 p.m. UTC | #1
On Mon, Apr 29, 2024 at 09:58:27PM +1000, David Disseldorp wrote:
> If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the
> provided size, tests may subsequently mount and run atop a previously
> created (e.g. non-size-bound) filesystem.
> This can lead to difficult to debug failures, or for some -ENOSPC
> exercising tests, near infinite runtimes. Avoid this by renaming the
> current function to _try_scratch_mkfs_sized() and _fail in the parent
> _scratch_mkfs_sized() wrapper.
> 
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> ---
> Changes since v1:
> - call _fail in a wrapper function, instead of adding failure handlers
>   to individual test _scratch_mkfs_sized() callers.

As we call _fail in _scratch_mkfs_sized, so don't need to do _fail after mkfs
fails :

$ grep -rsn -A 1 _scratch_mkfs_sized tests/|grep -E "_fail "
tests/btrfs/007-47-             || _fail "size=$fsz mkfs failed"
tests/btrfs/007-74-             || _fail "size=$fsz mkfs failed"
tests/btrfs/004-161-            || _fail "size=$fsz mkfs failed"
tests/ext4/021:27:_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/ext4/059-26-      >>$seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/449-28-_scratch_mount || _fail "mount failed"
tests/generic/171:45:_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/172:43:_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/173:45:_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/174:46:_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/735:28:_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/015-35-    || _fail "mkfs failed"
tests/generic/077:53:_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
tests/generic/083-54-                   || _fail "size=$fsz mkfs failed"
tests/xfs/057-55-               _fail "mkfs failed"
tests/xfs/015:46:_scratch_mkfs_sized $((96 * 1024 * 1024)) > $tmp.mkfs.raw || _fail "mkfs failed"

> 
>  common/rc | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 56f1afb6..e95070dd 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -968,8 +968,8 @@ _small_fs_size_mb()
>  }
>  
>  # Create fs of certain size on scratch device
> -# _scratch_mkfs_sized <size in bytes> [optional blocksize]
> -_scratch_mkfs_sized()
> +# _try_scratch_mkfs_sized <size in bytes> [optional blocksize]
> +_try_scratch_mkfs_sized()
>  {
>  	local fssize=$1
>  	local blocksize=$2
> @@ -1111,6 +1111,11 @@ _scratch_mkfs_sized()
>  	esac
>  }
>  
> +_scratch_mkfs_sized()
> +{
> +	_try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed"

How about printing the "size" arguments?

> +}
> +
>  # Emulate an N-data-disk stripe w/ various stripe units
>  # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
>  _scratch_mkfs_geom()
> -- 
> 2.35.3
> 
>
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 56f1afb6..e95070dd 100644
--- a/common/rc
+++ b/common/rc
@@ -968,8 +968,8 @@  _small_fs_size_mb()
 }
 
 # Create fs of certain size on scratch device
-# _scratch_mkfs_sized <size in bytes> [optional blocksize]
-_scratch_mkfs_sized()
+# _try_scratch_mkfs_sized <size in bytes> [optional blocksize]
+_try_scratch_mkfs_sized()
 {
 	local fssize=$1
 	local blocksize=$2
@@ -1111,6 +1111,11 @@  _scratch_mkfs_sized()
 	esac
 }
 
+_scratch_mkfs_sized()
+{
+	_try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed"
+}
+
 # Emulate an N-data-disk stripe w/ various stripe units
 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
 _scratch_mkfs_geom()