1#!/bin/ksh -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 28# 29# Copyright (c) 2012 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib 34 35# 36# DESCRIPTION: 37# 'zpool create <pool> <vspec> ...' can successfully create a 38# new pool with a name in ZFS namespace. 39# 40# STRATEGY: 41# 1. Create storage pools with a name in ZFS namespace with different 42# vdev specs. 43# 2. Verify the pool created successfully 44# 45 46verify_runnable "global" 47 48function cleanup 49{ 50 poolexists $TESTPOOL && destroy_pool $TESTPOOL 51 52 clean_blockfile "$TESTDIR0 $TESTDIR1" 53 54 if [[ -n $DISK ]]; then 55 partition_disk $SIZE $DISK 7 56 else 57 typeset disk="" 58 for disk in $DISK0 $DISK1; do 59 partition_disk $SIZE $disk 7 60 done 61 fi 62} 63 64log_assert "'zpool create <pool> <vspec> ...' can successfully create" \ 65 "a new pool with a name in ZFS namespace." 66 67log_onexit cleanup 68 69set -A keywords "" "mirror" "raidz" "raidz1" 70 71case $DISK_ARRAY_NUM in 720|1) 73 typeset disk="" 74 if (( $DISK_ARRAY_NUM == 0 )); then 75 disk=$DISK 76 else 77 disk=$DISK0 78 fi 79 create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}s${SLICE5} 80 create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 ${disk}s${SLICE6} 81 82 pooldevs="${disk}s${SLICE0} \ 83 /dev/dsk/${disk}s${SLICE0} \ 84 \"${disk}s${SLICE0} ${disk}s${SLICE1}\" \ 85 $TESTDIR0/$FILEDISK0" 86 raidzdevs="\"/dev/dsk/${disk}s${SLICE0} ${disk}s${SLICE1}\" \ 87 \"${disk}s${SLICE0} ${disk}s${SLICE1} ${disk}s${SLICE3}\" \ 88 \"${disk}s${SLICE0} ${disk}s${SLICE1} ${disk}s${SLICE3} \ 89 ${disk}s${SLICE4}\"\ 90 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\"" 91 mirrordevs=$raidzdevs 92 ;; 932|*) 94 create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${DISK0}s${SLICE5} 95 create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 ${DISK1}s${SLICE5} 96 97 pooldevs="${DISK0}s${SLICE0}\ 98 \"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\" \ 99 \"${DISK0}s${SLICE0} ${DISK0}s${SLICE1} ${DISK1}s${SLICE1}\"\ 100 \"${DISK0}s${SLICE0} ${DISK1}s${SLICE0} ${DISK0}s${SLICE1}\ 101 ${DISK1}s${SLICE1}\" \ 102 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\"" 103 raidzdevs="\"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\" \ 104 \"${DISK0}s${SLICE0} ${DISK0}s${SLICE1} ${DISK1}s${SLICE1}\"\ 105 \"${DISK0}s${SLICE0} ${DISK1}s${SLICE0} ${DISK0}s${SLICE1}\ 106 ${DISK1}s${SLICE1}\" \ 107 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\"" 108 mirrordevs=$raidzdevs 109 ;; 110esac 111 112typeset -i i=0 113while (( $i < ${#keywords[*]} )); do 114 case ${keywords[i]} in 115 "") 116 create_pool_test "$TESTPOOL" "${keywords[i]}" "$pooldevs";; 117 mirror) 118 create_pool_test "$TESTPOOL" "${keywords[i]}" "$mirrordevs";; 119 raidz|raidz1) 120 create_pool_test "$TESTPOOL" "${keywords[i]}" "$raidzdevs" ;; 121 esac 122 (( i = i+1 )) 123done 124 125log_pass "'zpool create <pool> <vspec> ...' success." 126