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_007_pos.ksh 1.1 09/06/22 SMI" 30# 31 32. $STF_SUITE/tests/cli_root/zfs_get/zfs_get_list_d.kshlib 33. $STF_SUITE/tests/cli_user/cli_user.kshlib 34 35################################################################################# 36# 37# __stc_assertion_start 38# 39# ID: zfs_list_007_pos 40# 41# DESCRIPTION: 42# 'zfs list -d <n>' should get expected output. 43# 44# STRATEGY: 45# 1. 'zfs list -d <n>' to get the output. 46# 2. 'zfs list -r|egrep' to get the expected output. 47# 3. Compare the two outputs, they shoud be same. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2009-05-25) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "both" 60 61if ! zfs_get_list_d_supported ; then 62 log_unsupported "'zfs list -d' is not supported." 63fi 64 65set -A fs_type "all" "filesystem" "snapshot" 66if is_global_zone ; then 67 set -A fs_type ${fs_type[*]} "volume" 68fi 69 70function cleanup 71{ 72 log_must $RM -f $DEPTH_OUTPUT 73 log_must $RM -f $EXPECT_OUTPUT 74} 75 76log_onexit cleanup 77log_assert "'zfs list -d <n>' should get expected output." 78 79mntpnt=$TMPDIR 80DEPTH_OUTPUT="$mntpnt/depth_output" 81EXPECT_OUTPUT="$mntpnt/expect_output" 82typeset -i old_val=0 83typeset -i j=0 84typeset -i fs=0 85typeset eg_opt="$DEPTH_FS"$ 86for dp in ${depth_array[@]}; do 87 (( j=old_val+1 )) 88 while (( j<=dp && j<=MAX_DEPTH )); do 89 eg_opt="$eg_opt""|d""$j"$ 90 (( j+=1 )) 91 done 92 (( fs=0 )) 93 while (( fs<${#fs_type[*]} )); do 94 if [[ "$dp" == "0" ]] && \ 95 [[ "${fs_type[$fs]}" == "volume" || "${fs_type[$fs]}" == "snapshot" ]]; then 96 log_must eval "run_unprivileged $ZFS list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" 97 [[ -s "$DEPTH_OUTPUT" ]] && \ 98 log_fail "$DEPTH_OUTPUT should be null." 99 log_mustnot run_unprivileged $ZFS list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | $EGREP -e '$eg_opt' 100 else 101 log_must eval "run_unprivileged $ZFS list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" 102 log_must eval "run_unprivileged $ZFS list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | $EGREP -e '$eg_opt' > $EXPECT_OUTPUT" 103 log_must $DIFF $DEPTH_OUTPUT $EXPECT_OUTPUT 104 fi 105 (( fs+=1 )) 106 done 107 (( old_val=dp )) 108done 109 110log_pass "'zfs list -d <n>' should get expected output." 111 112