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/tests/cli_user/zfs_list/zfs_list.kshlib 27. $STF_SUITE/tests/cli_user/cli_user.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_list_006_pos 34# 35# DESCRIPTION: 36# Verify 'zfs list' exclude list of snapshot. 37# 38# STRATEGY: 39# 1. Verify snapshot not shown in the list: 40# zfs list [-r] 41# 2. Verify snapshot will be shown by following case: 42# zfs list [-r] -t snapshot 43# zfs list [-r] -t all 44# zfs list <snapshot> 45# 46# TESTABILITY: explicit 47# 48# TEST_AUTOMATION_LEVEL: automated 49# 50# CODING_STATUS: COMPLETED (2009-04-24) 51# 52# __stc_assertion_end 53# 54################################################################################ 55 56verify_runnable "both" 57 58if ! pool_prop_exist "listsnapshots" ; then 59 log_unsupported "Pool property of 'listsnapshots' not supported." 60fi 61 62log_assert "Verify 'zfs list' exclude list of snapshot." 63 64set -A hide_options "--" "-t filesystem" "-t volume" 65set -A show_options "--" "-t snapshot" "-t all" 66 67typeset pool=${TESTPOOL%%/*} 68typeset dataset=${DATASETS%% *} 69typeset BASEFS=$TESTPOOL/$TESTFS 70 71for newvalue in "" "on" "off" ; do 72 73 if [[ -n $newvalue ]] && ! is_global_zone ; then 74 break 75 fi 76 77 if [[ -n $newvalue ]] ; then 78 log_must $ZPOOL set listsnapshots=$newvalue $pool 79 fi 80 81 if [ -z "$newvalue" -o "off" = "$newvalue" ] ; then 82 run_unprivileged $ZFS list -r -H -o name $pool | $GREP -q '@' && \ 83 log_fail "zfs list included snapshots but shouldn't have" 84 else 85 run_unprivileged $ZFS list -r -H -o name $pool | $GREP -q '@' || \ 86 log_fail "zfs list failed to include snapshots" 87 fi 88 89 90 typeset -i i=0 91 while (( i < ${#hide_options[*]} )) ; do 92 run_unprivileged $ZFS list -r -H -o name ${hide_options[i]} $pool | \ 93 $GREP -q '@' && \ 94 log_fail "zfs list included snapshots but shouldn't have" 95 96 (( i = i + 1 )) 97 done 98 99 (( i = 0 )) 100 101 while (( i < ${#show_options[*]} )) ; do 102 run_unprivileged $ZFS list -r -H -o name ${show_options[i]} $pool | \ 103 $GREP -q '@' || \ 104 log_fail "zfs list failed to include snapshots" 105 (( i = i + 1 )) 106 done 107 108 output=$(run_unprivileged $ZFS list -H -o name $BASEFS/${dataset}@snap) 109 if [[ $output != $BASEFS/${dataset}@snap ]] ; then 110 log_fail "zfs list not show $BASEFS/${dataset}@snap" 111 fi 112 113 if is_global_zone ; then 114 output=$(run_unprivileged $ZFS list -H -o name $BASEFS/${dataset}-vol@snap) 115 if [[ $output != $BASEFS/${dataset}-vol@snap ]] ; then 116 log_fail "zfs list not show $BASEFS/${dataset}-vol@snap" 117 fi 118 fi 119done 120 121log_pass "'zfs list' exclude list of snapshot." 122