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#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"@(#)zfs_get_008_pos.ksh	1.1	09/06/22 SMI"
28#
29
30. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_common.kshlib
31. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_list_d.kshlib
32
33###############################################################################
34#
35# __stc_assertion_start
36#
37# ID: zfs_get_008_pos
38#
39# DESCRIPTION:
40# Verify "-d <n>" can work with other options
41#
42# STRATEGY:
43# 1. Create pool, filesystem, dataset, volume and snapshot.
44# 2. Getting an -d option, other options and properties random combination.
45# 3. Using the combination as the parameters of 'zfs get' to check the
46# command line return value.
47#
48# TESTABILITY: explicit
49#
50# TEST_AUTOMATION_LEVEL: automated
51#
52# CODING_STATUS: COMPLETED (2009-05-22)
53#
54# __stc_assertion_end
55#
56################################################################################
57
58verify_runnable "both"
59
60if ! zfs_get_list_d_supported ; then
61	log_unsupported "'zfs get -d' is not supported."
62fi
63
64set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \
65	"-s local,default,temporary,inherited,none" \
66	"-o name -s local,default,temporary,inherited,none" \
67	"-rHp -o name -s local,default,temporary,inherited,none"
68
69set -A props type used available creation volsize referenced compressratio \
70	mounted origin recordsize quota reservation mountpoint sharenfs \
71	checksum compression atime devices exec readonly setuid snapdir \
72	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
81set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
82	$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP
83
84log_assert "Verify '-d <n>' can work with other options"
85log_onexit cleanup
86
87# Create volume and filesystem's snapshot
88create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
89create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
90
91typeset -i opt_numb=16
92typeset -i prop_numb=16
93typeset -i i=0
94typeset -i item=0
95typeset -i depth_item=0
96
97for dst in ${dataset[@]}; do
98	(( i=0 ))
99	while (( i < opt_numb )); do
100		(( item = $RANDOM % ${#options[@]} ))
101		(( depth_item = $RANDOM % ${#depth_options[@]} ))
102		for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
103		do
104			log_must eval "$ZFS get -${depth_options[depth_item]} ${options[item]} $prop $dst > /dev/null 2>&1"
105		done
106		(( i += 1 ))
107	done
108done
109
110log_pass "Verify '-d <n>' can work with other options"
111
112