PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 124 lines | 66 code | 15 blank | 43 comment | 24 complexity | 527c691af8c298e532a08ece75f6b3fa 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 2008 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
  31. #
  32. # DESCRIPTION:
  33. # 'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create an
  34. # alternate root pool or a new pool mounted at the specified mountpoint.
  35. #
  36. # STRATEGY:
  37. # 1. Create a pool with '-m' option
  38. # 2. Verify the pool is mounted at the specified mountpoint
  39. #
  40. verify_runnable "global"
  41. function cleanup
  42. {
  43. poolexists $TESTPOOL && destroy_pool $TESTPOOL
  44. rm -rf $TESTDIR $TESTDIR1
  45. }
  46. log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \
  47. "an alternate pool or a new pool mounted at the specified mountpoint."
  48. log_onexit cleanup
  49. set -A pooltype "" "mirror" "raidz" "raidz1" "raidz2"
  50. #
  51. # cleanup the pools created in previous case if zpool_create_004_pos timedout
  52. #
  53. for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do
  54. poolexists $pool && destroy_pool $pool
  55. done
  56. #prepare raw file for file disk
  57. rm -rf $TESTDIR
  58. log_must mkdir -p $TESTDIR
  59. typeset -i i=1
  60. while (( i < 4 )); do
  61. log_must mkfile $FILESIZE $TESTDIR/file.$i
  62. (( i = i + 1 ))
  63. done
  64. #Remove the directory with name as pool name if it exists
  65. rm -rf /$TESTPOOL
  66. file=$TESTDIR/file
  67. for opt in "-R $TESTDIR1" "-m $TESTDIR1" \
  68. "-R $TESTDIR1 -m $TESTDIR1" "-m $TESTDIR1 -R $TESTDIR1"
  69. do
  70. i=0
  71. while (( i < ${#pooltype[*]} )); do
  72. #Remove the testing pool and its mount directory
  73. poolexists $TESTPOOL && \
  74. log_must zpool destroy -f $TESTPOOL
  75. [[ -d $TESTDIR1 ]] && rm -rf $TESTDIR1
  76. log_must zpool create $opt $TESTPOOL ${pooltype[i]} \
  77. $file.1 $file.2 $file.3
  78. ! poolexists $TESTPOOL && \
  79. log_fail "Creating pool with $opt fails."
  80. mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'`
  81. (( ${#mpt} == 0 )) && \
  82. log_fail "$TESTPOOL created with $opt is not mounted."
  83. mpt_val=$(get_prop "mountpoint" $TESTPOOL)
  84. [[ "$mpt" != "$mpt_val" ]] && \
  85. log_fail "The value of mountpoint property is different\
  86. from the output of zfs mount"
  87. if [[ "$opt" == "-m $TESTDIR1" ]]; then
  88. [[ ! -d $TESTDIR1 ]] && \
  89. log_fail "$TESTDIR1 is not created automatically."
  90. [[ "$mpt" != "$TESTDIR1" ]] && \
  91. log_fail "$TESTPOOL is not mounted on $TESTDIR1."
  92. elif [[ "$opt" == "-R $TESTDIR1" ]]; then
  93. [[ ! -d $TESTDIR1/$TESTPOOL ]] && \
  94. log_fail "$TESTDIR1/$TESTPOOL is not created automatically."
  95. [[ "$mpt" != "$TESTDIR1/$TESTPOOL" ]] && \
  96. log_fail "$TESTPOOL is not mounted on $TESTDIR1/$TESTPOOL."
  97. else
  98. [[ ! -d ${TESTDIR1}$TESTDIR1 ]] && \
  99. log_fail "${TESTDIR1}$TESTDIR1 is not created automatically."
  100. [[ "$mpt" != "${TESTDIR1}$TESTDIR1" ]] && \
  101. log_fail "$TESTPOOL is not mounted on ${TESTDIR1}$TESTDIR1."
  102. fi
  103. [[ -d /$TESTPOOL ]] && \
  104. log_fail "The default mountpoint /$TESTPOOL is created" \
  105. "while with $opt option."
  106. (( i = i + 1 ))
  107. done
  108. done
  109. log_pass "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' works as expected."