/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 112 lines · 54 code · 17 blank · 41 comment · 7 complexity · 06591199e525a99fd05e43aafe61557e MD5 · raw file

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