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