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# Verify "-d <n>" can work with other options
34#
35# STRATEGY:
36# 1. Create pool, filesystem, dataset, volume and snapshot.
37# 2. Getting an -d option, other options and properties random combination.
38# 3. Using the combination as the parameters of 'zfs get' to check the
39# command line return value.
40#
41
42verify_runnable "both"
43
44set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \
45	"-s local,default,temporary,inherited,none" \
46	"-o name -s local,default,temporary,inherited,none" \
47	"-rHp -o name -s local,default,temporary,inherited,none"
48
49set -A props type used available creation volsize referenced compressratio \
50	mounted origin recordsize quota reservation mountpoint sharenfs \
51	checksum compression atime devices exec readonly setuid zoned snapdir \
52	aclmode aclinherit canmount primarycache secondarycache \
53	usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
54	userquota@root groupquota@root userused@root groupused@root
55
56$ZFS upgrade -v > /dev/null 2>&1
57if [[ $? -eq 0 ]]; then
58	set -A all_props ${all_props[*]} version
59fi
60
61set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
62	$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP
63
64log_assert "Verify '-d <n>' can work with other options"
65log_onexit cleanup
66
67# Create volume and filesystem's snapshot
68create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
69create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
70
71typeset -i opt_numb=16
72typeset -i prop_numb=16
73typeset -i i=0
74typeset -i item=0
75typeset -i depth_item=0
76
77for dst in ${dataset[@]}; do
78	(( i=0 ))
79	while (( i < opt_numb )); do
80		(( item = $RANDOM % ${#options[@]} ))
81		(( depth_item = $RANDOM % ${#depth_options[@]} ))
82		for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
83		do
84			log_must eval "$ZFS get -${depth_options[depth_item]} ${options[item]} $prop $dst > /dev/null 2>&1"
85		done
86		(( i += 1 ))
87	done
88done
89
90log_pass "Verify '-d <n>' can work with other options"
91
92