PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs_copies/zfs_copies_001_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 126 lines | 56 code | 16 blank | 54 comment | 12 complexity | a618a507c923d7537b92b3a06c87c768 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 2007 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_copies_001_pos.ksh 1.1 07/07/31 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/cli_root/zfs_copies/zfs_copies.kshlib
  31. ################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zfs_copies_001_pos
  36. #
  37. # DESCRIPTION:
  38. # Verify "copies" property can be correctly set as 1,2 and 3 and different
  39. # filesystem can have different value of "copies" property within the same pool.
  40. #
  41. # STRATEGY:
  42. # 1. Create different filesystems with copies set as 1,2,3;
  43. # 2. Verify that the "copies" property has been set correctly
  44. #
  45. # TESTABILITY: explicit
  46. #
  47. # TEST_AUTOMATION_LEVEL: automated
  48. #
  49. # CODING_STATUS: COMPLETED (2006-05-31)
  50. #
  51. # __stc_assertion_end
  52. #
  53. ################################################################################
  54. verify_runnable "both"
  55. function cleanup
  56. {
  57. typeset ds
  58. for ds in $fs1 $fs2 $vol1 $vol2; do
  59. if datasetexists $ds; then
  60. log_must $ZFS destroy $ds
  61. fi
  62. done
  63. }
  64. log_assert "Verify 'copies' property with correct arguments works or not."
  65. log_onexit cleanup
  66. fs=$TESTPOOL/$TESTFS
  67. fs1=$TESTPOOL/$TESTFS1
  68. fs2=$TESTPOOL/$TESTFS2
  69. vol=$TESTPOOL/$TESTVOL
  70. vol1=$TESTPOOL/$TESTVOL1
  71. vol2=$TESTPOOL/$TESTVOL2
  72. #
  73. # Check the default value for copies property
  74. #
  75. for ds in $fs $vol; do
  76. cmp_prop $ds 1
  77. done
  78. for val in 1 2 3; do
  79. log_must $ZFS create -o copies=$val $fs1
  80. if is_global_zone; then
  81. log_must $ZFS create -V $VOLSIZE -o copies=$val $vol1
  82. else
  83. log_must $ZFS create -o copies=$val $vol1
  84. fi
  85. for ds in $fs1 $vol1; do
  86. cmp_prop $ds $val
  87. done
  88. for val2 in 3 2 1; do
  89. log_must $ZFS create -o copies=$val2 $fs2
  90. if is_global_zone; then
  91. log_must $ZFS create -V $VOLSIZE -o copies=$val2 $vol2
  92. else
  93. log_must $ZFS create -o copies=$val2 $vol2
  94. fi
  95. for ds in $fs2 $vol2; do
  96. cmp_prop $ds $val2
  97. log_must $ZFS destroy $ds
  98. done
  99. done
  100. for ds in $fs1 $vol1; do
  101. log_must $ZFS destroy $ds
  102. done
  103. done
  104. for val in 3 2 1; do
  105. for ds in $fs $vol; do
  106. log_must $ZFS set copies=$val $ds
  107. cmp_prop $ds $val
  108. done
  109. done
  110. log_pass "'copies' property with correct arguments works as expected. "