diff mbox series

[1/7] btrfs/010: don't run without /sys/fs/btrfs

Message ID 20190121163316.20616-1-jeffm@suse.com (mailing list archive)
State New, archived
Headers show
Series [1/7] btrfs/010: don't run without /sys/fs/btrfs | expand

Commit Message

Jeff Mahoney Jan. 21, 2019, 4:33 p.m. UTC
From: Jeff Mahoney <jeffm@suse.com>

Older kernels don't have /sys/fs/btrfs.  btrfs/010 will happily run
until it goes to check its work against sysfs and finds those
files don't exist.  This patch introduces a require check to
ensure that the sysfs files are present before running.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 common/btrfs    | 8 ++++++++
 tests/btrfs/010 | 1 +
 2 files changed, 9 insertions(+)

Comments

Filipe Manana Jan. 22, 2019, 10:38 p.m. UTC | #1
On Mon, Jan 21, 2019 at 4:33 PM <jeffm@suse.com> wrote:
>
> From: Jeff Mahoney <jeffm@suse.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good. Since it's a btrfs specific change/fix, it would have been
a good idea to cc linux-btrfs.

>
> Older kernels don't have /sys/fs/btrfs.  btrfs/010 will happily run
> until it goes to check its work against sysfs and finds those
> files don't exist.  This patch introduces a require check to
> ensure that the sysfs files are present before running.
>
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> ---
>  common/btrfs    | 8 ++++++++
>  tests/btrfs/010 | 1 +
>  2 files changed, 9 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index 26dc0bb9..f6513c06 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -89,6 +89,14 @@ _require_btrfs_fs_feature()
>                 _notrun "Feature $feat not supported by the available btrfs version"
>  }
>
> +_require_btrfs_fs_sysfs()
> +{
> +       modprobe btrfs > /dev/null 2>&1
> +       [ -e /sys/fs/btrfs/features ] || \
> +               _notrun "Sysfs not supported by the available btrfs version"
> +
> +}
> +
>  _check_btrfs_filesystem()
>  {
>         device=$1
> diff --git a/tests/btrfs/010 b/tests/btrfs/010
> index 1a5f0146..72b2c727 100755
> --- a/tests/btrfs/010
> +++ b/tests/btrfs/010
> @@ -33,6 +33,7 @@ rm -f $seqres.full
>  _supported_fs btrfs
>  _supported_os Linux
>  _require_test
> +_require_btrfs_fs_sysfs
>
>  # Create 32k extents. All of these extents will be accounted as outstanding and
>  # reserved.
> --
> 2.16.4
>
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index 26dc0bb9..f6513c06 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -89,6 +89,14 @@  _require_btrfs_fs_feature()
 		_notrun "Feature $feat not supported by the available btrfs version"
 }
 
+_require_btrfs_fs_sysfs()
+{
+	modprobe btrfs > /dev/null 2>&1
+	[ -e /sys/fs/btrfs/features ] || \
+		_notrun "Sysfs not supported by the available btrfs version"
+
+}
+
 _check_btrfs_filesystem()
 {
 	device=$1
diff --git a/tests/btrfs/010 b/tests/btrfs/010
index 1a5f0146..72b2c727 100755
--- a/tests/btrfs/010
+++ b/tests/btrfs/010
@@ -33,6 +33,7 @@  rm -f $seqres.full
 _supported_fs btrfs
 _supported_os Linux
 _require_test
+_require_btrfs_fs_sysfs
 
 # Create 32k extents. All of these extents will be accounted as outstanding and
 # reserved.