1 #!/usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 #ident "@(#)zpool_create_011_neg.ksh 1.5 08/11/03 SMI"
31 . $STF_SUITE/include/libtest.kshlib
32 . $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib
34 ################################################################################
36 # __stc_assertion_start
38 # ID: zpool_create_011_neg
41 # 'zpool create' will fail in the following cases:
42 # existent pool; device is part of an active pool; nested virtual devices;
43 # differently sized devices without -f option; device being currently
44 # mounted; devices in /etc/fstab; specified as the dedicated dump device.
47 # 1. Create case scenarios
48 # 2. For each scenario, try to create a new pool with the virtual devices
49 # 3. Verify the creation is failed.
51 # TESTABILITY: explicit
53 # TEST_AUTOMATION_LEVEL: automated
55 # CODING_STATUS: COMPLETED (2005-07-04)
59 ################################################################################
61 verify_runnable "global"
65 for pool in $TESTPOOL $TESTPOOL1
70 if [[ -n $specified_dump_dev ]]; then
71 $DUMPON -r $specified_dump_dev
75 log_assert "'zpool create' should be failed with inapplicable scenarios."
78 if [[ -n $DISK ]]; then
85 mirror1="${disk}p2 ${disk}p3"
86 mirror2="${disk}p4 ${disk}p5"
89 diff_size_dev="${disk}p6 ${disk}p7"
90 fstab_dev=$(find_fstab_dev)
91 specified_dump_dev=${disk}
93 lba=$(get_partition_end $disk 6)
94 $GPART delete -i 7 $disk
95 set_partition 7 "$lba" $SIZE1 $disk
96 create_pool "$TESTPOOL" "$pooldev1"
99 # Set up the testing scenarios parameters
101 set -A arg "$TESTPOOL $pooldev2" \
102 "$TESTPOOL1 $pooldev1" \
103 "$TESTPOOL1 $TESTDIR0/$FILEDISK0" \
104 "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \
105 "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \
106 "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \
107 "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \
108 "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \
109 "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \
110 "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \
111 "$TESTPOOL1 mirror $diff_size_dev" \
112 "$TESTPOOL1 raidz $diff_size_dev" \
113 "$TESTPOOL1 raidz1 $diff_size_dev" \
114 "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
115 "$TESTPOOL1 $fstab_dev" \
116 "$TESTPOOL1 ${disk}s10" \
117 "$TESTPOOL1 spare $pooldev2"
120 while (( i < ${#arg[*]} )); do
121 log_mustnot $ZPOOL create ${arg[i]}
125 # now destroy the pool to be polite
126 log_must $ZPOOL destroy -f $TESTPOOL
128 # create/destroy a pool as a simple way to set the partitioning
129 # back to something normal so we can use this $disk as a dump device
130 log_must $ZPOOL create -f $TESTPOOL3 $disk
131 log_must $ZPOOL destroy -f $TESTPOOL3
133 log_must dumpon $specified_dump_dev
134 log_mustnot $ZPOOL create -f $TESTPOOL1 "$specified_dump_dev"
136 # Also check to see that in-use checking prevents us from creating
137 # a zpool from just the first slice on the disk.
138 log_mustnot $ZPOOL create -f $TESTPOOL1 ${specified_dump_dev}s0
140 log_pass "'zpool create' is failed as expected with inapplicable scenarios."