aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib')
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib40
1 files changed, 38 insertions, 2 deletions
diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib
index d979d6874f9b..974e19c04269 100644
--- a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib
+++ b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib
@@ -1171,6 +1171,22 @@ function datasetnonexists
return 0
}
+# Check if the specified dataset property has the expected value or fail
+function dataset_has_prop # property expected_value dataset
+{
+ typeset prop=$1
+ typeset expected=$2
+ typeset dataset=$3
+
+ typeset value=""
+
+ value="$(get_prop "$prop" "$dataset")"
+ [[ "$value" == "$expected" ]] || {
+ log_note "dataset $dataset: property $prop == $value (!= $expected)"
+ return 1
+ }
+}
+
# FreeBSD breaks exports(5) at whitespace and doesn't process escapes
# Solaris just breaks
#
@@ -2629,11 +2645,16 @@ function verify_opt_p_ops
typeset datatype=$2
typeset dataset=$3
typeset newdataset=$4
+ typeset popt=$5
if [[ $datatype != "fs" && $datatype != "vol" ]]; then
log_fail "$datatype is not supported."
fi
+ if [[ -z "$popt" ]]; then
+ popt=-p
+ fi
+
# check parameters accordingly
case $ops in
create)
@@ -2671,7 +2692,7 @@ function verify_opt_p_ops
log_mustnot datasetexists $newdataset ${newdataset%/*}
# with -p option, operation should succeed
- log_must zfs $ops -p $dataset $newdataset
+ log_must zfs $ops $popt $dataset $newdataset
block_device_wait
if ! datasetexists $newdataset ; then
@@ -2680,7 +2701,7 @@ function verify_opt_p_ops
# when $ops is create or clone, redo the operation still return zero
if [[ $ops != "rename" ]]; then
- log_must zfs $ops -p $dataset $newdataset
+ log_must zfs $ops $popt $dataset $newdataset
fi
return 0
@@ -3140,6 +3161,21 @@ function wait_scrubbed #pool timeout
done
}
+# Wait for a pool to be resilvered
+#
+# $1 pool name
+# $2 timeout
+#
+function wait_resilvered #pool timeout
+{
+ typeset timeout=${2:-300}
+ typeset pool=${1:-$TESTPOOL}
+ for (( timer = 0; timer < $timeout; timer++ )); do
+ is_pool_resilvered $pool && break;
+ sleep 1;
+ done
+}
+
# Backup the zed.rc in our test directory so that we can edit it for our test.
#
# Returns: Backup file name. You will need to pass this to zed_rc_restore().