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