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_005_neg 35# 36# DESCRIPTION: 37# Setting the invalid option and properties, 'zfs get' should failed. 38# 39# STRATEGY: 40# 1. Create pool, filesystem, volume and snapshot. 41# 2. Getting incorrect combination by invalid parameters 42# 3. Using the combination as the parameters of 'zfs get' to check the 43# command line return value. 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2005-07-04) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55verify_runnable "both" 56 57set -A val_opts p r H 58set -A v_props type used available creation volsize referenced compressratio mounted \ 59 origin recordsize quota reservation mountpoint sharenfs checksum \ 60 compression atime devices exec readonly setuid zoned snapdir aclmode \ 61 aclinherit canmount primarycache secondarycache \ 62 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots 63 64$ZFS upgrade -v > /dev/null 2>&1 65if [[ $? -eq 0 ]]; then 66 set -A v_props ${v_props[*]} version 67fi 68 69if is_userquota_supported; then 70 set -A userquota_props userquota@root groupquota@root \ 71 userused@root groupused@root 72fi 73 74set -A val_pros -- "${v_props[@]}" "${userquota_props[@]}" 75 76set -f # Force shell does not parse '?' and '*' as the wildcard 77set -A inval_opts P R h ? * 78set -A inval_props Type 0 ? * -on --on readonl time USED RATIO MOUNTED 79 80set -A dataset $TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL \ 81 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP 82 83typeset -i opt_numb=6 84typeset -i prop_numb=12 85 86val_opts_str=$(gen_option_str "${val_opts[*]}" "-" "" $opt_numb) 87val_props_str=$(gen_option_str "${val_props[*]}" "" "," $prop_numb) 88val_props_str="$val_props_str -a -d" 89 90inval_opts_str=$(gen_option_str "${inval_opts[*]}" "-" "" $opt_numb) 91inval_props_str=$(gen_option_str "${inval_props[*]}" "" "," $prop_numb) 92 93# 94# Test different options and properties combination. 95# 96# $1 options 97# $2 properties 98# 99function test_options 100{ 101 typeset opts=$1 102 typeset props=$2 103 104 for dst in ${dataset[@]}; do 105 for opt in $opts; do 106 for prop in $props; do 107 $ZFS get $opt $prop $dst > /dev/null 2>&1 108 ret=$? 109 if [[ $ret == 0 ]]; then 110 log_fail "$ZFS get \ 111 $opt $prop $dst unexpectedly succeeded." 112 fi 113 done 114 done 115 done 116} 117 118log_assert "Setting the invalid option and properties, 'zfs get' should be \ 119 failed." 120log_onexit cleanup 121 122# Create filesystem and volume's snapshot 123create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 124create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 125 126log_note "Valid options + invalid properties, 'zfs get' should fail." 127test_options "$val_opts_str" "$inval_props_str" 128 129log_note "Invalid options + valid properties, 'zfs get' should fail." 130test_options "$inval_opts_str" "$val_props_str" 131 132log_note "Invalid options + invalid properties, 'zfs get' should fail." 133test_options "$inval_opts_str" "$inval_props_str" 134 135log_pass "Setting the invalid options to dataset, 'zfs get' pass." 136