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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib
37 # Executing well-formed 'zfs list' commands should return success.
40 # 1. Create an array of valid options.
41 # 2. Execute each element in the array.
42 # 3. Verify success is returned.
45 verify_runnable "both"
47 set -A args "list" "list -r" "list -H" \
48 "list $TESTPOOL/$TESTFS" \
49 "list -r $TESTPOOL/$TESTFS" "list -H $TESTPOOL/$TESTFS" \
50 "list -rH $TESTPOOL/$TESTFS" "list -Hr $TESTPOOL/$TESTFS" \
51 "list -o name $TESTPOOL/$TESTFS" "list -r -o name $TESTPOOL/$TESTFS" \
52 "list -H -o name $TESTPOOL/$TESTFS" "list -rH -o name $TESTPOOL/$TESTFS" \
53 "list -Hr -o name $TESTPOOL/$TESTFS"
55 set -A d_args " " "-r" "-H" \
57 "-r $TESTPOOL/$TESTFS" "-H $TESTPOOL/$TESTFS" \
58 "-rH $TESTPOOL/$TESTFS" "-Hr $TESTPOOL/$TESTFS" \
59 "-o name $TESTPOOL/$TESTFS" "-r -o name $TESTPOOL/$TESTFS" \
60 "-H -o name $TESTPOOL/$TESTFS" "-rH -o name $TESTPOOL/$TESTFS" \
61 "-Hr -o name $TESTPOOL/$TESTFS"
63 typeset -i m=${#args[*]}
66 while (( n<${#depth_options[*]} ));
69 while (( k<${#d_args[*]} ));
71 args[$m]="list"" -${depth_options[$n]}"" ${d_args[$k]}"
78 set -A pathargs "list -r $TESTDIR" "list -H $TESTDIR" \
79 "list -r ./../$TESTDIR" "list -H ./../$TESTDIR"
81 set -A d_pathargs " $TESTDIR" "-r $TESTDIR" "-H $TESTDIR" \
82 "-r ./../$TESTDIR" "-H ./../$TESTDIR"
84 (( m=${#pathargs[*]} ))
87 while (( n<${#depth_options[*]} ));
90 while (( k<${#d_pathargs[*]} ));
92 pathargs[$m]="list"" -${depth_options[$n]}"" ${d_pathargs[$k]}"
99 log_assert "Verify 'zfs list [-rH] [-o property[,prop]*] [fs|clct|vol]'."
102 while [[ $i -lt ${#args[*]} ]]; do
103 log_must eval "zfs ${args[i]} > /dev/null"
107 # Verify 'zfs list <path>' will succeed on absolute or relative path.
111 while [[ $i -lt ${#pathargs[*]} ]]; do
112 log_must eval "zfs ${pathargs[i]} > /dev/null"
116 log_pass "The sub-command 'list' succeeds as non-root."