PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 123 lines | 65 code | 19 blank | 39 comment | 16 complexity | 3d3dd44e6e665e6f22eee104fb2f98fd MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh -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. #
  23. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
  31. #
  32. # DESCRIPTION:
  33. # Setting valid canmount to filesystem, it is successful.
  34. # Whatever is set to volume or snapshot, it is failed.
  35. # 'zfs set canmount=on|off <fs>'
  36. #
  37. # STRATEGY:
  38. # 1. Setup a pool and create fs, volume, snapshot clone within it.
  39. # 2. Loop all the valid mountpoint value.
  40. # 3. Check the return value.
  41. #
  42. verify_runnable "both"
  43. set -A dataset_pos \
  44. "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTCLONE"
  45. if is_global_zone ; then
  46. set -A dataset_neg \
  47. "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS@$TESTSNAP" \
  48. "$TESTPOOL/$TESTVOL@$TESTSNAP" "$TESTPOOL/$TESTCLONE1"
  49. else
  50. set -A dataset_neg \
  51. "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTVOL@$TESTSNAP"
  52. fi
  53. set -A values "on" "off"
  54. function cleanup
  55. {
  56. if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then
  57. log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
  58. fi
  59. if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then
  60. log_must zfs destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP
  61. fi
  62. [[ -n $old_ctr_canmount ]] && \
  63. log_must zfs set canmount=$old_ctr_canmount $TESTPOOL/$TESTCTR
  64. [[ -n $old_fs_canmount ]] && \
  65. log_must zfs set canmount=$old_fs_canmount $TESTPOOL/$TESTFS
  66. zfs unmount -a > /dev/null 2>&1
  67. log_must zfs mount -a
  68. }
  69. log_assert "Setting a valid property of canmount to file system, it must be successful."
  70. log_onexit cleanup
  71. typeset old_fs_canmount="" old_ctr_canmount=""
  72. old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
  73. [[ $? != 0 ]] && \
  74. log_fail "Get the $TESTPOOL/$TESTFS canmount error."
  75. old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
  76. [[ $? != 0 ]] && \
  77. log_fail "Get the $TESTPOOL/$TESTCTR canmount error."
  78. log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
  79. log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP
  80. log_must zfs clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE
  81. log_must zfs clone $TESTPOOL/$TESTVOL@$TESTSNAP $TESTPOOL/$TESTCLONE1
  82. for dataset in "${dataset_pos[@]}" ; do
  83. for value in "${values[@]}" ; do
  84. set_n_check_prop "$value" "canmount" "$dataset"
  85. if [[ $value == "off" ]]; then
  86. log_mustnot ismounted $dataset
  87. log_mustnot zfs mount $dataset
  88. log_mustnot ismounted $dataset
  89. else
  90. if ! ismounted $dataset ; then
  91. log_must zfs mount $dataset
  92. fi
  93. log_must ismounted $dataset
  94. fi
  95. done
  96. done
  97. for dataset in "${dataset_neg[@]}" ; do
  98. for value in "${values[@]}" ; do
  99. set_n_check_prop "$value" "canmount" \
  100. "$dataset" "false"
  101. log_mustnot ismounted $dataset
  102. done
  103. done
  104. log_pass "Setting canmount to filesystem pass."