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