PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 116 lines | 40 code | 16 blank | 60 comment | 7 complexity | b84f377d3a348c8f2f61fb562fcfc0b0 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_002_pos.ksh 1.6 09/06/22 SMI"
  28. #
  29. . $STF_SUITE/tests/cli_root/zfs_get/zfs_get_common.kshlib
  30. . $STF_SUITE/tests/userquota/userquota_common.kshlib
  31. ###############################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zfs_get_002_pos
  36. #
  37. # DESCRIPTION:
  38. # Setting the valid option and properties 'zfs get' return correct value.
  39. # It should be successful.
  40. #
  41. # STRATEGY:
  42. # 1. Create pool, filesystem, dataset, volume and snapshot.
  43. # 2. Getting the options and properties random combination.
  44. # 3. Using the combination as the parameters of 'zfs get' to check the
  45. # command line return value.
  46. #
  47. # TESTABILITY: explicit
  48. #
  49. # TEST_AUTOMATION_LEVEL: automated
  50. #
  51. # CODING_STATUS: COMPLETED (2005-07-04)
  52. #
  53. # __stc_assertion_end
  54. #
  55. ################################################################################
  56. verify_runnable "both"
  57. set -A options " " p r H
  58. set -A zfs_props type used available creation volsize referenced compressratio \
  59. mounted origin recordsize quota reservation mountpoint sharenfs \
  60. checksum compression atime devices exec readonly setuid snapdir \
  61. aclmode aclinherit canmount primarycache secondarycache \
  62. usedbychildren usedbydataset usedbyrefreservation usedbysnapshots
  63. $ZFS upgrade -v > /dev/null 2>&1
  64. if [[ $? -eq 0 ]]; then
  65. set -A zfs_props ${zfs_props[*]} version
  66. fi
  67. if is_userquota_supported; then
  68. set -A userquota_props userquota@root groupquota@root \
  69. userused@root groupused@root
  70. fi
  71. set -A props -- "${zfs_props[@]}" "${userquota_props[@]}"
  72. set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
  73. $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP
  74. log_assert "Setting the valid options and properties 'zfs get' return correct "\
  75. "value. It should be successful."
  76. log_onexit cleanup
  77. # Create volume and filesystem's snapshot
  78. create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
  79. create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
  80. #
  81. # Begin to test 'get [-prH] <property[,property]...>
  82. # <filesystem|dataset|volume|snapshot>'
  83. # 'get [-prH] <-a|-d> <filesystem|dataset|volume|snapshot>"
  84. #
  85. typeset -i opt_numb=8
  86. typeset -i prop_numb=20
  87. for dst in ${dataset[@]}; do
  88. # option can be empty, so "" is necessary.
  89. for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
  90. for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
  91. do
  92. $ZFS get $opt $prop $dst > /dev/null 2>&1
  93. ret=$?
  94. if [[ $ret != 0 ]]; then
  95. log_fail "$ZFS get $opt $prop $dst (Code: $ret)"
  96. fi
  97. done
  98. done
  99. done
  100. log_pass "Setting the valid options to dataset, 'zfs get' pass."