xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_007_neg.ksh (revision 4c87aefe8930bd07275b8dd2e96ea5f24d93a52e)
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
47if [[ -n $DISK ]]; then
48	disk=$DISK
49else
50	disk=$DISK0
51fi
52
53set -A args  "" "-?" "-n" "-f" "-nf" "-fn" "-f -n" "--f" "-e" "-s" \
54	"-m" "-R" "-m -R" "-Rm" "-mR" "-m $TESTDIR $TESTPOOL" \
55	"-R $TESTDIR $TESTPOOL" "-m nodir $TESTPOOL $disk" \
56	"-R nodir $TESTPOOL $disk" "-m nodir -R nodir $TESTPOOL $disk" \
57	"-R nodir -m nodir $TESTPOOL $disk" "-R $TESTDIR -m nodir $TESTPOOL $disk" \
58	"-R nodir -m $TESTDIR $TESTPOOL $disk" \
59	"-blah" "$TESTPOOL" "$TESTPOOL blah" "$TESTPOOL c?t0d0" \
60	"$TESTPOOL c0txd0" "$TESTPOOL c0t0dx" "$TESTPOOL cxtxdx" \
61	"$TESTPOOL mirror" "$TESTPOOL raidz" "$TESTPOOL mirror raidz" \
62	"$TESTPOOL raidz1" "$TESTPOOL mirror raidz1" \
63	"$TESTPOOL mirror c?t?d?" "$TESTPOOL mirror $disk c0t1d?" \
64	"$TESTPOOL RAIDZ ${disk}s${SLICE0} ${disk}s${SLICE1}" \
65	"$TESTPOOL ${disk}s${SLICE0} log ${disk}s${SLICE1} \
66	log ${disk}s${SLICE3}" \
67	"$TESTPOOL ${disk}s${SLICE0} spare ${disk}s${SLICE1} \
68	spare ${disk}s${SLICE3}" \
69	"$TESTPOOL RAIDZ1 ${disk}s${SLICE0} ${disk}s${SLICE1}" \
70	"$TESTPOOL MIRROR $disk" "$TESTPOOL raidz $disk" \
71	"$TESTPOOL raidz1 $disk" \
72	"1tank $disk" "1234 $disk" "?tank $disk" \
73	"tan%k $disk" "ta@# $disk" "tan+k $disk" \
74	"$BYND_MAX_NAME $disk"
75
76log_assert "'zpool create' should return an error with badly-formed parameters."
77log_onexit default_cleanup_noexit
78
79typeset -i i=0
80while [[ $i -lt ${#args[*]} ]]; do
81	log_mustnot zpool create ${args[i]}
82	((i = i + 1))
83done
84
85log_pass "'zpool create' with badly formed parameters failed as expected."
86