PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_001_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 127 lines | 59 code | 16 blank | 52 comment | 4 complexity | f5a41012378357041f8844925a3c11dd 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 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zpool_add_001_pos.ksh 1.4 09/06/22 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib
  31. ################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zpool_add_001_pos
  36. #
  37. # DESCRIPTION:
  38. # 'zpool add <pool> <vdev> ...' can successfully add the specified
  39. # devices to the given pool
  40. #
  41. # STRATEGY:
  42. # 1. Create a storage pool
  43. # 2. Add spare devices to the pool
  44. # 3. Verify the devices are added to the pool successfully
  45. #
  46. # TESTABILITY: explicit
  47. #
  48. # TEST_AUTOMATION_LEVEL: automated
  49. #
  50. # CODING STATUS: COMPLETED (2005-09-27)
  51. #
  52. # __stc_assertion_end
  53. #
  54. ###############################################################################
  55. verify_runnable "global"
  56. log_assert "'zpool add <pool> <vdev> ...' can add devices to the pool."
  57. set -A keywords "" "mirror" "raidz" "raidz1" "spare"
  58. set_disks
  59. typeset diskname0=${DISK0#/dev/}
  60. typeset diskname1=${DISK1#/dev/}
  61. typeset diskname2=${DISK2#/dev/}
  62. typeset diskname3=${DISK3#/dev/}
  63. typeset diskname4=${DISK4#/dev/}
  64. pooldevs="${diskname0}\
  65. \"/dev/${diskname0} ${diskname1}\" \
  66. \"${diskname0} ${diskname1} ${diskname2}\""
  67. mirrordevs="\"/dev/${diskname0} ${diskname1}\""
  68. raidzdevs="\"/dev/${diskname0} ${diskname1}\""
  69. typeset -i i=0
  70. typeset vdev
  71. eval set -A poolarray $pooldevs
  72. eval set -A mirrorarray $mirrordevs
  73. eval set -A raidzarray $raidzdevs
  74. while (( $i < ${#keywords[*]} )); do
  75. case ${keywords[i]} in
  76. ""|spare)
  77. for vdev in "${poolarray[@]}"; do
  78. create_pool "$TESTPOOL" "${diskname3}"
  79. log_must poolexists "$TESTPOOL"
  80. log_must $ZPOOL add -f "$TESTPOOL" ${keywords[i]} \
  81. $vdev
  82. log_must iscontained "$TESTPOOL" "$vdev"
  83. destroy_pool "$TESTPOOL"
  84. done
  85. ;;
  86. mirror)
  87. for vdev in "${mirrorarray[@]}"; do
  88. create_pool "$TESTPOOL" "${keywords[i]}" \
  89. "${diskname3}" "${diskname4}"
  90. log_must poolexists "$TESTPOOL"
  91. log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \
  92. $vdev
  93. log_must iscontained "$TESTPOOL" "$vdev"
  94. destroy_pool "$TESTPOOL"
  95. done
  96. ;;
  97. raidz|raidz1)
  98. for vdev in "${raidzarray[@]}"; do
  99. create_pool "$TESTPOOL" "${keywords[i]}" \
  100. "${diskname3}" "${diskname4}"
  101. log_must poolexists "$TESTPOOL"
  102. log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \
  103. $vdev
  104. log_must iscontained "$TESTPOOL" "$vdev"
  105. destroy_pool "$TESTPOOL"
  106. done
  107. ;;
  108. esac
  109. (( i = i+1 ))
  110. done
  111. log_pass "'zpool add <pool> <vdev> ...' executes successfully"