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 "@(#)pool_names_002_neg.ksh 1.4 08/11/03 SMI"
32 . $STF_SUITE/include/libtest.kshlib
34 ###############################################################################
36 # __stc_assertion_start
38 # ID: pool_names_002_neg
42 # Ensure that a set of invalid names cannot be used to create pools.
45 # 1) For each invalid character in the character set, try to create
46 # and destroy the pool. Verify it fails.
47 # 2) Given a list of invalid pool names, ensure the pools are not
50 # TESTABILITY: explicit
52 # TEST_AUTOMATION_LEVEL: automated
54 # CODING_STATUS: COMPLETED (2005-11-21)
58 ################################################################################
60 verify_runnable "global"
62 log_assert "Ensure that a set of invalid names cannot be used to create pools."
64 # Global variable use to cleanup failures.
69 destroy_pool $POOLNAME
71 if [[ -d $TESTDIR ]]; then
72 log_must $RM -rf $TESTDIR
78 if [[ ! -e $TESTDIR ]]; then
79 log_must $MKDIR $TESTDIR
82 log_note "Ensure invalid characters fail"
83 for POOLNAME in "!" "\"" "#" "$" "%" "&" "'" "(" ")" \
84 "\*" "+" "," "-" "\." "/" "\\" \
85 ":" ";" "<" "=" ">" "\?" "@" \
86 "[" "]" "^" "_" "\`" "{" "|" "}" "~"
88 log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
89 if poolexists $POOLNAME; then
90 log_fail "Unexpectedly created pool: '$POOLNAME'"
93 log_mustnot $ZPOOL destroy $POOLNAME
96 # poolexists cannot be used to test pools with numeric names, because
97 # "zpool list" will interpret the name as a repeat interval and never return.
98 log_note "Ensure invalid characters fail"
99 for POOLNAME in 0 1 2 3 4 5 6 7 8 9 2222222222222222222
101 log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
102 log_mustnot $ZPOOL destroy $POOLNAME
105 log_note "Check that invalid octal values fail"
106 for oct in "\000" "\001" "\002" "\003" "\004" "\005" "\006" "\007" \
107 "\010" "\011" "\012" "\013" "\014" "\015" "\017" \
108 "\020" "\021" "\022" "\023" "\024" "\025" "\026" "\027" \
109 "\030" "\031" "\032" "\033" "\034" "\035" "\036" "\037" \
112 # Be careful not to print the poolname, because it might be a terminal
114 POOLNAME=`eval "print x | tr 'x' '$oct'"`
115 $ZPOOL create -m $TESTDIR $POOLNAME $DISK > /dev/null 2>&1
117 log_fail "Unexpectedly created pool: \"$oct\""
118 elif poolexists $POOLNAME; then
119 log_fail "Unexpectedly created pool: \"$oct\""
122 $ZPOOL destroy $POOLNAME > /dev/null 2>&1
124 log_fail "Unexpectedly destroyed pool: \"$oct\""
128 log_note "Verify invalid pool names fail"
129 set -A POOLNAME "c0t0d0s0" "c0t0d0" "c0t0d19" "c0t50000E0108D279d0" \
130 "mirror" "raidz" ",," ",,,,,,,,,,,,,,,,,,,,,,,,," \
131 "mirror_pool" "raidz_pool" \
132 "mirror-pool" "raidz-pool" "spare" "spare_pool" \
133 "spare-pool" "raidz1-" "raidz2:" ":aaa" "-bbb" "_ccc" ".ddd"
134 POOLNAME[${#POOLNAME[@]}]='log'
136 while ((i < ${#POOLNAME[@]})); do
137 log_mustnot $ZPOOL create -m $TESTDIR ${POOLNAME[$i]} $DISK
138 if poolexists ${POOLNAME[$i]}; then
139 log_fail "Unexpectedly created pool: '${POOLNAME[$i]}'"
142 log_mustnot $ZPOOL destroy ${POOLNAME[$i]}
147 log_pass "Invalid names and characters were caught correctly"