btrfs: add test for btrfs cloning with file holes
[xfstests-dev.git] / common / rc
index f27ee5337e98625b16f9f5bf2f6012087ca37552..e2136d001c81a6c7b0af26de846c29ff309c2959 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2177,6 +2177,31 @@ _require_btrfs_send_stream_version()
        fi
 }
 
+_require_btrfs_mkfs_feature()
+{
+       if [ -z $1 ]; then
+               echo "Missing feature name argument for _require_btrfs_mkfs_feature"
+               exit 1
+       fi
+       feat=$1
+       $MKFS_BTRFS_PROG -O list-all 2>&1 | \
+               grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
+       [ $? -eq 0 ] || \
+               _notrun "Feature $feat not supported in the available version of mkfs.btrfs"
+}
+
+_require_btrfs_fs_feature()
+{
+       if [ -z $1 ]; then
+               echo "Missing feature name argument for _require_btrfs_fs_feature"
+               exit 1
+       fi
+       feat=$1
+       modprobe btrfs > /dev/null 2>&1
+       [ -e /sys/fs/btrfs/features/$feat ] || \
+               _notrun "Feature $feat not supported by the available btrfs version"
+}
+
 init_rc()
 {
        if [ "$iam" == new ]