aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2021-02-18 14:17:31 +0000
committerMartin Matuska <mm@FreeBSD.org>2021-02-18 14:19:35 +0000
commitee36e25a86cbe2a9474c1d61f2c4b450da8ef952 (patch)
tree1f9e503fe3f154ff3ebc542840b892419ad85314 /sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
parentfa2528ac643519072c498b483d0dcc1fa5d99bc1 (diff)
parent62ceb3c592a54fc54d9cb3beee91906979c3df14 (diff)
downloadsrc-ee36e25a86cbe2a9474c1d61f2c4b450da8ef952.tar.gz
src-ee36e25a86cbe2a9474c1d61f2c4b450da8ef952.zip
zfs: merge OpenZFS master-bf156c966
Notable upstream changes: bf156c966 Remove unused abd_alloc_scatter_offset_chunkcnt 658fb8020 Add "compatibility" property for zpool feature sets This update introduces a new pool property called "compatibility" that can be used to enable a limited set of pool features on pool creation and "stick" to it, so the "zpool upgrade" does not accidentally enable features that are not desired. The value of this property may then be changed later. See zpool-features(5) for more information about the "compatibility" pool property. Obtained from: OpenZFS MFC after: 2 weeks
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib')
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib81
1 files changed, 81 insertions, 0 deletions
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
index 325f0b0360c3..c98e49518712 100644
--- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
+++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
@@ -107,3 +107,84 @@ function save_dump_dev
fi
echo $dumpdev
}
+
+#
+# Verify a pools enabled features match the provided feature set.
+# $1, pool name
+# $2, feature set(s)
+#
+# check_feature_set $TESTPOOL set1 set2 set3 ...
+#
+function check_feature_set
+{
+ typeset pool=$1
+ typeset feature_set=$2
+ shift
+
+ for set in "$@"; do
+ if test -e "$ZPOOL_COMPAT_DIR/$set"; then
+ file="$ZPOOL_COMPAT_DIR/$set"
+ else
+ log_fail "Missing feature file: $ZPOOL_COMPAT_DIR/$set"
+ fi
+ done
+
+ #
+ # Create a temporary file which contains all features which are
+ # common to the listed feature sets. This is used for comparison
+ # below to determine which features should be enabled.
+ #
+ typeset tmpfile=$(mktemp)
+
+ while read line; do
+ typeset flag=1
+
+ if [[ "$line" == "#*" ]]; then
+ continue
+ fi
+
+ for set in "$@"; do
+ if ! grep -q "$line" $ZPOOL_COMPAT_DIR/$set; then
+ flag=0
+ break;
+ fi
+ done
+
+ if [[ $flag -eq 1 ]]; then
+ echo "$line" >>$tmpfile
+ fi
+ done <"$file"
+
+ #
+ # Verify every enabled feature appears in the merged feature set.
+ # Verify every disabled feature does not.
+ #
+ for feature in $(zpool get all $pool | \
+ awk '$2 ~ /feature@/ { print $2 }'); do
+ state=$(get_pool_prop $feature $pool)
+ name=$(cut -d'@' -f2 <<<"$feature")
+
+ if [[ "$state" = "enabled" || "$state" = "active" ]]; then
+ if ! grep -q $name $tmpfile; then
+ cat $tmpfile
+ rm -f $tmpfile
+ log_fail "Enabled feature $name not " \
+ "in feature set file"
+ fi
+ elif [[ "$state" = "disabled" ]]; then
+ if grep -q $name $tmpfile; then
+ cat $tmpfile
+ rm -f $tmpfile
+ log_fail "Disabled feature $name is " \
+ "in feature set file"
+ fi
+ else
+ rm -f $tmpfile
+ log_fail "Feature $name in unknown state $state"
+ fi
+ done
+
+ log_note "Checked all features"
+
+ rm -f $tmpfile
+}