PageRenderTime 78ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs_set/mountpoint_002_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 110 lines | 44 code | 13 blank | 53 comment | 14 complexity | 0eb50b99d499a378cf4bdb3e04db6c49 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 "@(#)mountpoint_002_pos.ksh 1.1 07/01/09 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib
  31. ###############################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: mountpoint_002_pos
  36. #
  37. # DESCRIPTION:
  38. # If ZFS is currently managing the file system but it is currently unmoutned,
  39. # and the mountpoint property is changed, the file system remains unmounted.
  40. #
  41. # STRATEGY:
  42. # 1. Setup a pool and create fs, ctr within it.
  43. # 2. Unmount that dataset
  44. # 2. Change the mountpoint to the valid mountpoint value.
  45. # 3. Check the file system remains unmounted.
  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 dataset "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR"
  58. set -A values "$TESTDIR2" "$TESTDIR_NOTEXISTING"
  59. function cleanup
  60. {
  61. log_must $ZFS set mountpoint=$old_ctr_mpt $TESTPOOL/$TESTCTR
  62. log_must $ZFS set mountpoint=$old_fs_mpt $TESTPOOL/$TESTFS
  63. log_must $ZFS mount -a
  64. [[ -d $TESTDIR2 ]] && log_must $RM -r $TESTDIR2
  65. [[ -d $TESTDIR_NOTEXISTING ]] && log_must $RM -r $TESTDIR_NOTEXISTING
  66. }
  67. log_assert "Setting a valid mountpoint for an unmounted file system, \
  68. it remains unmounted."
  69. log_onexit cleanup
  70. old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
  71. [[ $? != 0 ]] && \
  72. log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS"
  73. old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
  74. [[ $? != 0 ]] && \
  75. log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR"
  76. if [[ ! -d $TESTDIR2 ]]; then
  77. log_must $MKDIR $TESTDIR2
  78. fi
  79. typeset -i i=0
  80. typeset -i j=0
  81. while (( i < ${#dataset[@]} )); do
  82. j=0
  83. if ismounted ${dataset[i]} ; then
  84. log_must $ZFS unmount ${dataset[i]}
  85. fi
  86. log_mustnot ismounted ${dataset[i]}
  87. while (( j < ${#values[@]} )); do
  88. set_n_check_prop "${values[j]}" "mountpoint" \
  89. "${dataset[i]}"
  90. log_mustnot ismounted ${dataset[i]}
  91. (( j += 1 ))
  92. done
  93. cleanup
  94. (( i += 1 ))
  95. done
  96. log_pass "Setting a valid mountpoint for an unmounted file system, \
  97. it remains unmounted."