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_002_pos.ksh	1.6	09/06/22 SMI"
30#
31
32. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_common.kshlib
33. $STF_SUITE/tests/userquota/userquota_common.kshlib
34
35###############################################################################
36#
37# __stc_assertion_start
38#
39# ID: zfs_get_002_pos
40#
41# DESCRIPTION:
42# Setting the valid option and properties 'zfs get' return correct value.
43# It should be successful.
44#
45# STRATEGY:
46# 1. Create pool, filesystem, dataset, volume and snapshot.
47# 2. Getting the options and properties random combination.
48# 3. Using the combination as the parameters of 'zfs get' to check the
49# command line return value.
50#
51# TESTABILITY: explicit
52#
53# TEST_AUTOMATION_LEVEL: automated
54#
55# CODING_STATUS: COMPLETED (2005-07-04)
56#
57# __stc_assertion_end
58#
59################################################################################
60
61verify_runnable "both"
62
63set -A options " " p r H
64
65set -A zfs_props type used available creation volsize referenced compressratio \
66	mounted origin recordsize quota reservation mountpoint sharenfs \
67	checksum compression atime devices exec readonly setuid snapdir \
68	aclmode aclinherit canmount primarycache secondarycache \
69	usedbychildren usedbydataset usedbyrefreservation usedbysnapshots
70
71
72$ZFS upgrade -v > /dev/null 2>&1
73if [[ $? -eq 0 ]]; then
74	set -A zfs_props ${zfs_props[*]} version
75fi
76
77if is_userquota_supported; then
78	set -A  userquota_props userquota@root groupquota@root \
79		userused@root groupused@root
80fi
81
82set -A props -- "${zfs_props[@]}" "${userquota_props[@]}"
83
84set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
85	$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP
86
87log_assert "Setting the valid options and properties 'zfs get' return correct "\
88	"value. It should be successful."
89log_onexit cleanup
90
91# Create volume and filesystem's snapshot
92create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
93create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
94
95#
96# Begin to test 'get [-prH] <property[,property]...>
97# 			<filesystem|dataset|volume|snapshot>'
98# 		'get [-prH] <-a|-d> <filesystem|dataset|volume|snapshot>"
99#
100typeset -i opt_numb=8
101typeset -i prop_numb=20
102for dst in ${dataset[@]}; do
103	# option can be empty, so "" is necessary.
104	for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
105		for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
106		do
107			$ZFS get $opt $prop $dst > /dev/null 2>&1
108			ret=$?
109			if [[ $ret != 0 ]]; then
110				log_fail "$ZFS get $opt $prop $dst (Code: $ret)"
111			fi
112		done
113	done
114done
115
116log_pass "Setting the valid options to dataset, 'zfs get' pass."
117