]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_get / zfs_get_008_pos.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) 2016 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib
34
35 #
36 # DESCRIPTION:
37 # Verify "-d <n>" can work with other options
38 #
39 # STRATEGY:
40 # 1. Create pool, filesystem, dataset, volume, snapshot, and bookmark.
41 # 2. Getting an -d option, other options and properties random combination.
42 # 3. Using the combination as the parameters of 'zfs get' to check the
43 # command line return value.
44 #
45
46 verify_runnable "both"
47
48 set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \
49         "-s local,default,temporary,inherited,none" \
50         "-o name -s local,default,temporary,inherited,none" \
51         "-rHp -o name -s local,default,temporary,inherited,none"
52
53 set -A props type used available creation volsize referenced compressratio \
54         mounted origin recordsize quota reservation mountpoint sharenfs \
55         checksum compression atime devices exec readonly setuid snapdir \
56         aclinherit canmount primarycache secondarycache \
57         usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
58         userquota@root groupquota@root userused@root groupused@root
59 if is_freebsd; then
60         set -A props ${props[*]} jailed aclmode
61 else
62         set -A props ${props[*]} zoned acltype
63 fi
64
65 zfs upgrade -v > /dev/null 2>&1
66 if [[ $? -eq 0 ]]; then
67         set -A props ${props[*]} version
68 fi
69
70 set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
71         $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP
72
73 set -A bookmark_props creation
74 set -A bookmark $TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK
75
76 log_assert "Verify '-d <n>' can work with other options"
77 log_onexit cleanup
78
79 # Create volume and filesystem's snapshot
80 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
81 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
82
83 # Create filesystem and volume's bookmark
84 create_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK
85 create_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK
86
87 typeset -i opt_numb=16
88 typeset -i prop_numb=16
89 typeset -i i=0
90 typeset -i item=0
91 typeset -i depth_item=0
92
93 for dst in ${dataset[@]}; do
94         (( i=0 ))
95         while (( i < opt_numb )); do
96                 (( item = $RANDOM % ${#options[@]} ))
97                 (( depth_item = $RANDOM % ${#depth_options[@]} ))
98                 for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
99                 do
100                         log_must eval "zfs get -${depth_options[depth_item]} ${options[item]} $prop $dst > /dev/null 2>&1"
101                 done
102                 (( i += 1 ))
103         done
104 done
105
106 for dst in ${bookmark[@]}; do
107         (( i=0 ))
108         while (( i < opt_numb )); do
109                 (( item = $RANDOM % ${#options[@]} ))
110                 (( depth_item = $RANDOM % ${#depth_options[@]} ))
111                 log_must eval "zfs get -${depth_options[depth_item]} ${options[item]} $bookmark_props $dst > /dev/null 2>&1"
112                 (( i += 1 ))
113         done
114 done
115
116 log_pass "Verify '-d <n>' can work with other options"
117