1#!/bin/ksh -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 https://opensource.org/licenses/CDDL-1.0. 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 28# 29# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib 33 34# 35# DESCRIPTION: 36# 'zfs list -d <n>' should get expected output. 37# 38# STRATEGY: 39# 1. 'zfs list -d <n>' to get the output. 40# 2. 'zfs list -r|grep' to get the expected output. 41# 3. Compare the two outputs, they should be same. 42# 43 44verify_runnable "both" 45 46set -A fs_type "all" "filesystem" "snapshot" 47if is_global_zone ; then 48 set -A fs_type ${fs_type[*]} "volume" 49fi 50 51function cleanup 52{ 53 log_must rm -f $DEPTH_OUTPUT $EXPECT_OUTPUT 54} 55 56log_onexit cleanup 57log_assert "'zfs list -d <n>' should get expected output." 58 59DEPTH_OUTPUT="$TEST_BASE_DIR/depth_output" 60EXPECT_OUTPUT="$TEST_BASE_DIR/expect_output" 61typeset -i old_val=0 62typeset -i j=0 63typeset -i fs=0 64typeset eg_opt="$DEPTH_FS"$ 65for dp in ${depth_array[@]}; do 66 (( j=old_val+1 )) 67 while (( j<=dp && j<=MAX_DEPTH )); do 68 eg_opt="$eg_opt""|depth""$j"$ 69 (( j+=1 )) 70 done 71 (( fs=0 )) 72 while (( fs<${#fs_type[*]} )); do 73 if [[ "$dp" == "0" ]] && \ 74 [[ "${fs_type[$fs]}" == "volume" || "${fs_type[$fs]}" == "snapshot" ]]; then 75 log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" 76 [[ -s "$DEPTH_OUTPUT" ]] && \ 77 log_fail "$DEPTH_OUTPUT should be null." 78 log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E "$eg_opt" 79 else 80 log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" 81 log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" 82 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT 83 fi 84 (( fs+=1 )) 85 done 86 (( old_val=dp )) 87done 88 89log_pass "'zfs list -d <n>' should get expected output." 90