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

/tests/sys/cddl/zfs/tests/cli_root/zfs_unmount/zfs_unmount_all_001_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 209 lines | 116 code | 39 blank | 54 comment | 21 complexity | 0d27795d506164d1ad903c87fea29e19 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_unmount_all_001_pos.ksh 1.3 07/07/31 SMI"
  28. #
  29. . $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib
  30. . $STF_SUITE/tests/cli_root/zfs_unmount/zfs_unmount.kshlib
  31. ################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zfs_unmount_all_001_pos
  36. #
  37. # DESCRIPTION:
  38. # Verify that 'zfs unmount -a[f]' succeeds as root.
  39. #
  40. # STRATEGY:
  41. # 1. Create a group of pools with specified vdev.
  42. # 2. Create zfs filesystems within the given pools.
  43. # 3. Mount all the filesystems.
  44. # 4. Verify that 'zfs unmount -a[f]' command succeed,
  45. # and all available ZFS filesystems are unmounted.
  46. # 5. Verify that 'zfs mount' is identical with 'df -F zfs'
  47. #
  48. # TESTABILITY: explicit
  49. #
  50. # TEST_AUTOMATION_LEVEL: automated
  51. #
  52. # CODING_STATUS: COMPLETED (2005-07-12)
  53. #
  54. # __stc_assertion_end
  55. #
  56. ################################################################################
  57. verify_runnable "both"
  58. set -A fs "$TESTFS" "$TESTFS1"
  59. set -A ctr "" "$TESTCTR" "$TESTCTR1" "$TESTCTR/$TESTCTR1"
  60. set -A vol "$TESTVOL" "$TESTVOL1"
  61. function setup_all
  62. {
  63. typeset -i i=0
  64. typeset -i j=0
  65. typeset path
  66. while (( i < ${#ctr[*]} )); do
  67. path=${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}/$TESTPOOL
  68. if [[ -n ${ctr[i]} ]]; then
  69. path=$path/${ctr[i]}
  70. setup_filesystem "$DISKS" "$TESTPOOL" \
  71. "${ctr[i]}" "$path" \
  72. "ctr"
  73. fi
  74. if is_global_zone ; then
  75. j=0
  76. while (( j < ${#vol[*]} )); do
  77. setup_filesystem "$DISKS" "$TESTPOOL" \
  78. "${ctr[i]}/${vol[j]}" \
  79. "$path/${vol[j]}" \
  80. "vol"
  81. ((j = j + 1))
  82. done
  83. fi
  84. j=0
  85. while (( j < ${#fs[*]} )); do
  86. setup_filesystem "$DISKS" "$TESTPOOL" \
  87. "${ctr[i]}/${fs[j]}" \
  88. "$path/${fs[j]}"
  89. ((j = j + 1))
  90. done
  91. ((i = i + 1))
  92. done
  93. return 0
  94. }
  95. function cleanup_all
  96. {
  97. typeset -i i=0
  98. typeset -i j=0
  99. ((i = ${#ctr[*]} - 1))
  100. while (( i >= 0 )); do
  101. if is_global_zone ; then
  102. j=0
  103. while (( j < ${#vol[*]} )); do
  104. cleanup_filesystem "$TESTPOOL" \
  105. "${ctr[i]}/${vol[j]}"
  106. ((j = j + 1))
  107. done
  108. fi
  109. j=0
  110. while (( j < ${#fs[*]} )); do
  111. cleanup_filesystem "$TESTPOOL" \
  112. "${ctr[i]}/${fs[j]}"
  113. ((j = j + 1))
  114. done
  115. [[ -n ${ctr[i]} ]] && \
  116. cleanup_filesystem "$TESTPOOL" "${ctr[i]}"
  117. ((i = i - 1))
  118. done
  119. [[ -d ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} ]] && \
  120. $RM -rf ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}
  121. }
  122. function verify_all
  123. {
  124. typeset -i i=0
  125. typeset -i j=0
  126. typeset path
  127. while (( i < ${#ctr[*]} )); do
  128. path=$TESTPOOL
  129. [[ -n ${ctr[i]} ]] && \
  130. path=$path/${ctr[i]}
  131. if is_global_zone ; then
  132. j=0
  133. while (( j < ${#vol[*]} )); do
  134. log_must unmounted "$path/${vol[j]}"
  135. ((j = j + 1))
  136. done
  137. fi
  138. j=0
  139. while (( j < ${#fs[*]} )); do
  140. log_must unmounted "$path/${fs[j]}"
  141. ((j = j + 1))
  142. done
  143. log_must unmounted "$path"
  144. ((i = i + 1))
  145. done
  146. return 0
  147. }
  148. log_assert "Verify that 'zfs $unmountall' succeeds as root, " \
  149. "and all available ZFS filesystems are unmounted."
  150. log_onexit cleanup_all
  151. log_must setup_all
  152. typeset opt
  153. for opt in "-a" "-fa"; do
  154. log_must $ZFS $mountall
  155. if [[ $opt == "-fa" ]]; then
  156. mntpnt=$(get_prop mountpoint ${TESTPOOL}/${TESTCTR}/${TESTFS})
  157. cd $mntpnt
  158. log_mustnot $ZFS unmount -a
  159. fi
  160. log_must $ZFS unmount $opt
  161. if [[ $opt == "-fa" ]]; then
  162. cd /tmp
  163. fi
  164. log_must verify_all
  165. log_note "Verify that 'zfs $mountcmd' will display " \
  166. "all ZFS filesystems currently mounted."
  167. log_must verify_mount_display
  168. done
  169. log_pass "'zfs mount -[f]a' succeeds as root, " \
  170. "and all available ZFS filesystems are unmounted."