PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs_get/zfs_get_009_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 105 lines | 40 code | 13 blank | 52 comment | 6 complexity | 05e94077440dc1e3ca4132182bbf7fa9 MD5 | raw file
  1. #!/usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_get_009_pos.ksh 1.1 09/06/22 SMI"
  28. #
  29. . $STF_SUITE/tests/cli_root/zfs_get/zfs_get_common.kshlib
  30. . $STF_SUITE/tests/cli_root/zfs_get/zfs_get_list_d.kshlib
  31. #################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zfs_get_009_pos
  36. #
  37. # DESCRIPTION:
  38. # 'zfs get -d <n>' should get expected output.
  39. #
  40. # STRATEGY:
  41. # 1. Create a multiple depth filesystem.
  42. # 2. 'zfs get -d <n>' to get the output.
  43. # 3. 'zfs get -r|egrep' to get the expected output.
  44. # 4. Compare the two outputs, they shoud be same.
  45. #
  46. # TESTABILITY: explicit
  47. #
  48. # TEST_AUTOMATION_LEVEL: automated
  49. #
  50. # CODING_STATUS: COMPLETED (2009-05-20)
  51. #
  52. # __stc_assertion_end
  53. #
  54. ################################################################################
  55. verify_runnable "both"
  56. if ! zfs_get_list_d_supported ; then
  57. log_unsupported "'zfs get -d' is not supported."
  58. fi
  59. log_assert "'zfs get -d <n>' should get expected output."
  60. log_onexit depth_fs_cleanup
  61. set -A all_props type used available creation volsize referenced \
  62. compressratio mounted origin recordsize quota reservation mountpoint \
  63. sharenfs checksum compression atime devices exec readonly setuid \
  64. snapdir aclmode aclinherit canmount primarycache secondarycache \
  65. usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
  66. userquota@root groupquota@root userused@root groupused@root
  67. $ZFS upgrade -v > /dev/null 2>&1
  68. if [[ $? -eq 0 ]]; then
  69. set -A all_props ${all_props[*]} version
  70. fi
  71. depth_fs_setup
  72. mntpnt=$(get_prop mountpoint $DEPTH_FS)
  73. DEPTH_OUTPUT="$mntpnt/depth_output"
  74. EXPECT_OUTPUT="$mntpnt/expect_output"
  75. typeset -i prop_numb=16
  76. typeset -i old_val=0
  77. typeset -i j=0
  78. typeset eg_opt="$DEPTH_FS"$
  79. for dp in ${depth_array[@]}; do
  80. (( j=old_val+1 ))
  81. while (( j<=dp && j<=MAX_DEPTH )); do
  82. eg_opt="$eg_opt""|d""$j"$
  83. (( j+=1 ))
  84. done
  85. for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do
  86. log_must eval "$ZFS get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT"
  87. log_must eval "$ZFS get -rH -o name $prop $DEPTH_FS | $EGREP -e '$eg_opt' > $EXPECT_OUTPUT"
  88. log_must $DIFF $DEPTH_OUTPUT $EXPECT_OUTPUT
  89. done
  90. (( old_val=dp ))
  91. done
  92. log_pass "'zfs get -d <n>' should get expected output."