]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh
OpenZFS 7386 - zfs get does not work properly with bookmarks
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_get / zfs_get_001_pos.ksh
CommitLineData
6bb24f4d
BB
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. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib
30
31#
32# DESCRIPTION:
33# Setting the valid option and properties, 'zfs get' should return the
34# correct property value.
35#
36# STRATEGY:
aeacdefe 37# 1. Create pool, filesystem, volume, snapshot, and bookmark.
6bb24f4d
BB
38# 2. Setting valid parameter, 'zfs get' should succeed.
39# 3. Compare the output property name with the original input property.
40#
41
42verify_runnable "both"
43
44typeset options=("" "-p" "-r" "-H")
45
46typeset -i i=${#options[*]}
47typeset -i j=0
48while ((j<${#depth_options[*]}));
49do
50 options[$i]=-"${depth_options[$j]}"
51 ((j+=1))
52 ((i+=1))
53done
54
55typeset zfs_props=("type" used available creation volsize referenced \
56 compressratio mounted origin recordsize quota reservation mountpoint \
57 sharenfs checksum compression atime devices exec readonly setuid zoned \
58 snapdir acltype aclinherit canmount primarycache secondarycache \
59 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
60 version)
61
62typeset userquota_props=(userquota@root groupquota@root userused@root \
63 groupused@root)
64typeset all_props=("${zfs_props[@]}" "${userquota_props[@]}")
65typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
66 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)
67
aeacdefe
GM
68typeset bookmark_props=(creation)
69typeset bookmark=($TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK)
70
6bb24f4d
BB
71#
72# According to dataset and option, checking if 'zfs get' return correct
73# property information.
74#
75# $1 dataset
76# $2 properties which are expected to output into $TESTDIR/$TESTFILE0
77# $3 option
78#
79function check_return_value
80{
81 typeset dst=$1
82 typeset props=$2
83 typeset opt=$3
84 typeset -i found=0
85 typeset p
86
87 for p in $props; do
88 found=0
89
90 while read line; do
91 typeset item
92 item=$($ECHO $line | $AWK '{print $2}' 2>&1)
93
94 if [[ $item == $p ]]; then
95 ((found += 1))
96 break
97 fi
98 done < $TESTDIR/$TESTFILE0
99
100 if ((found == 0)); then
101 log_fail "'zfs get $opt $props $dst' return " \
102 "error message.'$p' haven't been found."
103 fi
104 done
105
106 log_note "SUCCESS: '$ZFS get $opt $prop $dst'."
107}
108
109log_assert "Setting the valid options and properties 'zfs get' should return " \
110 "the correct property value."
111log_onexit cleanup
112
113# Create filesystem and volume's snapshot
114create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
115create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
116
aeacdefe
GM
117# Create filesystem and volume's bookmark
118create_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK
119create_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK
120
6bb24f4d
BB
121typeset -i i=0
122while ((i < ${#dataset[@]})); do
123 for opt in "${options[@]}"; do
124 for prop in ${all_props[@]}; do
125 eval "$ZFS get $opt $prop ${dataset[i]} > \
126 $TESTDIR/$TESTFILE0"
127 ret=$?
128 if [[ $ret != 0 ]]; then
129 log_fail "$ZFS get returned: $ret"
130 fi
131 check_return_value ${dataset[i]} "$prop" "$opt"
132 done
133 done
134 ((i += 1))
135done
136
aeacdefe
GM
137i=0
138while ((i < ${#bookmark[@]})); do
139 for opt in "${options[@]}"; do
140 for prop in ${bookmark_props[@]}; do
141 eval "$ZFS get $opt $prop ${bookmark[i]} > \
142 $TESTDIR/$TESTFILE0"
143 ret=$?
144 if [[ $ret != 0 ]]; then
145 log_fail "$ZFS get returned: $ret"
146 fi
147 check_return_value ${bookmark[i]} "$prop" "$opt"
148 done
149 done
150 ((i += 1))
151done
152
6bb24f4d
BB
153log_pass "Setting the valid options to dataset, it should succeed and return " \
154 "valid value. 'zfs get' pass."