PageRenderTime 37ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 124 lines | 49 code | 21 blank | 54 comment | 5 complexity | ff7d600a4d9591d8ee91cd68e9847208 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_007_neg.ksh 1.3 07/10/09 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_007_neg
  36. #
  37. # DESCRIPTION:
  38. # Try each 'zfs unmount' with inapplicable scenarios to make sure
  39. # it returns an error. include:
  40. # * Multiple filesystem|mountpoint specified
  41. # * '-a', but also with a specific filesystem|mountpoint.
  42. #
  43. # STRATEGY:
  44. # 1. Create an array of parameters
  45. # 2. For each parameter in the array, execute the sub-command
  46. # 3. Verify an error is returned.
  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. multifs="$TESTFS $TESTFS1"
  59. datasets=""
  60. for fs in $multifs ; do
  61. datasets="$datasets $TESTPOOL/$fs"
  62. done
  63. set -A args "$unmountall $TESTPOOL/$TESTFS" \
  64. "$unmountcmd $datasets"
  65. function setup_all
  66. {
  67. typeset fs
  68. for fs in $multifs ; do
  69. setup_filesystem "$DISKS" "$TESTPOOL" \
  70. "$fs" \
  71. "${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}/$TESTPOOL/$fs"
  72. done
  73. return 0
  74. }
  75. function cleanup_all
  76. {
  77. typeset fs
  78. cleanup_filesystem "$TESTPOOL" "$TESTFS1"
  79. log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  80. [[ -d ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} ]] && \
  81. $RM -rf ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}
  82. return 0
  83. }
  84. function verify_all
  85. {
  86. typeset fs
  87. for fs in $multifs ; do
  88. log_must mounted $TESTPOOL/$fs
  89. done
  90. return 0
  91. }
  92. log_assert "Badly-formed 'zfs $unmountcmd' with inapplicable scenarios " \
  93. "should return an error."
  94. log_onexit cleanup_all
  95. log_must setup_all
  96. typeset -i i=0
  97. while (( i < ${#args[*]} )); do
  98. log_mustnot $ZFS ${args[i]}
  99. ((i = i + 1))
  100. done
  101. log_must verify_all
  102. log_pass "Badly formed 'zfs $unmountcmd' with inapplicable scenarios " \
  103. "fail as expected."