diff mbox series

[08/12] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option

Message ID 4d9c26252329f9cbbe48a77c58e8ff42d0b45275.1707969354.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: functional test cases for tempfsid | expand

Commit Message

Anand Jain Feb. 15, 2024, 6:34 a.m. UTC
For easier and more effective testing of btrfs tempfsid, newer versions
of mkfs.btrfs contain options such as --device-uuid. Check if the
currently running mkfs.btrfs contains this option.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Filipe Manana Feb. 15, 2024, 12:37 p.m. UTC | #1
On Thu, Feb 15, 2024 at 6:35 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> For easier and more effective testing of btrfs tempfsid, newer versions
> of mkfs.btrfs contain options such as --device-uuid. Check if the
> currently running mkfs.btrfs contains this option.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  common/btrfs | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index 61d5812d49d9..9a7fa2c71ec5 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -88,6 +88,22 @@ _require_btrfs_mkfs_feature()
>                 _notrun "Feature $feat not supported in the available version of mkfs.btrfs"
>  }
>
> +_require_btrfs_mkfs_uuid_option()
> +{
> +       local cnt
> +       local feature
> +
> +       if [ -z $1 ]; then
> +               echo "Missing option name argument for _require_btrfs_mkfs_option"
> +               exit 1
> +       fi
> +       feature=$1
> +       cnt=$($MKFS_BTRFS_PROG --help 2>&1 |grep -E --count "\-\-uuid|\-\-device-uuid")

A space between | and grep would make things more readable and match
the general coding style.

> +       if [ $cnt != 2 ]; then
> +               _notrun "Require $MKFS_BTRFS_PROG with --uuid and --device-uuid option"

option -> options.

Otherwise it looks fine, thanks.

> +       fi
> +}
> +
>  _require_btrfs_fs_feature()
>  {
>         if [ -z $1 ]; then
> --
> 2.39.3
>
>
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index 61d5812d49d9..9a7fa2c71ec5 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -88,6 +88,22 @@  _require_btrfs_mkfs_feature()
 		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
 }
 
+_require_btrfs_mkfs_uuid_option()
+{
+	local cnt
+	local feature
+
+	if [ -z $1 ]; then
+		echo "Missing option name argument for _require_btrfs_mkfs_option"
+		exit 1
+	fi
+	feature=$1
+	cnt=$($MKFS_BTRFS_PROG --help 2>&1 |grep -E --count "\-\-uuid|\-\-device-uuid")
+	if [ $cnt != 2 ]; then
+		_notrun "Require $MKFS_BTRFS_PROG with --uuid and --device-uuid option"
+	fi
+}
+
 _require_btrfs_fs_feature()
 {
 	if [ -z $1 ]; then