]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh
c77f769de118a5cecfd20316cbda436814e8b0cf
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_get / zfs_get_005_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/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib
29
30 #
31 # DESCRIPTION:
32 # Setting the invalid option and properties, 'zfs get' should failed.
33 #
34 # STRATEGY:
35 # 1. Create pool, filesystem, volume and snapshot.
36 # 2. Getting incorrect combination by invalid parameters
37 # 3. Using the combination as the parameters of 'zfs get' to check the
38 # command line return value.
39 #
40
41 verify_runnable "both"
42
43 typeset val_opts=(p r H)
44 typeset v_props=(type used available creation volsize referenced compressratio \
45 mounted origin recordsize quota reservation mountpoint sharenfs checksum \
46 compression atime devices exec readonly setuid zoned snapdir acltype \
47 aclinherit canmount primarycache secondarycache \
48 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version)
49
50 typeset userquota_props=(userquota@root groupquota@root userused@root \
51 groupused@root)
52 typeset val_pros=(-- "${v_props[@]}" "${userquota_props[@]}")
53 set -f # Force shell does not parse '?' and '*' as the wildcard
54 typeset inval_opts=(P R h ? *)
55 typeset inval_props=(Type 0 ? * -on --on readonl time USED RATIO MOUNTED)
56
57 typeset dataset=($TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL \
58 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)
59
60 typeset -i opt_numb=6
61 typeset -i prop_numb=12
62
63 val_opts_str=$(gen_option_str "${val_opts[*]}" "-" "" $opt_numb)
64 val_props_str=$(gen_option_str "${val_props[*]}" "" "," $prop_numb)
65 val_props_str="$val_props_str -a -d"
66
67 inval_opts_str=$(gen_option_str "${inval_opts[*]}" "-" "" $opt_numb)
68 inval_props_str=$(gen_option_str "${inval_props[*]}" "" "," $prop_numb)
69
70 #
71 # Test different options and properties combination.
72 #
73 # $1 options
74 # $2 properties
75 #
76 function test_options
77 {
78 typeset opts=$1
79 typeset props=$2
80
81 for dst in ${dataset[@]}; do
82 for opt in $opts; do
83 for prop in $props; do
84 $ZFS get $opt $prop $dst > /dev/null 2>&1
85 ret=$?
86 if [[ $ret == 0 ]]; then
87 log_fail "$ZFS get $opt $prop $dst " \
88 "unexpectedly succeeded."
89 fi
90 done
91 done
92 done
93 }
94
95 log_assert "Setting the invalid option and properties, 'zfs get' should be \
96 failed."
97 log_onexit cleanup
98
99 # Create filesystem and volume's snapshot
100 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
101 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
102
103 log_note "Valid options + invalid properties, 'zfs get' should fail."
104 test_options "$val_opts_str" "$inval_props_str"
105
106 log_note "Invalid options + valid properties, 'zfs get' should fail."
107 test_options "$inval_opts_str" "$val_props_str"
108
109 log_note "Invalid options + invalid properties, 'zfs get' should fail."
110 test_options "$inval_opts_str" "$inval_props_str"
111
112 log_pass "Setting the invalid options to dataset, 'zfs get' pass."