1#!/bin/ksh -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 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28#
29# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
34
35#
36# DESCRIPTION:
37# 'zpool create' should return an error with badly formed parameters.
38#
39# STRATEGY:
40# 1. Create an array of parameters
41# 2. For each parameter in the array, execute 'zpool create'
42# 3. Verify an error is returned.
43#
44
45verify_runnable "global"
46
47set -A args  "" "-?" "-n" "-f" "-nf" "-fn" "-f -n" "--f" "-e" "-s" \
48	"-m" "-R" "-m -R" "-Rm" "-mR" "-m $TESTDIR $TESTPOOL" \
49	"-R $TESTDIR $TESTPOOL" "-m nodir $TESTPOOL $DISK0" \
50	"-R nodir $TESTPOOL $DISK0" "-m nodir -R nodir $TESTPOOL $DISK0" \
51	"-R nodir -m nodir $TESTPOOL $DISK0" "-R $TESTDIR -m nodir $TESTPOOL $DISK0" \
52	"-R nodir -m $TESTDIR $TESTPOOL $DISK0" \
53	"-blah" "$TESTPOOL" "$TESTPOOL blah" "$TESTPOOL c?t0d0" \
54	"$TESTPOOL c0txd0" "$TESTPOOL c0t0dx" "$TESTPOOL cxtxdx" \
55	"$TESTPOOL mirror" "$TESTPOOL raidz" "$TESTPOOL mirror raidz" \
56	"$TESTPOOL raidz1" "$TESTPOOL mirror raidz1" \
57	"$TESTPOOL mirror c?t?d?" "$TESTPOOL mirror $DISK0 c0t1d?" \
58	"$TESTPOOL RAIDZ $DISK0 $DISK1" \
59	"$TESTPOOL $DISK0 log $DISK1 log $DISK2" \
60	"$TESTPOOL $DISK0 spare $DISK1 spare $DISK2" \
61	"$TESTPOOL RAIDZ1 $DISK0 $DISK1" \
62	"$TESTPOOL MIRROR $DISK0" "$TESTPOOL raidz $DISK0" \
63	"$TESTPOOL raidz1 $DISK0" \
64	"1tank $DISK0" "1234 $DISK0" "?tank $DISK0" \
65	"tan%k $DISK0" "ta@# $DISK0" "tan+k $DISK0" \
66	"$BYND_MAX_NAME $DISK0"
67
68log_assert "'zpool create' should return an error with badly-formed parameters."
69log_onexit default_cleanup_noexit
70
71typeset -i i=0
72while [[ $i -lt ${#args[*]} ]]; do
73	log_mustnot zpool create ${args[i]}
74	((i = i + 1))
75done
76
77log_pass "'zpool create' with badly formed parameters failed as expected."
78