Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/cddl/zfs/tests/hotspare/hotspare_add_003_neg.ksh
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
# CODING_STATUS: COMPLETED (2006-06-07) | # CODING_STATUS: COMPLETED (2006-06-07) | ||||
# | # | ||||
# __stc_assertion_end | # __stc_assertion_end | ||||
# | # | ||||
############################################################################### | ############################################################################### | ||||
verify_runnable "global" | verify_runnable "global" | ||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241070 | |||||
bug_241070_is_fixed=false | |||||
function cleanup | function cleanup | ||||
{ | { | ||||
poolexists "$TESTPOOL" && \ | poolexists "$TESTPOOL" && \ | ||||
destroy_pool "$TESTPOOL" | destroy_pool "$TESTPOOL" | ||||
poolexists "$TESTPOOL1" && \ | poolexists "$TESTPOOL1" && \ | ||||
destroy_pool "$TESTPOOL1" | destroy_pool "$TESTPOOL1" | ||||
if $bug_241070_is_fixed; then | log_onfail $UMOUNT $TMPDIR/mounted_dir | ||||
log_must $DUMPON -r $dump_dev | log_onfail $SWAPOFF $swap_dev | ||||
fi | log_onfail $DUMPON -r $dump_dev | ||||
log_must $UMOUNT $TMPDIR/mounted_dir | |||||
log_must $SWAPOFF $swap_dev | |||||
partition_cleanup | partition_cleanup | ||||
} | } | ||||
log_assert "'zpool add [-f]' with hot spares should fail with inapplicable scenarios." | log_assert "'zpool add [-f]' with hot spares should fail with inapplicable scenarios." | ||||
log_onexit cleanup | log_onexit cleanup | ||||
set_devs | set_devs | ||||
Show All 10 Lines | |||||
log_must poolexists "$TESTPOOL1" | log_must poolexists "$TESTPOOL1" | ||||
log_must $MKDIR $TMPDIR/mounted_dir | log_must $MKDIR $TMPDIR/mounted_dir | ||||
log_must $NEWFS $mounted_dev | log_must $NEWFS $mounted_dev | ||||
log_must $MOUNT $mounted_dev $TMPDIR/mounted_dir | log_must $MOUNT $mounted_dev $TMPDIR/mounted_dir | ||||
log_must $SWAPON $swap_dev | log_must $SWAPON $swap_dev | ||||
if $bug_241070_is_fixed; then | |||||
log_must $DUMPON $dump_dev | log_must $DUMPON $dump_dev | ||||
fi | |||||
# - nonexistent device, | # - nonexistent device, | ||||
# - part of an active pool, | # - part of an active pool, | ||||
# - currently mounted, | # - currently mounted, | ||||
# - a swap device, | # - a swap device, | ||||
# - a dump device, | |||||
# - identical with the basic or spares vdev within the pool, | # - identical with the basic or spares vdev within the pool, | ||||
set -A arg "$nonexist_dev" \ | set -A arg "$nonexist_dev" \ | ||||
"${pooldevs[0]}" \ | "${pooldevs[0]}" \ | ||||
"${pooldevs[1]}" \ | "${pooldevs[1]}" \ | ||||
"$mounted_dev" \ | "$mounted_dev" \ | ||||
"$swap_dev" | "$swap_dev" | ||||
# if $bug_241070_is_fixed | |||||
#"$dump_dev" | |||||
typeset -i i=0 | typeset -i i=0 | ||||
while (( i < ${#arg[*]} )); do | while (( i < ${#arg[*]} )); do | ||||
if [[ -n "${arg[i]}" ]]; then | if [[ -n "${arg[i]}" ]]; then | ||||
log_mustnot $ZPOOL add $TESTPOOL spare ${arg[i]} | log_mustnot $ZPOOL add $TESTPOOL spare ${arg[i]} | ||||
log_mustnot $ZPOOL add -f $TESTPOOL spare ${arg[i]} | log_mustnot $ZPOOL add -f $TESTPOOL spare ${arg[i]} | ||||
fi | fi | ||||
(( i = i + 1 )) | (( i = i + 1 )) | ||||
done | done | ||||
# - a dump device, | |||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241070 | |||||
# When that bug is fixed, add $dump_dev to $arg and remove this block. | |||||
log_must $ZPOOL add $TESTPOOL spare ${dump_dev} | |||||
log_must $ZPOOL add -f $TESTPOOL spare ${dump_dev} | |||||
# - belong to a exported or potentially active ZFS pool, | # - belong to a exported or potentially active ZFS pool, | ||||
log_must $ZPOOL export $TESTPOOL1 | log_must $ZPOOL export $TESTPOOL1 | ||||
log_mustnot $ZPOOL add "$TESTPOOL" spare ${pooldevs[1]} | log_mustnot $ZPOOL add "$TESTPOOL" spare ${pooldevs[1]} | ||||
log_must $ZPOOL import -d $HOTSPARE_TMPDIR $TESTPOOL1 | log_must $ZPOOL import -d $HOTSPARE_TMPDIR $TESTPOOL1 | ||||
log_pass "'zpool add [-f]' with hot spares should fail with inapplicable scenarios." | log_pass "'zpool add [-f]' with hot spares should fail with inapplicable scenarios." |