]> git.proxmox.com Git - mirror_zfs-debian.git/blame - tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh
New upstream version 0.7.2
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_user / zfs_list / zfs_list_007_pos.ksh
CommitLineData
cae5b340
AX
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 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#
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|egrep' 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
54 log_must rm -f $EXPECT_OUTPUT
55}
56
57log_onexit cleanup
58log_assert "'zfs list -d <n>' should get expected output."
59
60mntpnt=/var/tmp
61DEPTH_OUTPUT="$mntpnt/depth_output"
62EXPECT_OUTPUT="$mntpnt/expect_output"
63typeset -i old_val=0
64typeset -i j=0
65typeset -i fs=0
66typeset eg_opt="$DEPTH_FS"$
67for dp in ${depth_array[@]}; do
68 (( j=old_val+1 ))
69 while (( j<=dp && j<=MAX_DEPTH )); do
70 eg_opt="$eg_opt""|depth""$j"$
71 (( j+=1 ))
72 done
73 (( fs=0 ))
74 while (( fs<${#fs_type[*]} )); do
75 if [[ "$dp" == "0" ]] && \
76 [[ "${fs_type[$fs]}" == "volume" || "${fs_type[$fs]}" == "snapshot" ]]; then
77 log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT"
78 [[ -s "$DEPTH_OUTPUT" ]] && \
79 log_fail "$DEPTH_OUTPUT should be null."
80 log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt'
81 else
82 log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT"
83 log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT"
84 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
85 fi
86 (( fs+=1 ))
87 done
88 (( old_val=dp ))
89done
90
91log_pass "'zfs list -d <n>' should get expected output."