1#!/usr/local/bin/ksh93 -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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27. $STF_SUITE/tests/cli_root/zfs_create/properties.kshlib 28 29################################################################################ 30# 31# __stc_assertion_start 32# 33# ID: zfs_create_009_neg 34# 35# DESCRIPTION: 36# 'zfs create <filesystem>' fails with bad <filesystem> arguments, including: 37# *Invalid character against the ZFS namespace 38# *Incomplete component 39# *Too many arguments 40# *Filesystem already exists 41# *Beyond maximal name length. 42# *Same property set multiple times via '-o property=value' 43# *Volume's property set on filesystem 44# 45# STRATEGY: 46# 1. Create an array of <filesystem> arguments 47# 2. Execute 'zfs create <filesystem>' with each argument 48# 3. Verify an error is returned. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-07-04) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62function cleanup 63{ 64 typeset -i i 65 typeset found 66 67 # 68 # check to see if there is any new fs created during the test 69 # if so destroy it. 70 # 71 for dset in $($ZFS list -H | \ 72 $AWK '{print $1}' | $GREP / ); do 73 found=false 74 i=0 75 while (( $i < ${#existed_fs[*]} )); do 76 if [[ $dset == ${existed_fs[i]} ]]; then 77 found=true 78 break 79 fi 80 (( i = i + 1 )) 81 done 82 83 # 84 # new fs created during the test, cleanup it 85 # 86 if [[ $found == "false" ]]; then 87 log_must $ZFS destroy -f $dset 88 fi 89 done 90} 91 92log_onexit cleanup 93 94set -A args "$TESTPOOL/" "$TESTPOOL//blah" "$TESTPOOL/@blah" \ 95 "$TESTPOOL/blah@blah" "$TESTPOOL/blah^blah" "$TESTPOOL/blah%blah" \ 96 "$TESTPOOL/blah*blah" "$TESTPOOL/blah blah" \ 97 "-s $TESTPOOL/$TESTFS1" "-b 1092 $TESTPOOL/$TESTFS1" \ 98 "-b 64k $TESTPOOL/$TESTFS1" "-s -b 32k $TESTPOOL/$TESTFS1" \ 99 "$TESTPOOL/$BYND_MAX_NAME" 100 101log_assert "Verify 'zfs create <filesystem>' fails with bad <filesystem> argument." 102 103datasetexists $TESTPOOL/$TESTFS || \ 104 log_must $ZFS create $TESTPOOL/$TESTFS 105 106set -A existed_fs $($ZFS list -H | $AWK '{print $1}' | $GREP / ) 107 108log_mustnot $ZFS create $TESTPOOL 109log_mustnot $ZFS create $TESTPOOL/$TESTFS 110 111typeset -i i=0 112while (( $i < ${#args[*]} )); do 113 log_mustnot $ZFS create ${args[$i]} 114 log_mustnot $ZFS create -p ${args[$i]} 115 ((i = i + 1)) 116done 117 118i=0 119while (( $i < ${#RW_FS_PROP[*]} )); do 120 log_mustnot $ZFS create -o ${RW_FS_PROP[i]} -o ${RW_FS_PROP[i]} \ 121 $TESTPOOL/$TESTFS1 122 log_mustnot $ZFS create -p -o ${RW_FS_PROP[i]} -o ${RW_FS_PROP[i]} \ 123 $TESTPOOL/$TESTFS1 124 ((i = i + 1)) 125done 126 127i=0 128while (( $i < ${#VOL_ONLY_PROP[*]} )); do 129 log_mustnot $ZFS create -o ${VOL_ONLY_PROP[i]} $TESTPOOL/$TESTFS1 130 log_mustnot $ZFS create -p -o ${VOL_ONLY_PROP[i]} $TESTPOOL/$TESTFS1 131 ((i = i + 1)) 132done 133 134log_pass "'zfs create <filesystem>' fails as expected with bad <filesystem> argument." 135