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]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
37 # Ensure that a set of invalid names cannot be used to create pools.
40 # 1) For each invalid character in the character set, try to create
41 # and destroy the pool. Verify it fails.
42 # 2) Given a list of invalid pool names, ensure the pools are not
46 verify_runnable "global"
48 log_assert "Ensure that a set of invalid names cannot be used to create pools."
50 # Global variable use to cleanup failures.
55 if poolexists $POOLNAME; then
56 log_must zpool destroy $POOLNAME
59 if [[ -d $TESTDIR ]]; then
60 log_must rm -rf $TESTDIR
66 for pool in $(get_all_pools); do
67 if [[ "$pool" != "$TESTPOOL" ]]; then
68 log_must zpool destroy $pool
73 if [[ ! -e $TESTDIR ]]; then
74 log_must mkdir $TESTDIR
77 log_note "Ensure invalid characters fail"
78 for POOLNAME in "!" "\"" "#" "$" "%" "&" "'" "(" ")" \
79 "\*" "+" "," "-" "\." "/" "\\" \
81 ":" ";" "<" "=" ">" "\?" "@" \
82 "[" "]" "^" "_" "\`" "{" "|" "}" "~"
84 log_mustnot zpool create -m $TESTDIR $POOLNAME $DISK
85 if poolexists $POOLNAME; then
86 log_fail "Unexpectedly created pool: '$POOLNAME'"
89 log_mustnot zpool destroy $POOLNAME
92 log_note "Check that invalid octal values fail"
93 for oct in "\000" "\001" "\002" "\003" "\004" "\005" "\006" "\007" \
94 "\010" "\011" "\012" "\013" "\014" "\015" "\017" \
95 "\020" "\021" "\022" "\023" "\024" "\025" "\026" "\027" \
96 "\030" "\031" "\032" "\033" "\034" "\035" "\036" "\037" \
99 POOLNAME=`eval "echo x | tr 'x' '$oct'"`
100 log_mustnot zpool create -m $TESTDIR $POOLNAME $DISK
101 if poolexists $POOLNAME; then
102 log_fail "Unexpectedly created pool: '$POOLNAME'"
105 log_mustnot zpool destroy $POOLNAME
108 log_note "Verify invalid pool names fail"
109 set -A POOLNAME "c0t0d0s0" "c0t0d0" "c0t0d19" "c0t50000E0108D279d0" \
110 "mirror" "raidz" ",," ",,,,,,,,,,,,,,,,,,,,,,,,," \
111 "2222222222222222222" "mirror_pool" "raidz_pool" \
112 "mirror-pool" "raidz-pool" "spare" "spare_pool" \
113 "spare-pool" "raidz1-" "raidz2:" ":aaa" "-bbb" "_ccc" ".ddd"
114 if verify_slog_support ; then
115 POOLNAME[${#POOLNAME[@]}]='log'
118 while ((i < ${#POOLNAME[@]})); do
119 log_mustnot zpool create -m $TESTDIR ${POOLNAME[$i]} $DISK
120 if poolexists ${POOLNAME[$i]}; then
121 log_fail "Unexpectedly created pool: '${POOLNAME[$i]}'"
124 log_mustnot zpool destroy ${POOLNAME[$i]}
129 log_pass "Invalid names and characters were caught correctly"