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_001_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/cli_root/zfs_get/zfs_get_list_d.kshlib 34. $STF_SUITE/tests/userquota/userquota_common.kshlib 35 36############################################################################### 37# 38# __stc_assertion_start 39# 40# ID: zfs_get_001_pos 41# 42# DESCRIPTION: 43# Setting the valid option and properties, 'zfs get' should return the 44# correct property value. 45# 46# STRATEGY: 47# 1. Create pool, filesystem, volume and snapshot. 48# 2. Setting valid parameter, 'zfs get' should succeed. 49# 3. Compare the output property name with the original input property. 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" 64if zfs_get_list_d_supported ; then 65 typeset -i i=${#options[*]} 66 typeset -i j=0 67 while (( j<${#depth_options[*]} )); 68 do 69 options[$i]=-"${depth_options[$j]}" 70 (( j+=1 )) 71 (( i+=1 )) 72 done 73fi 74 75set -A zfs_props type used available creation volsize referenced \ 76 compressratio mounted origin recordsize quota reservation mountpoint \ 77 sharenfs checksum compression atime devices exec readonly setuid \ 78 snapdir aclmode aclinherit canmount primarycache secondarycache \ 79 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots 80 81 82$ZFS upgrade -v > /dev/null 2>&1 83if [[ $? -eq 0 ]]; then 84 set -A zfs_props ${zfs_props[*]} version 85fi 86 87if is_userquota_supported; then 88 set -A userquota_props userquota@root groupquota@root \ 89 userused@root groupused@root 90fi 91 92set -A all_props -- "${zfs_props[@]}" "${userquota_props[@]}" 93 94set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ 95 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP 96 97# 98# According to dataset and option, checking if 'zfs get' return correct 99# property information. 100# 101# $1 dataset 102# $2 properties which are expected to output into $TESTDIR/$TESTFILE0 103# $3 option 104# 105function check_return_value 106{ 107 typeset dst=$1 108 typeset props=$2 109 typeset opt=$3 110 typeset -i found=0 111 typeset p 112 113 for p in $props; do 114 found=0 115 116 while read line; do 117 typeset item 118 item=$($ECHO $line | $AWK '{print $2}' 2>&1) 119 120 if [[ $item == $p ]]; then 121 (( found += 1 )) 122 break 123 fi 124 done < $TESTDIR/$TESTFILE0 125 126 if (( found == 0 )); then 127 log_fail "'zfs get $opt $props $dst' return " \ 128 "error message.'$p' haven't been found." 129 fi 130 done 131 132 log_note "SUCCESS: '$ZFS get $opt $prop $dst'." 133} 134 135log_assert "Setting the valid options and properties 'zfs get' should return " \ 136 "the correct property value." 137log_onexit cleanup 138 139# Create filesystem and volume's snapshot 140create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 141create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 142 143typeset -i i=0 144while (( i < ${#dataset[@]} )); do 145 for opt in "${options[@]}"; do 146 for prop in ${all_props[@]}; do 147 eval "$ZFS get $opt $prop ${dataset[i]} > \ 148 $TESTDIR/$TESTFILE0" 149 ret=$? 150 if [[ $ret != 0 ]]; then 151 log_fail "$ZFS get returned: $ret" 152 fi 153 check_return_value ${dataset[i]} "$prop" "$opt" 154 done 155 done 156 (( i += 1 )) 157done 158 159log_pass "Setting the valid options to dataset, it should succeed and return " \ 160 "valid value. 'zfs get' pass." 161