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