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_008_neg.ksh	1.4	07/10/09 SMI"
30#
31. $STF_SUITE/include/libtest.kshlib
32
33################################################################################
34#
35# __stc_assertion_start
36#
37# ID: zfs_create_008_neg
38#
39# DESCRIPTION:
40# 'zfs create' should return an error with badly formed parameters.
41#
42# STRATEGY:
43# 1. Create an array of parameters
44# 2. For each parameter in the array, execute 'zfs create'
45# 3. Verify an error is returned.
46#
47# TESTABILITY: explicit
48#
49# TEST_AUTOMATION_LEVEL: automated
50#
51# CODING_STATUS: COMPLETED (2005-07-04)
52#
53# __stc_assertion_end
54#
55################################################################################
56
57verify_runnable "both"
58
59function cleanup
60{
61	if datasetexists $TESTPOOL/$TESTFS1 ; then
62		log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
63	fi
64}
65
66log_onexit cleanup
67
68set -A args "ab" "-?" "-cV" "-Vc" "-c -V" "c" "V" "--c" "-e" "-s" \
69    "-blah" "-cV 12k" "-s -cV 1P" "-sc" "-Vs 5g" "-o" "--o" "-O" "--O" \
70    "-o QuOta=none" "-o quota=non" "-o quota=abcd" "-o quota=0" "-o quota=" \
71    "-o ResErVaTi0n=none" "-o reserV=none" "-o reservation=abcd" "-o reserv=" \
72    "-o recorDSize=64k" "-o recordsize=256K" "-o recordsize=256" \
73    "-o recsize=" "-o recsize=zero" "-o recordsize=0" \
74    "-o mountPoint=/tmp/tmpfile${TESTCASE_ID}" "-o mountpoint=non0" "-o mountpoint=" \
75    "-o mountpoint=LEGACY" "-o mounpoint=none" \
76    "-o sharenfs=ON" "-o ShareNFS=off" "-o sharenfs=sss" \
77    "-o checkSUM=on" "-o checksum=SHA256" "-o chsum=off" "-o checksum=aaa" \
78    "-o checkSUM=on -V $VOLSIZE" "-o checksum=SHA256 -V $VOLSIZE" \
79    "-o chsum=off -V $VOLSIZE" "-o checksum=aaa -V $VOLSIZE" \
80    "-o compression=of" "-o ComPression=lzjb" "-o compress=ON" "-o compress=a" \
81    "-o compression=of -V $VOLSIZE" "-o ComPression=lzjb -V $VOLSIZE" \
82    "-o compress=ON -V $VOLSIZE" "-o compress=a -V $VOLSIZE" \
83    "-o atime=ON" "-o ATime=off" "-o atime=bbb" \
84    "-o deviCes=on" "-o devices=OFF" "-o devices=aaa" \
85    "-o exec=ON" "-o EXec=off" "-o exec=aaa" \
86    "-o readonly=ON" "-o reADOnly=off" "-o rdonly=OFF" "-o rdonly=aaa" \
87    "-o readonly=ON -V $VOLSIZE" "-o reADOnly=off -V $VOLSIZE" \
88    "-o rdonly=OFF -V $VOLSIZE" "-o rdonly=aaa -V $VOLSIZE" \
89    "-o zoned=ON" "-o ZoNed=off" "-o zoned=aaa" \
90    "-o snapdIR=hidden" "-o snapdir=VISible" "-o snapdir=aaa" \
91    "-o aclmode=DIScard" "-o aclmODE=groupmask" "-o aclmode=aaa" \
92    "-o aclinherit=deny" "-o aclinHerit=secure" "-o aclinherit=aaa" \
93    "-o type=volume" "-o type=snapshot" "-o type=filesystem" \
94    "-o type=volume -V $VOLSIZE" "-o type=snapshot -V $VOLSIZE" \
95    "-o type=filesystem -V $VOLSIZE" \
96    "-o creation=aaa" "-o creation=aaa -V $VOLSIZE" \
97    "-o used=10K" "-o used=10K -V $VOLSIZE" \
98    "-o available=10K" "-o available=10K -V $VOLSIZE" \
99    "-o referenced=10K" "-o referenced=10K -V $VOLSIZE" \
100    "-o compressratio=1.00x" "-o compressratio=1.00x -V $VOLSIZE" \
101    "-o version=0" "-o version=1.234" "-o version=10K" "-o version=-1" \
102    "-o version=aaa" "-o version=999"
103
104log_assert "'zfs create' should return an error with badly-formed parameters."
105
106typeset -i i=0
107while [[ $i -lt ${#args[*]} ]]; do
108	log_mustnot $ZFS create ${args[i]} $TESTPOOL/$TESTFS1
109	log_mustnot $ZFS create -p ${args[i]} $TESTPOOL/$TESTFS1
110	((i = i + 1))
111done
112
113log_pass "'zfs create' with badly formed parameters failed as expected."
114