xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
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#	'zfs get -d <n>' should get expected output.
34#
35# STRATEGY:
36#	1. Create a multiple depth filesystem.
37#	2. 'zfs get -d <n>' to get the output.
38#	3. 'zfs get -r|egrep' to get the expected output.
39#	4. Compare the two outputs, they shoud be same.
40#
41
42verify_runnable "both"
43
44log_assert "'zfs get -d <n>' should get expected output."
45log_onexit depth_fs_cleanup
46
47set -A all_props type used available creation volsize referenced \
48	compressratio mounted origin recordsize quota reservation mountpoint \
49	sharenfs checksum compression atime devices exec readonly setuid \
50	zoned snapdir aclmode aclinherit canmount primarycache secondarycache \
51	usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
52	userquota@root groupquota@root userused@root groupused@root
53
54$ZFS upgrade -v > /dev/null 2>&1
55if [[ $? -eq 0 ]]; then
56	set -A all_props ${all_props[*]} version
57fi
58
59depth_fs_setup
60
61mntpnt=$(get_prop mountpoint $DEPTH_FS)
62DEPTH_OUTPUT="$mntpnt/depth_output"
63EXPECT_OUTPUT="$mntpnt/expect_output"
64typeset -i prop_numb=16
65typeset -i old_val=0
66typeset -i j=0
67typeset eg_opt="$DEPTH_FS"$
68for dp in ${depth_array[@]}; do
69	(( j=old_val+1 ))
70	while (( j<=dp && j<=MAX_DEPTH )); do
71		eg_opt="$eg_opt""|depth""$j"$
72		(( j+=1 ))
73	done
74	for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do
75		log_must eval "$ZFS get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT"
76		log_must eval "$ZFS get -rH -o name $prop $DEPTH_FS | $EGREP -e '$eg_opt' > $EXPECT_OUTPUT"
77		log_must $DIFF $DEPTH_OUTPUT $EXPECT_OUTPUT
78	done
79	(( old_val=dp ))
80done
81
82log_pass "'zfs get -d <n>' should get expected output."
83
84