[btrfs-progs,PATCHv3,1/3] tests: common: Add check_dm_target_support helper
diff mbox series

Message ID 20200103021215.30147-2-marcos.souza.org@gmail.com
State New
Headers show
Series
  • tests: do not fail if dm-thin is missing
Related show

Commit Message

Marcos Paulo de Souza Jan. 3, 2020, 2:12 a.m. UTC
From: Marcos Paulo de Souza <mpdesouza@suse.com>

This function will be used later to test if dm-thin is supported.
Inspired by fstests.

Suggested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 tests/common | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Qu Wenruo Jan. 3, 2020, 5:11 a.m. UTC | #1
On 2020/1/3 上午10:12, Marcos Paulo de Souza wrote:
> From: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> This function will be used later to test if dm-thin is supported.
> Inspired by fstests.
> 
> Suggested-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  tests/common | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tests/common b/tests/common
> index ca098444..3ea8c260 100644
> --- a/tests/common
> +++ b/tests/common
> @@ -322,6 +322,21 @@ check_global_prereq()
>  	fi
>  }
>  
> +# check if the targets passed as arguments are available, and if not just skip
> +# the test
> +check_dm_target_support()
> +{
> +	setup_root_helper
> +
> +	for target in "$@"; do
> +		$SUDO_HELPER modprobe dm-$target >/dev/null 2>&1
> +		$SUDO_HELPER dmsetup targets 2>&1 | grep -q ^$target
> +		if [ $? -ne 0 ]; then
> +			_not_run "This test requires dm $target support."
> +		fi
> +	done
> +}
> +
>  check_image()
>  {
>  	local image
>

Patch
diff mbox series

diff --git a/tests/common b/tests/common
index ca098444..3ea8c260 100644
--- a/tests/common
+++ b/tests/common
@@ -322,6 +322,21 @@  check_global_prereq()
 	fi
 }
 
+# check if the targets passed as arguments are available, and if not just skip
+# the test
+check_dm_target_support()
+{
+	setup_root_helper
+
+	for target in "$@"; do
+		$SUDO_HELPER modprobe dm-$target >/dev/null 2>&1
+		$SUDO_HELPER dmsetup targets 2>&1 | grep -q ^$target
+		if [ $? -ne 0 ]; then
+			_not_run "This test requires dm $target support."
+		fi
+	done
+}
+
 check_image()
 {
 	local image