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_010_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_010_neg 39# 40# DESCRIPTION: 41# 'zfs create [-b <blocksize> ] -V <size> <volume>' fails with badly formed 42# <size> or <volume> arguments,including: 43# *Invalid volume size and volume name 44# *Invalid blocksize 45# *Incomplete component in the dataset tree 46# *The volume already exists 47# *The volume name beyond the maximal name length - 256. 48# *Same property set multiple times via '-o property=value' 49# *Filesystems's property set on volume 50# 51# STRATEGY: 52# 1. Create an array of badly formed arguments 53# 2. For each argument, execute 'zfs create -V <size> <volume>' 54# 3. Verify an error is returned. 55# 56# TESTABILITY: explicit 57# 58# TEST_AUTOMATION_LEVEL: automated 59# 60# CODING_STATUS: COMPLETED (2005-07-04) 61# 62# __stc_assertion_end 63# 64################################################################################ 65 66verify_runnable "global" 67 68function cleanup 69{ 70 typeset -i i 71 typeset found 72 73 # 74 # check to see if there is any new fs created during the test 75 # if so destroy it. 76 # 77 for dset in $($ZFS list -H | \ 78 $AWK '{print $1}' | $GREP / ); do 79 found=false 80 i=0 81 while (( $i < ${#existed_fs[*]} )); do 82 if [[ $dset == ${existed_fs[i]} ]]; then 83 found=true 84 break 85 fi 86 (( i = i + 1 )) 87 done 88 89 # 90 # new fs created during the test, cleanup it 91 # 92 if [[ $found == "false" ]]; then 93 log_must $ZFS destroy -f $dset 94 fi 95 done 96} 97 98log_onexit cleanup 99 100log_assert "Verify 'zfs create [-s] [-b <blocksize> ] -V <size> <volume>' fails with" \ 101 "badly-formed <size> or <volume> arguments." 102 103set -A args "$VOLSIZE" "$TESTVOL1" \ 104 "$VOLSIZE $TESTVOL1" "0 $TESTPOOL/$TESTVOL1" \ 105 "-1gb $TESTPOOL/$TESTVOL1" "1g? $TESTPOOL/$TESTVOL1" \ 106 "1.01BB $TESTPOOL/$TESTVOL1" "1%g $TESTPOOL/$TESTVOL1" \ 107 "1g% $TESTPOOL/$TESTVOL1" "1g$ $TESTPOOL/$TESTVOL1" \ 108 "$m $TESTPOOL/$TESTVOL1" "1m$ $TESTPOOL/$TESTVOL1" \ 109 "1m! $TESTPOOL/$TESTVOL1" \ 110 "1gbb $TESTPOOL/blah" "1blah $TESTPOOL/blah" "blah $TESTPOOL/blah" \ 111 "$VOLSIZE $TESTPOOL" "$VOLSIZE $TESTPOOL/" "$VOLSIZE $TESTPOOL//blah"\ 112 "$VOLSIZE $TESTPOOL/blah@blah" "$VOLSIZE $TESTPOOL/blah^blah" \ 113 "$VOLSIZE $TESTPOOL/blah*blah" "$VOLSIZE $TESTPOOL/blah%blah" \ 114 "$VOLSIZE blah" "$VOLSIZE $TESTPOOL/$BYND_MAX_NAME" \ 115 "1m -b $TESTPOOL/$TESTVOL1" "1m -b 11k $TESTPOOL/$TESTVOL1" \ 116 "1m -b 511 $TESTPOOL/$TESTVOL1" "1m -b 256k $TESTPOOL/$TESTVOL1" 117 118set -A options "" "-s" 119 120datasetexists $TESTPOOL/$TESTVOL || \ 121 log_must $ZFS create -V $VOLSIZE $TESTPOOL/$TESTVOL 122 123set -A existed_fs $($ZFS list -H | $AWK '{print $1}' | $GREP / ) 124 125log_mustnot $ZFS create -V $VOLSIZE $TESTPOOL/$TESTVOL 126log_mustnot $ZFS create -s -V $VOLSIZE $TESTPOOL/$TESTVOL 127 128typeset -i i=0 129typeset -i j=0 130while (( i < ${#options[*]} )); do 131 132 j=0 133 while (( j < ${#args[*]} )); do 134 log_mustnot $ZFS create ${options[$i]} -V ${args[$j]} 135 log_mustnot $ZFS create -p ${options[$i]} -V ${args[$j]} 136 137 ((j = j + 1)) 138 done 139 140 j=0 141 while (( $j < ${#RW_VOL_PROP[*]} )); do 142 log_mustnot $ZFS create ${options[$i]} -o ${RW_VOL_PROP[j]} \ 143 -o ${RW_VOL_PROP[j]} -V $VOLSIZE $TESTPOOL/$TESTVOL1 144 log_mustnot $ZFS create -p ${options[$i]} -o ${RW_VOL_PROP[j]} \ 145 -o ${RW_VOL_PROP[j]} -V $VOLSIZE $TESTPOOL/$TESTVOL1 146 ((j = j + 1)) 147 done 148 149 j=0 150 while (( $j < ${#FS_ONLY_PROP[*]} )); do 151 log_mustnot $ZFS create ${options[$i]} -o ${FS_ONLY_PROP[j]} \ 152 -V $VOLSIZE $TESTPOOL/$TESTVOL1 153 log_mustnot $ZFS create -p ${options[$i]} -o ${FS_ONLY_PROP[j]} \ 154 -V $VOLSIZE $TESTPOOL/$TESTVOL1 155 ((j = j + 1)) 156 done 157 158 ((i = i + 1)) 159done 160 161log_pass "'zfs create [-s][-b <blocksize>] -V <size> <volume>' fails as expected." 162