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. $STF_SUITE/include/libtest.kshlib 27. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_list_d.kshlib 28. $STF_SUITE/tests/cli_user/cli_user.kshlib 29 30################################################################################ 31# 32# __stc_assertion_start 33# 34# ID: zfs_list_001_pos 35# 36# DESCRIPTION: 37# Executing well-formed 'zfs list' commands should return success. 38# 39# STRATEGY: 40# 1. Create an array of valid options. 41# 2. Execute each element in the array. 42# 3. Verify success is returned. 43# 44# TESTABILITY: explicit 45# 46# TEST_AUTOMATION_LEVEL: automated 47# 48# CODING_STATUS: COMPLETED (2005-07-04) 49# 50# __stc_assertion_end 51# 52################################################################################ 53 54verify_runnable "both" 55 56set -A args "list" "list -r" "list -H" \ 57 "list $TESTPOOL/$TESTFS" \ 58 "list -r $TESTPOOL/$TESTFS" "list -H $TESTPOOL/$TESTFS" \ 59 "list -rH $TESTPOOL/$TESTFS" "list -Hr $TESTPOOL/$TESTFS" \ 60 "list -o name $TESTPOOL/$TESTFS" "list -r -o name $TESTPOOL/$TESTFS" \ 61 "list -H -o name $TESTPOOL/$TESTFS" "list -rH -o name $TESTPOOL/$TESTFS" \ 62 "list -Hr -o name $TESTPOOL/$TESTFS" 63 64if zfs_get_list_d_supported ; then 65 set -A d_args " " "-r" "-H" \ 66 "$TESTPOOL/$TESTFS" \ 67 "-r $TESTPOOL/$TESTFS" "-H $TESTPOOL/$TESTFS" \ 68 "-rH $TESTPOOL/$TESTFS" "-Hr $TESTPOOL/$TESTFS" \ 69 "-o name $TESTPOOL/$TESTFS" "-r -o name $TESTPOOL/$TESTFS" \ 70 "-H -o name $TESTPOOL/$TESTFS" "-rH -o name $TESTPOOL/$TESTFS" \ 71 "-Hr -o name $TESTPOOL/$TESTFS" 72 73 typeset -i m=${#args[*]} 74 typeset -i n=0 75 typeset -i k=0 76 while (( n<${#depth_options[*]} )); 77 do 78 (( k=0 )) 79 while (( k<${#d_args[*]} )); 80 do 81 args[$m]="list"" -${depth_options[$n]}"" ${d_args[$k]}" 82 (( k+=1 )) 83 (( m+=1 )) 84 done 85 (( n+=1 )) 86 done 87fi 88 89set -A pathargs "list -r $TESTDIR" "list -H $TESTDIR" \ 90 "list -r ./../$TESTDIR" "list -H ./../$TESTDIR" 91 92if zfs_get_list_d_supported ; then 93set -A d_pathargs " $TESTDIR" "-r $TESTDIR" "-H $TESTDIR" \ 94 "-r ./../$TESTDIR" "-H ./../$TESTDIR" 95 96 (( m=${#pathargs[*]} )) 97 (( n=0 )) 98 (( k=0 )) 99 while (( n<${#depth_options[*]} )); 100 do 101 (( k=0 )) 102 while (( k<${#d_pathargs[*]} )); 103 do 104 pathargs[$m]="list"" -${depth_options[$n]}"" ${d_pathargs[$k]}" 105 (( k+=1 )) 106 (( m+=1 )) 107 done 108 (( n+=1 )) 109 done 110fi 111 112log_assert "Verify 'zfs list [-rH] [-o property[,prop]*] [fs|clct|vol]'." 113 114typeset -i i=0 115while [[ $i -lt ${#args[*]} ]]; do 116 log_must run_unprivileged "eval $ZFS ${args[i]} > /dev/null" 117 ((i = i + 1)) 118done 119 120# Verify 'zfs list <path>' will succeed on absolute or relative path. 121 122cd /tmp 123typeset -i i=0 124while [[ $i -lt ${#pathargs[*]} ]]; do 125 log_must run_unprivileged "eval $ZFS ${pathargs[i]} > /dev/null" 126 ((i = i + 1)) 127done 128 129log_pass "The sub-command 'list' succeeds as non-root." 130