diff options
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib')
| -rw-r--r-- | sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib | 56 | 
1 files changed, 55 insertions, 1 deletions
| diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib index 23e89599cae0..8b30b9b91641 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib @@ -1085,7 +1085,7 @@ function fill_fs # destdir dirnum filenum bytes num_writes data  	typeset -i filenum=${3:-50}  	typeset -i bytes=${4:-8192}  	typeset -i num_writes=${5:-10240} -	typeset data=${6:-0} +	typeset data=${6:-"R"}  	mkdir -p $destdir/{1..$dirnum}  	for f in $destdir/{1..$dirnum}/$TESTFILE{1..$filenum}; do @@ -1112,6 +1112,16 @@ function get_pool_prop # property pool  	zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool"  } +# Get the specified vdev property in parsable format or fail +function get_vdev_prop +{ +	typeset prop="$1" +	typeset pool="$2" +	typeset vdev="$3" + +	zpool get -Hpo value "$prop" "$pool" "$vdev" || log_fail "zpool get $prop $pool $vdev" +} +  # Return 0 if a pool exists; $? otherwise  #  # $1 - pool name @@ -1971,6 +1981,28 @@ function wait_vdev_state # pool disk state timeout  }  # +# Wait for vdev 'sit_out' property to be cleared. +# +# $1 pool name +# $2 vdev name +# $3 timeout +# +function wait_sit_out #pool vdev timeout +{ +	typeset pool=${1:-$TESTPOOL} +	typeset vdev="$2" +	typeset timeout=${3:-300} +	for (( timer = 0; timer < $timeout; timer++ )); do +		if [ "$(get_vdev_prop sit_out "$pool" "$vdev")" = "off" ]; then +			return 0 +		fi +		sleep 1; +	done + +	return 1 +} + +#  # Check the output of 'zpool status -v <pool>',  # and to see if the content of <token> contain the <keyword> specified.  # @@ -2881,6 +2913,28 @@ function user_run  	log_note "user: $user"  	log_note "cmd: $*" +	if ! sudo -Eu $user test -x $PATH ; then +		log_note "-------------------------------------------------" +		log_note "Warning: $user doesn't have permissions on $PATH" +		log_note "" +		log_note "This usually happens when you're running ZTS locally" +		log_note "from inside the ZFS source dir, and are attempting to" +		log_note "run a test that calls user_run.  The ephemeral user" +		log_note "($user) that ZTS is creating does not have permission" +		log_note "to traverse to $PATH, or the binaries in $PATH are" +		log_note "not the right permissions." +		log_note "" +		log_note "To get around this, copy your ZFS source directory" +		log_note "to a world-accessible location (like /tmp), and " +		log_note "change the permissions on your ZFS source dir " +		log_note "to allow access." +		log_note "" +		log_note "Also, verify that /dev/zfs is RW for others:" +		log_note "" +		log_note "    sudo chmod o+rw /dev/zfs" +		log_note "-------------------------------------------------" +	fi +  	typeset out=$TEST_BASE_DIR/out  	typeset err=$TEST_BASE_DIR/err | 
