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_create_001_pos.ksh	1.4	09/05/19 SMI"
28#
29. $STF_SUITE/include/libtest.kshlib
30. $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib
31
32################################################################################
33#
34# __stc_assertion_start
35#
36# ID: zpool_create_001_pos
37#
38# DESCRIPTION:
39# 'zpool create <pool> <vspec> ...' can successfully create a
40# new pool with a name in ZFS namespace.
41#
42# STRATEGY:
43# 1. Create storage pools with a name in ZFS namespace with different
44# vdev specs.
45# 2. Verify the pool created successfully
46#
47# TESTABILITY: explicit
48#
49# TEST_AUTOMATION_LEVEL: automated
50#
51# CODING_STATUS: COMPLETED (2005-07-04)
52#
53# __stc_assertion_end
54#
55################################################################################
56
57verify_runnable "global"
58
59function cleanup
60{
61	poolexists $TESTPOOL && destroy_pool $TESTPOOL
62
63	clean_blockfile "$TESTDIR0 $TESTDIR1"
64}
65
66log_assert "'zpool create <pool> <vspec> ...' can successfully create" \
67	"a new pool with a name in ZFS namespace."
68
69log_onexit cleanup
70
71set -A keywords "" "mirror" "raidz" "raidz1"
72
73typeset diskname0=${DISK0#/dev/}
74typeset diskname1=${DISK1#/dev/}
75
76case $DISK_ARRAY_NUM in
770|1)
78	typeset disk=""
79	if (( $DISK_ARRAY_NUM == 0 )); then
80		disk=$DISK
81	else
82		disk=$DISK0
83	fi
84	typeset diskname=${disk#/dev/}
85	create_blockfile ${disk}p5 $TESTDIR0/$FILEDISK0
86	create_blockfile ${disk}p6 $TESTDIR1/$FILEDISK1
87
88	pooldevs="${diskname}p1 \
89                  /dev/${diskname}p1 \
90                  \"${diskname}p1 ${diskname}p2\" \
91                  $TESTDIR0/$FILEDISK0"
92	raidzdevs="\"/dev/${diskname}p1 ${diskname}p2\" \
93                   \"${diskname}p1 ${diskname}p2 ${diskname}p3\" \
94                   \"${diskname}p1 ${diskname}p2 ${diskname}p3 \
95                     ${diskname}p4\"\
96                   \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
97	mirrordevs=$raidzdevs
98	;;
992|*)
100	create_blockfile ${DISK0}p5 $TESTDIR0/$FILEDISK0
101	create_blockfile ${DISK1}p5 $TESTDIR1/$FILEDISK1
102
103	pooldevs="${diskname0}p1\
104                 \"/dev/${diskname0}p1 ${diskname1}p1\" \
105                 \"${diskname0}p1 ${diskname0}p2 ${diskname1}p2\"\
106                 \"${diskname0}p1 ${diskname1}p1 ${diskname0}p2\
107                   ${diskname1}p2\" \
108                 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
109 	raidzdevs="\"/dev/${diskname0}p1 ${diskname1}p1\" \
110                 \"${diskname0}p1 ${diskname0}p2 ${diskname1}p2\"\
111                 \"${diskname0}p1 ${diskname1}p1 ${diskname0}p2\
112                   ${diskname1}p2\" \
113                 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
114	mirrordevs=$raidzdevs
115	;;
116esac
117
118typeset -i i=0
119while (( $i < ${#keywords[*]} )); do
120	case ${keywords[i]} in
121	"")
122		create_pool_test "$TESTPOOL" "${keywords[i]}" "$pooldevs";;
123	mirror)
124		create_pool_test "$TESTPOOL" "${keywords[i]}" "$mirrordevs";;
125	raidz|raidz1)
126		create_pool_test "$TESTPOOL" "${keywords[i]}" "$raidzdevs" ;;
127	esac
128	(( i = i+1 ))
129done
130
131log_pass "'zpool create <pool> <vspec> ...' success."
132