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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
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
37 # Setting the valid option and properties, 'zfs get' should return the
38 # correct property value.
41 # 1. Create pool, filesystem, volume, snapshot, and bookmark.
42 # 2. Setting valid parameter, 'zfs get' should succeed.
43 # 3. Compare the output property name with the original input property.
46 verify_runnable "both"
48 typeset options=("" "-p" "-r" "-H")
50 typeset -i i=${#options[*]}
52 while ((j<${#depth_options[*]}));
54 options[$i]=-"${depth_options[$j]}"
59 typeset zfs_props=("type" used available creation volsize referenced \
60 compressratio mounted origin recordsize quota reservation mountpoint \
61 sharenfs checksum compression atime devices exec readonly setuid \
62 snapdir aclinherit canmount primarycache secondarycache version \
63 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots)
65 typeset zfs_props_os=(jailed aclmode)
67 typeset zfs_props_os=(zoned acltype)
69 typeset userquota_props=(userquota@root groupquota@root userused@root \
71 typeset all_props=("${zfs_props[@]}" \
72 "${zfs_props_os[@]}" \
73 "${userquota_props[@]}")
74 typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
75 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)
77 typeset bookmark_props=(creation)
78 typeset bookmark=($TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK)
81 # According to dataset and option, checking if 'zfs get' return correct
82 # property information.
85 # $2 properties which are expected to output into $TESTDIR/$TESTFILE0
88 function check_return_value
101 item=$(echo $line | awk '{print $2}' 2>&1)
103 if [[ $item == $p ]]; then
107 done < $TESTDIR/$TESTFILE0
109 if ((found == 0)); then
110 log_fail "'zfs get $opt $props $dst' return " \
111 "error message.'$p' haven't been found."
115 log_note "SUCCESS: 'zfs get $opt $prop $dst'."
118 log_assert "Setting the valid options and properties 'zfs get' should return " \
119 "the correct property value."
122 # Create filesystem and volume's snapshot
123 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
124 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
126 # Create filesystem and volume's bookmark
127 create_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK
128 create_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK
131 while ((i < ${#dataset[@]})); do
132 for opt in "${options[@]}"; do
133 for prop in ${all_props[@]}; do
134 eval "zfs get $opt $prop ${dataset[i]} > \
137 if [[ $ret != 0 ]]; then
138 log_fail "zfs get returned: $ret"
140 check_return_value ${dataset[i]} "$prop" "$opt"
147 while ((i < ${#bookmark[@]})); do
148 for opt in "${options[@]}"; do
149 for prop in ${bookmark_props[@]}; do
150 eval "zfs get $opt $prop ${bookmark[i]} > \
153 if [[ $ret != 0 ]]; then
154 log_fail "zfs get returned: $ret"
156 check_return_value ${bookmark[i]} "$prop" "$opt"
162 log_pass "Setting the valid options to dataset, it should succeed and return " \
163 "valid value. 'zfs get' pass."