1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)hotspare_create_001_neg.ksh 1.5 09/06/22 SMI" 30# 31. $STF_SUITE/tests/hotspare/hotspare.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: hotspare_create_001_neg 38# 39# DESCRIPTION: 40# 'zpool create [-f]' with hot spares will fail 41# while the hot spares belong to the following cases: 42# - existing pool 43# - nonexist device, 44# - part of an active pool, 45# - currently mounted, 46# - devices in /etc/vfstab, 47# - specified as the dedicated dump device, 48# - identical with the basic vdev within the pool, 49# 50# STRATEGY: 51# 1. Create case scenarios 52# 2. For each scenario, try to create a new pool with hot spares 53# of the virtual devices 54# 3. Verify the creation is failed. 55# 56# TESTABILITY: explicit 57# 58# TEST_AUTOMATION_LEVEL: automated 59# 60# CODING_STATUS: COMPLETED (2006-06-07) 61# 62# __stc_assertion_end 63# 64################################################################################ 65 66verify_runnable "global" 67 68function cleanup 69{ 70 for pool in $TESTPOOL $TESTPOOL1 71 do 72 destroy_pool $pool 73 done 74 75 if [[ -n $saved_dump_dev ]]; then 76 if [[ -n $DUMPADM ]]; then 77 log_must $DUMPADM -u -d $saved_dump_dev 78 fi 79 fi 80 81 partition_cleanup 82} 83 84log_assert "'zpool create [-f]' with hot spares should be failed " \ 85 "with inapplicable scenarios." 86log_onexit cleanup 87 88set_devs 89 90mnttab_dev=$(find_mnttab_dev) 91vfstab_dev=$(find_vfstab_dev) 92saved_dump_dev=$(save_dump_dev) 93dump_dev=${disk}s0 94nonexist_dev=${disk}sbad_slice_num 95 96create_pool "$TESTPOOL" ${pooldevs[0]} 97 98# 99# Set up the testing scenarios parameters 100# - existing pool 101# - nonexist device, 102# - part of an active pool, 103# - currently mounted, 104# - devices in /etc/vfstab, 105# - identical with the basic vdev within the pool, 106 107set -A arg "$TESTPOOL ${pooldevs[1]} spare ${pooldevs[2]}" \ 108 "$TESTPOOL1 ${pooldevs[1]} spare $nonexist_dev" \ 109 "$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[0]}" \ 110 "$TESTPOOL1 ${pooldevs[1]} spare $mnttab_dev" \ 111 "$TESTPOOL1 ${pooldevs[1]} spare $vfstab_dev" \ 112 "$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[1]}" 113 114typeset -i i=0 115while (( i < ${#arg[*]} )); do 116 log_mustnot $ZPOOL create ${arg[i]} 117 log_mustnot $ZPOOL create -f ${arg[i]} 118 (( i = i + 1 )) 119done 120 121# now destroy the pool to be polite 122log_must $ZPOOL destroy -f $TESTPOOL 123 124# 125# - specified as the dedicated dump device, 126# This part of the test can only be run on platforms for which DUMPADM is 127# defined; ie Solaris 128# 129if [[ -n $DUMPADM ]]; then 130 # create/destroy a pool as a simple way to set the partitioning 131 # back to something normal so we can use this $disk as a dump device 132 cleanup_devices $dump_dev 133 134 log_must $DUMPADM -u -d /dev/$dump_dev 135 log_mustnot $ZPOOL create $TESTPOOL1 ${pooldevs[1]} spare "$dump_dev" 136 log_mustnot $ZPOOL create -f $TESTPOOL1 ${pooldevs[1]} spare "$dump_dev" 137fi 138 139log_pass "'zpool create [-f]' with hot spare is failed as expected with inapplicable scenarios." 140