Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: fstests@vger.kernel.org
Cc: linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Anand Suveer Jain <asj@kernel.org>, Chao Yu <chao@kernel.org>,
	Christoph Hellwig <hch@infradead.org>
Subject: [PATCH v2 4/6] common/rc: add helpers for /sys/fs/$FSTYP/features/
Date: Sat, 24 Oct 2026 04:31:12 +0800	[thread overview]
Message-ID: <20261023203114.1655019-5-zlang@kernel.org> (raw)
In-Reply-To: <20261023203114.1655019-1-zlang@kernel.org>

More and more test cases depend on /sys/fs/$FSTYP/features/ entries.
To improve code structure and maintainability, introduce the
 - _has_fs_sysfs_feature_attr
 - _get_fs_sysfs_feature_attr
 - _require_fs_sysfs_feature_attr
helpers.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 common/rc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/common/rc b/common/rc
index bcecaaeb..67a64a09 100644
--- a/common/rc
+++ b/common/rc
@@ -5571,6 +5571,58 @@ _require_fs_sysfs_dev_attr()
 	_notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}"
 }
 
+# Print the content of /sys/fs/$FSTYP/features/$ATTR
+#
+# Only one argument is needed:
+#  - attr: path name under /sys/fs/$FSTYP/features
+#
+# Usage example:
+#   _get_fs_sysfs_feature_attr send_stream_version
+_get_fs_sysfs_feature_attr()
+{
+	local attr=$1
+
+	if [ -z "$attr" ];then
+		_fail "Usage: _get_fs_sysfs_feature_attr <attr>"
+	fi
+
+	cat /sys/fs/${FSTYP}/features/${attr}
+}
+
+# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/features/$ATTR
+#
+# Only one argument is needed:
+#  - attr: path name under /sys/fs/$FSTYP/features
+#
+# Usage example:
+#   _has_fs_sysfs_feature_attr raid56
+_has_fs_sysfs_feature_attr()
+{
+	local attr=$1
+
+	if [ -z "$attr" ];then
+		_fail "Usage: _has_fs_sysfs_feature_attr <attr>"
+	fi
+
+	test -e /sys/fs/${FSTYP}/features/${attr}
+}
+
+# Require the existence of a sysfs entry at /sys/fs/$FSTYP/features/$ATTR
+#
+# Only one argument is needed:
+#  - attr: path name under /sys/fs/$FSTYP/features
+#
+# Usage example:
+#   _require_fs_sysfs_feature_attr raid56
+_require_fs_sysfs_feature_attr()
+{
+	local attr=$1
+
+	_has_fs_sysfs_feature_attr "$attr" && return
+
+	_notrun "This test requires /sys/fs/${FSTYP}/features/${attr}"
+}
+
 # Generic test for specific filesystem feature.
 # Currently only implemented to test overlayfs features.
 _require_scratch_feature()
-- 
2.55.0


  parent reply	other threads:[~2026-10-23 20:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 20:31 [PATCH v2 0/6] Refactor *_fs_sysfs_* helpers Zorro Lang
2026-10-23 20:31 ` [PATCH v2 1/6] fstests: rename _*_fs_sysfs_attr helpers to _*_fs_sysfs_dev_attr Zorro Lang
2026-10-23 20:31 ` [PATCH v2 2/6] fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr Zorro Lang
2026-10-23 20:31 ` [PATCH v2 3/6] common: move btrfs-only sysfs policy helpers out of common/sysfs Zorro Lang
2026-10-23 20:31 ` Zorro Lang [this message]
2026-10-23 20:31 ` [PATCH v2 5/6] common/rc: use common helper in _require_fanotify_ioerrors for f2fs Zorro Lang
2026-10-23 20:31 ` [PATCH v2 6/6] fstests: replace btrfs specific helpers with common sysfs helpers Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023203114.1655019-5-zlang@kernel.org \
    --to=zlang@kernel.org \
    --cc=asj@kernel.org \
    --cc=chao@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox