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# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)zpool_add_001_pos.ksh 1.4 09/06/22 SMI" 28# 29. $STF_SUITE/include/libtest.kshlib 30. $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib 31 32################################################################################ 33# 34# __stc_assertion_start 35# 36# ID: zpool_add_001_pos 37# 38# DESCRIPTION: 39# 'zpool add <pool> <vdev> ...' can successfully add the specified 40# devices to the given pool 41# 42# STRATEGY: 43# 1. Create a storage pool 44# 2. Add spare devices to the pool 45# 3. Verify the devices are added to the pool successfully 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING STATUS: COMPLETED (2005-09-27) 52# 53# __stc_assertion_end 54# 55############################################################################### 56 57verify_runnable "global" 58 59log_assert "'zpool add <pool> <vdev> ...' can add devices to the pool." 60 61set -A keywords "" "mirror" "raidz" "raidz1" "spare" 62 63set_disks 64 65typeset diskname0=${DISK0#/dev/} 66typeset diskname1=${DISK1#/dev/} 67typeset diskname2=${DISK2#/dev/} 68typeset diskname3=${DISK3#/dev/} 69typeset diskname4=${DISK4#/dev/} 70 71pooldevs="${diskname0}\ 72 \"/dev/${diskname0} ${diskname1}\" \ 73 \"${diskname0} ${diskname1} ${diskname2}\"" 74mirrordevs="\"/dev/${diskname0} ${diskname1}\"" 75raidzdevs="\"/dev/${diskname0} ${diskname1}\"" 76 77typeset -i i=0 78typeset vdev 79eval set -A poolarray $pooldevs 80eval set -A mirrorarray $mirrordevs 81eval set -A raidzarray $raidzdevs 82 83while (( $i < ${#keywords[*]} )); do 84 case ${keywords[i]} in 85 ""|spare) 86 for vdev in "${poolarray[@]}"; do 87 create_pool "$TESTPOOL" "${diskname3}" 88 log_must poolexists "$TESTPOOL" 89 log_must $ZPOOL add -f "$TESTPOOL" ${keywords[i]} \ 90 $vdev 91 log_must iscontained "$TESTPOOL" "$vdev" 92 destroy_pool "$TESTPOOL" 93 done 94 95 ;; 96 mirror) 97 for vdev in "${mirrorarray[@]}"; do 98 create_pool "$TESTPOOL" "${keywords[i]}" \ 99 "${diskname3}" "${diskname4}" 100 log_must poolexists "$TESTPOOL" 101 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \ 102 $vdev 103 log_must iscontained "$TESTPOOL" "$vdev" 104 destroy_pool "$TESTPOOL" 105 done 106 107 ;; 108 raidz|raidz1) 109 for vdev in "${raidzarray[@]}"; do 110 create_pool "$TESTPOOL" "${keywords[i]}" \ 111 "${diskname3}" "${diskname4}" 112 log_must poolexists "$TESTPOOL" 113 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \ 114 $vdev 115 log_must iscontained "$TESTPOOL" "$vdev" 116 destroy_pool "$TESTPOOL" 117 done 118 119 ;; 120 esac 121 122 (( i = i+1 )) 123done 124 125log_pass "'zpool add <pool> <vdev> ...' executes successfully" 126