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# Setting the valid option and properties, 'zfs get' should return the 34# correct property value. 35# 36# STRATEGY: 37# 1. Create pool, filesystem, volume and snapshot. 38# 2. Setting valid parameter, 'zfs get' should succeed. 39# 3. Compare the output property name with the original input property. 40# 41 42verify_runnable "both" 43 44typeset options=("" "-p" "-r" "-H") 45 46typeset -i i=${#options[*]} 47typeset -i j=0 48while ((j<${#depth_options[*]})); 49do 50 options[$i]=-"${depth_options[$j]}" 51 ((j+=1)) 52 ((i+=1)) 53done 54 55typeset zfs_props=("type" used available creation volsize referenced \ 56 compressratio mounted origin recordsize quota reservation mountpoint \ 57 sharenfs checksum compression atime devices exec readonly setuid zoned \ 58 snapdir aclmode aclinherit canmount primarycache secondarycache \ 59 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ 60 version) 61 62typeset userquota_props=(userquota@root groupquota@root userused@root \ 63 groupused@root) 64typeset all_props=("${zfs_props[@]}" "${userquota_props[@]}") 65typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ 66 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) 67 68# 69# According to dataset and option, checking if 'zfs get' return correct 70# property information. 71# 72# $1 dataset 73# $2 properties which are expected to output into $TESTDIR/$TESTFILE0 74# $3 option 75# 76function check_return_value 77{ 78 typeset dst=$1 79 typeset props=$2 80 typeset opt=$3 81 typeset -i found=0 82 typeset p 83 84 for p in $props; do 85 found=0 86 87 while read line; do 88 typeset item 89 item=$($ECHO $line | $AWK '{print $2}' 2>&1) 90 91 if [[ $item == $p ]]; then 92 ((found += 1)) 93 break 94 fi 95 done < $TESTDIR/$TESTFILE0 96 97 if ((found == 0)); then 98 log_fail "'zfs get $opt $props $dst' return " \ 99 "error message.'$p' haven't been found." 100 fi 101 done 102 103 log_note "SUCCESS: '$ZFS get $opt $prop $dst'." 104} 105 106log_assert "Setting the valid options and properties 'zfs get' should return " \ 107 "the correct property value." 108log_onexit cleanup 109 110# Create filesystem and volume's snapshot 111create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 112create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 113 114typeset -i i=0 115while ((i < ${#dataset[@]})); do 116 for opt in "${options[@]}"; do 117 for prop in ${all_props[@]}; do 118 eval "$ZFS get $opt $prop ${dataset[i]} > \ 119 $TESTDIR/$TESTFILE0" 120 ret=$? 121 if [[ $ret != 0 ]]; then 122 log_fail "$ZFS get returned: $ret" 123 fi 124 check_return_value ${dataset[i]} "$prop" "$opt" 125 done 126 done 127 ((i += 1)) 128done 129 130log_pass "Setting the valid options to dataset, it should succeed and return " \ 131 "valid value. 'zfs get' pass." 132