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