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 "@(#)property_alias_001_pos.ksh 1.4 09/01/13 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33. $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib 34 35############################################################################### 36# 37# __stc_assertion_start 38# 39# ID: property_alias_001_pos 40# 41# DESCRIPTION: 42# Verify the properties with aliases also work with those aliases 43# 44# STRATEGY: 45# 1. Create pool, then create filesystem & volume within it. 46# 2. Set or retrieve property via alias with datasets. 47# 3. Verify the result should be successful. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2006-08-16) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "both" 60 61function set_and_check #<dataset><set_prop_name><set_value><check_prop_name> 62{ 63 typeset ds=$1 64 typeset setprop=$2 65 typeset setval=$3 66 typeset chkprop=$4 67 typeset getval 68 69 log_must $ZFS set $setprop=$setval $ds 70 if [[ $setval == "gzip-6" ]]; then 71 setval="gzip" 72 fi 73 getval=$(get_prop $chkprop $ds) 74 75 case $setprop in 76 reservation|reserv ) 77 if [[ $setval == "none" ]]; then 78 [[ $getval != "0" ]] && \ 79 log_fail "Setting the property $setprop" \ 80 "with value $setval fails." 81 elif [[ $getval != $setval ]]; then 82 log_fail "Setting the property $setprop with" \ 83 "with $setval fails." 84 fi 85 ;; 86 * ) 87 [[ $getval != $setval ]] && \ 88 log_fail "Setting the property $setprop with value \ 89 $setval fails." 90 ;; 91 esac 92} 93 94log_assert "Properties with aliases also work with those aliases." 95 96set -A ro_prop "available" "avail" "referenced" "refer" 97set -A rw_prop "readonly" "rdonly" "compression" "compress" "reservation" "reserv" 98set -A chk_prop "rdonly" "readonly" "compress" "compression" "reserv" "reservation" 99set -A size "512" "1024" "2048" "4096" "8192" "16384" "32768" "65536" "131072" 100 101pool=$TESTPOOL 102fs=$TESTPOOL/$TESTFS 103vol=$TESTPOOL/$TESTVOL 104typeset -l avail_space=$(get_prop avail $pool) 105typeset -l reservsize 106typeset -i i=0 107 108for ds in $pool $fs $vol; do 109 for propname in ${ro_prop[*]}; do 110 $ZFS get -pH -o value $propname $ds >/dev/null 2>&1 111 (( $? != 0 )) && \ 112 log_fail "Get the property $proname of $ds failed." 113 done 114 i=0 115 while (( i < ${#rw_prop[*]} )); do 116 case ${rw_prop[i]} in 117 readonly|rdonly ) 118 for val in "on" "off"; do 119 set_and_check $ds ${rw_prop[i]} $val ${chk_prop[i]} 120 done 121 ;; 122 compression|compress ) 123 for val in $(get_compress_opts zfs_set); do 124 set_and_check $ds ${rw_prop[i]} $val ${chk_prop[i]} 125 done 126 ;; 127 reservation|reserv ) 128 (( reservsize = $avail_space % $RANDOM )) 129 for val in "0" "$reservsize" "none"; do 130 set_and_check $ds ${rw_prop[i]} $val ${chk_prop[i]} 131 done 132 ;; 133 esac 134 135 (( i = i + 1 )) 136 done 137 if [[ $ds == $vol ]]; then 138 for propname in "volblocksize" "volblock" ; do 139 $ZFS get -pH -o value $propname $ds >/dev/null 2>&1 140 (( $? != 0 )) && \ 141 log_fail "Get the property $propname of $ds failed." 142 done 143 fi 144done 145 146for ds in $pool $fs; do 147 for propname in "recordsize" "recsize"; do 148 for val in ${size[*]}; do 149 if [[ $propname == "recordsize" ]]; then 150 set_and_check $ds $propname $val "recsize" 151 else 152 set_and_check $ds $propname $val "recordsize" 153 fi 154 done 155 done 156done 157 158log_pass "The alias of a property works as expected." 159