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 https://opensource.org/licenses/CDDL-1.0.
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 draid1" "$TESTPOOL mirror draid1" \
58	"$TESTPOOL mirror c?t?d?" "$TESTPOOL mirror $DISK0 c0t1d?" \
59	"$TESTPOOL RAIDZ $DISK0 $DISK1" \
60	"$TESTPOOL $DISK0 log $DISK1 log $DISK2" \
61	"$TESTPOOL $DISK0 spare $DISK1 spare $DISK2" \
62	"$TESTPOOL RAIDZ1 $DISK0 $DISK1" "$TESTPOOL MIRROR $DISK0" \
63	"$TESTPOOL DRAID $DISK1 $DISK2 $DISK3" "$TESTPOOL raidz $DISK0" \
64	"$TESTPOOL raidz1 $DISK0" "$TESTPOOL draid $DISK0" \
65	"$TESTPOOL draid2 $DISK0 $DISK1" \
66	"$TESTPOOL draid $DISK0 $DISK1 $DISK2 spare s0-draid1-0" \
67	"1tank $DISK0" "1234 $DISK0" "?tank $DISK0" \
68	"tan%k $DISK0" "ta@# $DISK0" "tan+k $DISK0" \
69	"$BYND_MAX_NAME $DISK0"
70
71log_assert "'zpool create' should return an error with badly-formed parameters."
72log_onexit default_cleanup_noexit
73
74typeset -i i=0
75while [[ $i -lt ${#args[*]} ]]; do
76	log_mustnot zpool create ${args[i]}
77	((i = i + 1))
78done
79
80log_pass "'zpool create' with badly formed parameters failed as expected."
81