1d583b39John Wren Kennedy#!/bin/ksh -p
2d583b39John Wren Kennedy#
3d583b39John Wren Kennedy# CDDL HEADER START
4d583b39John Wren Kennedy#
5d583b39John Wren Kennedy# The contents of this file are subject to the terms of the
6d583b39John Wren Kennedy# Common Development and Distribution License (the "License").
7d583b39John Wren Kennedy# You may not use this file except in compliance with the License.
8d583b39John Wren Kennedy#
9d583b39John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d583b39John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
11d583b39John Wren Kennedy# See the License for the specific language governing permissions
12d583b39John Wren Kennedy# and limitations under the License.
13d583b39John Wren Kennedy#
14d583b39John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
15d583b39John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16d583b39John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
17d583b39John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
18d583b39John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
19d583b39John Wren Kennedy#
20d583b39John Wren Kennedy# CDDL HEADER END
21d583b39John Wren Kennedy#
22d583b39John Wren Kennedy
23d583b39John Wren Kennedy#
24d583b39John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25d583b39John Wren Kennedy# Use is subject to license terms.
26d583b39John Wren Kennedy#
27d583b39John Wren Kennedy
28d583b39John Wren Kennedy#
294b5c8e9Matthew Ahrens# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
30d583b39John Wren Kennedy#
31d583b39John Wren Kennedy
32d583b39John Wren Kennedy. $STF_SUITE/include/libtest.shlib
33d583b39John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
34d583b39John Wren Kennedy
35d583b39John Wren Kennedy#
36d583b39John Wren Kennedy# DESCRIPTION:
37d583b39John Wren Kennedy# 'zpool create <pool> <vspec> ...' can successfully create a
38d583b39John Wren Kennedy# new pool with a name in ZFS namespace.
39d583b39John Wren Kennedy#
40d583b39John Wren Kennedy# STRATEGY:
41d583b39John Wren Kennedy# 1. Create storage pools with a name in ZFS namespace with different
42d583b39John Wren Kennedy# vdev specs.
43d583b39John Wren Kennedy# 2. Verify the pool created successfully
44d583b39John Wren Kennedy#
45d583b39John Wren Kennedy
46d583b39John Wren Kennedyverify_runnable "global"
47d583b39John Wren Kennedy
48d583b39John Wren Kennedyfunction cleanup
49d583b39John Wren Kennedy{
50d583b39John Wren Kennedy	poolexists $TESTPOOL && destroy_pool $TESTPOOL
51d583b39John Wren Kennedy
52d583b39John Wren Kennedy	clean_blockfile "$TESTDIR0 $TESTDIR1"
53d583b39John Wren Kennedy
54d583b39John Wren Kennedy	if [[ -n $DISK ]]; then
554b5c8e9Matthew Ahrens		partition_disk $((($MINVDEVSIZE / (1024 * 1024)) * 3))m $DISK 7
56d583b39John Wren Kennedy	else
57d583b39John Wren Kennedy		typeset disk=""
58d583b39John Wren Kennedy		for disk in $DISK0 $DISK1; do
594b5c8e9Matthew Ahrens			partition_disk \
604b5c8e9Matthew Ahrens			    $((($MINVDEVSIZE / (1024 * 1024)) * 3))m $disk 7
61d583b39John Wren Kennedy		done
62d583b39John Wren Kennedy	fi
63d583b39John Wren Kennedy}
64d583b39John Wren Kennedy
65d583b39John Wren Kennedylog_assert "'zpool create <pool> <vspec> ...' can successfully create" \
66d583b39John Wren Kennedy	"a new pool with a name in ZFS namespace."
67d583b39John Wren Kennedy
68d583b39John Wren Kennedylog_onexit cleanup
69d583b39John Wren Kennedy
70d583b39John Wren Kennedyset -A keywords "" "mirror" "raidz" "raidz1"
71d583b39John Wren Kennedy
72d583b39John Wren Kennedycase $DISK_ARRAY_NUM in
73d583b39John Wren Kennedy0|1)
74d583b39John Wren Kennedy	typeset disk=""
75d583b39John Wren Kennedy	if (( $DISK_ARRAY_NUM == 0 )); then
76d583b39John Wren Kennedy		disk=$DISK
77d583b39John Wren Kennedy	else
78d583b39John Wren Kennedy		disk=$DISK0
79d583b39John Wren Kennedy	fi
80d583b39John Wren Kennedy	create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}s${SLICE5}
81d583b39John Wren Kennedy        create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 ${disk}s${SLICE6}
82d583b39John Wren Kennedy
83d583b39John Wren Kennedy	pooldevs="${disk}s${SLICE0} \
84d583b39John Wren Kennedy                  /dev/dsk/${disk}s${SLICE0} \
85d583b39John Wren Kennedy                  \"${disk}s${SLICE0} ${disk}s${SLICE1}\" \
86d583b39John Wren Kennedy                  $TESTDIR0/$FILEDISK0"
87d583b39John Wren Kennedy	raidzdevs="\"/dev/dsk/${disk}s${SLICE0} ${disk}s${SLICE1}\" \
88d583b39John Wren Kennedy                   \"${disk}s${SLICE0} ${disk}s${SLICE1} ${disk}s${SLICE3}\" \
89d583b39John Wren Kennedy                   \"${disk}s${SLICE0} ${disk}s${SLICE1} ${disk}s${SLICE3} \
90d583b39John Wren Kennedy                     ${disk}s${SLICE4}\"\
91d583b39John Wren Kennedy                   \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
92d583b39John Wren Kennedy	mirrordevs=$raidzdevs
93d583b39John Wren Kennedy	;;
94d583b39John Wren Kennedy2|*)
95d583b39John Wren Kennedy	create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${DISK0}s${SLICE5}
96d583b39John Wren Kennedy        create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 ${DISK1}s${SLICE5}
97d583b39John Wren Kennedy
98d583b39John Wren Kennedy	pooldevs="${DISK0}s${SLICE0}\
99d583b39John Wren Kennedy                 \"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\" \
100d583b39John Wren Kennedy                 \"${DISK0}s${SLICE0} ${DISK0}s${SLICE1} ${DISK1}s${SLICE1}\"\
101d583b39John Wren Kennedy                 \"${DISK0}s${SLICE0} ${DISK1}s${SLICE0} ${DISK0}s${SLICE1}\
102d583b39John Wren Kennedy                   ${DISK1}s${SLICE1}\" \
103d583b39John Wren Kennedy                 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
104d583b39John Wren Kennedy	raidzdevs="\"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\" \
105d583b39John Wren Kennedy                 \"${DISK0}s${SLICE0} ${DISK0}s${SLICE1} ${DISK1}s${SLICE1}\"\
106d583b39John Wren Kennedy                 \"${DISK0}s${SLICE0} ${DISK1}s${SLICE0} ${DISK0}s${SLICE1}\
107d583b39John Wren Kennedy                   ${DISK1}s${SLICE1}\" \
108d583b39John Wren Kennedy                 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
109d583b39John Wren Kennedy	mirrordevs=$raidzdevs
110d583b39John Wren Kennedy	;;
111d583b39John Wren Kennedyesac
112d583b39John Wren Kennedy
113d583b39John Wren Kennedytypeset -i i=0
114d583b39John Wren Kennedywhile (( $i < ${#keywords[*]} )); do
115d583b39John Wren Kennedy	case ${keywords[i]} in
116d583b39John Wren Kennedy	"")
117d583b39John Wren Kennedy		create_pool_test "$TESTPOOL" "${keywords[i]}" "$pooldevs";;
118d583b39John Wren Kennedy	mirror)
119d583b39John Wren Kennedy		create_pool_test "$TESTPOOL" "${keywords[i]}" "$mirrordevs";;
120d583b39John Wren Kennedy	raidz|raidz1)
121d583b39John Wren Kennedy		create_pool_test "$TESTPOOL" "${keywords[i]}" "$raidzdevs" ;;
122d583b39John Wren Kennedy	esac
123d583b39John Wren Kennedy	(( i = i+1 ))
124d583b39John Wren Kennedydone
125d583b39John Wren Kennedy
126d583b39John Wren Kennedylog_pass "'zpool create <pool> <vspec> ...' success."
127