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) 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|grep' to get the expected output. 43# 4. Compare the two outputs, they should be same. 44# 45 46verify_runnable "both" 47 48if is_kmemleak; then 49 log_unsupported "Test case runs slowly when kmemleak is enabled" 50fi 51 52log_assert "'zfs get -d <n>' should get expected output." 53log_onexit depth_fs_cleanup 54 55set -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 version \ 59 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ 60 userquota@root groupquota@root userused@root groupused@root 61if is_freebsd; then 62 set -A all_props ${all_props[*]} jailed aclmode 63else 64 set -A all_props ${all_props[*]} zoned acltype 65fi 66 67depth_fs_setup 68 69mntpnt=$(get_prop mountpoint $DEPTH_FS) 70DEPTH_OUTPUT="$mntpnt/depth_output" 71EXPECT_OUTPUT="$mntpnt/expect_output" 72typeset -i prop_numb=16 73typeset -i old_val=0 74typeset -i j=0 75typeset eg_opt="$DEPTH_FS"$ 76for dp in ${depth_array[@]}; do 77 (( j=old_val+1 )) 78 while (( j<=dp && j<=MAX_DEPTH )); do 79 eg_opt="$eg_opt""|depth""$j"$ 80 (( j+=1 )) 81 done 82 for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do 83 log_must eval "zfs get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT" 84 log_must eval "zfs get -rH -o name $prop $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" 85 log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT 86 done 87 (( old_val=dp )) 88done 89 90# Ensure 'zfs get -t snapshot <dataset>' works as though -d 1 was specified 91log_must eval "zfs get -H -t snapshot -o name creation $DEPTH_FS > $DEPTH_OUTPUT" 92log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT" 93log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT 94 95# Ensure 'zfs get -t snap' works as a shorthand for 'zfs get -t snapshot' 96log_must eval "zfs get -H -t snap -d 1 -o name creation $DEPTH_FS > $DEPTH_OUTPUT" 97log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT" 98log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT 99 100# Ensure 'zfs get -t bookmark <dataset>' works as though -d 1 was specified 101log_must eval "zfs get -H -t bookmark -o name creation $DEPTH_FS > $DEPTH_OUTPUT" 102log_must eval "zfs get -H -t bookmark -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT" 103log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT 104 105 106log_pass "'zfs get -d <n>' should get expected output." 107 108