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