1#!/usr/local/bin/ksh93 -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# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)zfs_get_009_pos.ksh	1.1	09/06/22 SMI"
30#
31
32. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_common.kshlib
33. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_list_d.kshlib
34
35#################################################################################
36#
37# __stc_assertion_start
38#
39# ID: zfs_get_009_pos
40#
41# DESCRIPTION:
42#	'zfs get -d <n>' should get expected output.
43#
44# STRATEGY:
45#	1. Create a multiple depth filesystem.
46#	2. 'zfs get -d <n>' to get the output.
47#	3. 'zfs get -r|egrep' to get the expected output.
48#	4. Compare the two outputs, they shoud be same.
49#
50# TESTABILITY: explicit
51#
52# TEST_AUTOMATION_LEVEL: automated
53#
54# CODING_STATUS: COMPLETED (2009-05-20)
55#
56# __stc_assertion_end
57#
58################################################################################
59
60verify_runnable "both"
61
62if ! zfs_get_list_d_supported ; then
63	log_unsupported "'zfs get -d' is not supported."
64fi
65
66log_assert "'zfs get -d <n>' should get expected output."
67log_onexit depth_fs_cleanup
68
69set -A all_props type used available creation volsize referenced \
70	compressratio mounted origin recordsize quota reservation mountpoint \
71	sharenfs checksum compression atime devices exec readonly setuid \
72	snapdir aclmode aclinherit canmount primarycache secondarycache \
73	usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
74	userquota@root groupquota@root userused@root groupused@root
75
76$ZFS upgrade -v > /dev/null 2>&1
77if [[ $? -eq 0 ]]; then
78	set -A all_props ${all_props[*]} version
79fi
80
81depth_fs_setup
82
83mntpnt=$(get_prop mountpoint $DEPTH_FS)
84DEPTH_OUTPUT="$mntpnt/depth_output"
85EXPECT_OUTPUT="$mntpnt/expect_output"
86typeset -i prop_numb=16
87typeset -i old_val=0
88typeset -i j=0
89typeset eg_opt="$DEPTH_FS"$
90for dp in ${depth_array[@]}; do
91	(( j=old_val+1 ))
92	while (( j<=dp && j<=MAX_DEPTH )); do
93		eg_opt="$eg_opt""|d""$j"$
94		(( j+=1 ))
95	done
96	for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do
97		log_must eval "$ZFS get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT"
98		log_must eval "$ZFS get -rH -o name $prop $DEPTH_FS | $EGREP -e '$eg_opt' > $EXPECT_OUTPUT"
99		log_must $DIFF $DEPTH_OUTPUT $EXPECT_OUTPUT
100	done
101	(( old_val=dp ))
102done
103
104log_pass "'zfs get -d <n>' should get expected output."
105
106