]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_get / zfs_get_009_pos.ksh
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) 2016 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib
34
35 #
36 # DESCRIPTION:
37 #       'zfs get -d <n>' should get expected output.
38 #
39 # STRATEGY:
40 #       1. Create a multiple depth filesystem.
41 #       2. 'zfs get -d <n>' to get the output.
42 #       3. 'zfs get -r|egrep' to get the expected output.
43 #       4. Compare the two outputs, they should be same.
44 #
45
46 verify_runnable "both"
47
48 if is_kmemleak; then
49         log_unsupported "Test case runs slowly when kmemleak is enabled"
50 fi
51
52 log_assert "'zfs get -d <n>' should get expected output."
53 log_onexit depth_fs_cleanup
54
55 set -A all_props type used available creation volsize referenced \
56         compressratio mounted origin recordsize quota reservation mountpoint \
57         sharenfs checksum compression atime devices exec readonly setuid \
58         snapdir aclinherit canmount primarycache secondarycache \
59         usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
60         userquota@root groupquota@root userused@root groupused@root
61 if is_freebsd; then
62         set -A all_props ${all_props[*]} jailed aclmode
63 else
64         set -A all_props ${all_props[*]} zoned acltype
65 fi
66
67 zfs upgrade -v > /dev/null 2>&1
68 if [[ $? -eq 0 ]]; then
69         set -A all_props ${all_props[*]} version
70 fi
71
72 depth_fs_setup
73
74 mntpnt=$(get_prop mountpoint $DEPTH_FS)
75 DEPTH_OUTPUT="$mntpnt/depth_output"
76 EXPECT_OUTPUT="$mntpnt/expect_output"
77 typeset -i prop_numb=16
78 typeset -i old_val=0
79 typeset -i j=0
80 typeset eg_opt="$DEPTH_FS"$
81 for dp in ${depth_array[@]}; do
82         (( j=old_val+1 ))
83         while (( j<=dp && j<=MAX_DEPTH )); do
84                 eg_opt="$eg_opt""|depth""$j"$
85                 (( j+=1 ))
86         done
87         for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do
88                 log_must eval "zfs get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT"
89                 log_must eval "zfs get -rH -o name $prop $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT"
90                 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
91         done
92         (( old_val=dp ))
93 done
94
95 # Ensure 'zfs get -t snapshot <dataset>' works as though -d 1 was specified
96 log_must eval "zfs get -H -t snapshot -o name creation $DEPTH_FS > $DEPTH_OUTPUT"
97 log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
98 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
99
100 # Ensure 'zfs get -t snap' works as a shorthand for 'zfs get -t snapshot'
101 log_must eval "zfs get -H -t snap -d 1 -o name creation $DEPTH_FS > $DEPTH_OUTPUT"
102 log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
103 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
104
105 # Ensure 'zfs get -t bookmark <dataset>' works as though -d 1 was specified
106 log_must eval "zfs get -H -t bookmark -o name creation $DEPTH_FS > $DEPTH_OUTPUT"
107 log_must eval "zfs get -H -t bookmark -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
108 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
109
110
111 log_pass "'zfs get -d <n>' should get expected output."
112