]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_001_pos.ksh
Add the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_create / zpool_create_001_pos.ksh
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
46 verify_runnable "global"
47
48 function 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
64 log_assert "'zpool create <pool> <vspec> ...' can successfully create" \
65 "a new pool with a name in ZFS namespace."
66
67 log_onexit cleanup
68
69 set -A keywords "" "mirror" "raidz" "raidz1"
70
71 case $DISK_ARRAY_NUM in
72 0|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 \
80 ${disk}${SLICE_PREFIX}${SLICE5}
81 create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 \
82 ${disk}${SLICE_PREFIX}${SLICE6}
83
84 pooldevs="${disk}${SLICE_PREFIX}${SLICE0} \
85 ${DEV_DSKDIR}/${disk}${SLICE_PREFIX}${SLICE0} \
86 \"${disk}${SLICE_PREFIX}${SLICE0} \
87 ${disk}${SLICE_PREFIX}${SLICE1}\" \
88 $TESTDIR0/$FILEDISK0"
89 raidzdevs="\"${DEV_DSKDIR}/${disk}${SLICE_PREFIX}${SLICE0} \
90 ${disk}${SLICE_PREFIX}${SLICE1}\" \
91 \"${disk}${SLICE_PREFIX}${SLICE0} \
92 ${disk}${SLICE_PREFIX}${SLICE1} \
93 ${disk}${SLICE_PREFIX}${SLICE3}\" \
94 \"${disk}${SLICE_PREFIX}${SLICE0} \
95 ${disk}${SLICE_PREFIX}${SLICE1} \
96 ${disk}${SLICE_PREFIX}${SLICE3} \
97 ${disk}${SLICE_PREFIX}${SLICE4}\"\
98 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
99 mirrordevs=$raidzdevs
100 ;;
101 2|*)
102 create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 \
103 ${DISK0}${SLICE_PREFIX}${SLICE5}
104 create_blockfile $FILESIZE $TESTDIR1/$FILEDISK1 \
105 ${DISK1}${SLICE_PREFIX}${SLICE5}
106
107 pooldevs="${DISK0}${SLICE_PREFIX}${SLICE0} \
108 \"${DEV_DSKDIR}/${DISK0}${SLICE_PREFIX}${SLICE0} \
109 ${DISK1}${SLICE_PREFIX}${SLICE0}\" \
110 \"${DISK0}${SLICE_PREFIX}${SLICE0} \
111 ${DISK0}${SLICE_PREFIX}${SLICE1} \
112 ${DISK1}${SLICE_PREFIX}${SLICE1}\"\
113 \"${DISK0}${SLICE_PREFIX}${SLICE0} \
114 ${DISK1}${SLICE_PREFIX}${SLICE0} \
115 ${DISK0}${SLICE_PREFIX}${SLICE1}\
116 ${DISK1}${SLICE_PREFIX}${SLICE1}\" \
117 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
118 raidzdevs="\"${DEV_DSKDIR}/${DISK0}${SLICE_PREFIX}${SLICE0} \
119 ${DISK1}${SLICE_PREFIX}${SLICE0}\" \
120 \"${DISK0}${SLICE_PREFIX}${SLICE0} \
121 ${DISK0}${SLICE_PREFIX}${SLICE1} \
122 ${DISK1}${SLICE_PREFIX}${SLICE1}\" \
123 \"${DISK0}${SLICE_PREFIX}${SLICE0} \
124 ${DISK1}${SLICE_PREFIX}${SLICE0} \
125 ${DISK0}${SLICE_PREFIX}${SLICE1} \
126 ${DISK1}${SLICE_PREFIX}${SLICE1}\" \
127 \"$TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1\""
128 mirrordevs=$raidzdevs
129 ;;
130 esac
131
132 typeset -i i=0
133 while (( $i < ${#keywords[*]} )); do
134 case ${keywords[i]} in
135 "")
136 create_pool_test "$TESTPOOL" "${keywords[i]}" "$pooldevs";;
137 mirror)
138 create_pool_test "$TESTPOOL" "${keywords[i]}" "$mirrordevs";;
139 raidz|raidz1)
140 create_pool_test "$TESTPOOL" "${keywords[i]}" "$raidzdevs" ;;
141 esac
142 (( i = i+1 ))
143 done
144
145 log_pass "'zpool create <pool> <vspec> ...' success."