From: Naohiro Aota Date: Thu, 29 Apr 2021 12:39:26 +0000 (+0900) Subject: common/rc: introduce zone check commands X-Git-Tag: v2022.05.01~428 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=a6dbebcb19e96049d1e8efaa98b8817bafaad730 common/rc: introduce zone check commands Introduce some zone related helper functions: _zone_type(), _require_zoned_device(), and _require_non_zoned_device(). They all take a device path as an argument. _zone_type() return the zone type of the device according to the value returned from "/sys/block//queue/zoned". See Documentation/ABI/testing/sysfs-block for a detail. _require_zoned_device() checks if the device is zoned. If not, it skips the current test. _require_non_zoned_device() does the opposite. Signed-off-by: Naohiro Aota Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/common/rc b/common/rc index a7fc066c..0fe1366c 100644 --- a/common/rc +++ b/common/rc @@ -1931,6 +1931,50 @@ _require_dm_target() fi } +_zone_type() +{ + local target=$1 + if [ -z $target ]; then + echo "Usage: _zone_type " + exit 1 + fi + local sdev=`_short_dev $target` + + if [ -e /sys/block/${sdev}/queue/zoned ]; then + cat /sys/block/${sdev}/queue/zoned + else + echo none + fi +} + +_require_zoned_device() +{ + local target=$1 + if [ -z $target ]; then + echo "Usage: _require_zoned_device " + exit 1 + fi + + local type=`_zone_type ${target}` + if [ "${type}" = "none" ]; then + _notrun "this test require zoned block device" + fi +} + +_require_non_zoned_device() +{ + local target=$1 + if [ -z $target ]; then + echo "Usage: _require_non_zoned_device " + exit 1 + fi + + local type=`_zone_type ${target}` + if [ "${type}" != "none" ]; then + _notrun "this test require non-zoned block device" + fi +} + # this test requires the ext4 kernel support crc feature on scratch device # _require_scratch_ext4_crc()