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