1# vim: filetype=sh 2# Common routines for replacement tests. 3 4function check_vdev_action # <action> <expect> <opt> <disk1> [disk2] 5{ 6 typeset action=$1 7 typeset expect=$2 8 typeset opt=$3 9 typeset disk1="$4" 10 typeset disk2="$5" 11 12 busy_path $TESTDIR 13 $expect $ZPOOL $action $opt $TESTPOOL $disk1 $disk2 14 reap_children 15 log_must $ZPOOL export $TESTPOOL 16 log_must $ZPOOL import $TESTPOOL 17 log_must $ZFS umount $TESTPOOL/$TESTFS 18 log_must $ZDB -cdui $TESTPOOL/$TESTFS 19 log_must $ZFS mount $TESTPOOL/$TESTFS 20} 21 22function pool_action # <tvd_type> <action> <actionexpect> <existexpect> 23{ 24 typeset tvd_type=$1 25 typeset action=$2 26 typeset actionexpect=$3 27 typeset existexpect=$4 28 29 typeset disk=${disk_array[3]} 30 typeset short=${disk##/dev/} 31 32 for opt in "" "-f"; do 33 [ "$action" = "detach" -a "$opt" = "-f" ] && continue 34 create_pool $TESTPOOL $tvd_type ${disk_array[@]:0:3} 35 log_must $ZFS create $TESTPOOL/$TESTFS 36 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 37 check_vdev_action $action $actionexpect "$opt" \ 38 ${disk_array[0]} $disk 39 40 $existexpect eval "$ZPOOL iostat -v $TESTPOOL | $GREP -q $short" 41 destroy_pool $TESTPOOL 42 done 43} 44 45function replacement_cleanup 46{ 47 poolexists $TESTPOOL && log_must $ZPOOL status $TESTPOOL 48 reap_children 49} 50