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