]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_002_neg.ksh
a4c8a28992d98513c5c2d212ef4ce504f06d65e5
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_set / zpool_set_002_neg.ksh
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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012, 2015 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33
34 #
35 # DESCRIPTION:
36 #
37 # Malformed zpool set commands are rejected
38 #
39 # STRATEGY:
40 # 1. Create an array of many different malformed zfs set arguments
41 # 2. Run zpool set for each arg checking each will exit with status code 1
42 #
43 #
44
45 verify_runnable "global"
46
47 # note to self - need to make sure there isn't a pool called bootfs
48 # before running this test...
49 function cleanup {
50
51 $ZPOOL destroy bootfs
52 $RM /tmp/zpool_set_002.$$.dat
53 }
54
55 log_assert "Malformed zpool set commands are rejected"
56
57 if poolexists bootfs
58 then
59 log_unsupported "Unable to run test on a machine with a pool called \
60 bootfs"
61 fi
62
63 log_onexit cleanup
64
65 # build up an array of bad arguments.
66 set -A arguments "rubbish " \
67 "foo@bar= " \
68 "@@@= +pool " \
69 "zpool bootfs " \
70 "bootfs " \
71 "bootfs +" \
72 "bootfs=bootfs/123 " \
73 "bootfs=bootfs@val " \
74 "Bootfs=bootfs " \
75 "- " \
76 "== " \
77 "set " \
78 "@@ " \
79 "12345 " \
80 "€にほんご " \
81 "/ " \
82 "bootfs=bootfs /" \
83 "bootfs=a%d%s "
84
85
86 # here, we build up a large string.
87 # a word to the ksh-wary, ${#array[@]} gives you the
88 # total number of entries in an array, so array[${#array[@]}]
89 # will index the last entry+1, ksh arrays start at index 0.
90 COUNT=0
91 while [ $COUNT -le 1025 ]
92 do
93 bigname="${bigname}o"
94 COUNT=$(( $COUNT + 1 ))
95 done
96
97 # add an argument of maximum length property name
98 arguments[${#arguments[@]}]="$bigname=value"
99
100 # add an argument of maximum length property value
101 arguments[${#arguments[@]}]="bootfs=$bigname"
102
103 # Create a pool called bootfs (so-called, so as to trip any clashes between
104 # property name, and pool name)
105 # Also create a filesystem in this pool
106 log_must $MKFILE $MINVDEVSIZE /tmp/zpool_set_002.$$.dat
107 log_must $ZPOOL create bootfs /tmp/zpool_set_002.$$.dat
108 log_must $ZFS create bootfs/root
109
110 typeset -i i=0;
111 while [ $i -lt "${#arguments[@]}" ]
112 do
113 log_mustnot eval "$ZPOOL set ${arguments[$i]} > /dev/null 2>&1"
114
115 # now also try with a valid pool in the argument list
116 log_mustnot eval "$ZPOOL set ${arguments[$i]}bootfs > /dev/null 2>&1"
117
118 # now also try with two valid pools in the argument list
119 log_mustnot eval "$ZPOOL set ${arguments[$i]}bootfs bootfs > /dev/null"
120 i=$(( $i + 1))
121 done
122
123 log_pass "Malformed zpool set commands are rejected"