/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_011_neg.ksh

https://bitbucket.org/freebsd/freebsd-base · Korn Shell · 140 lines · 62 code · 16 blank · 62 comment · 4 complexity · 914fcf64f56f11696f5ff69c8ce60e7b 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 2008 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. #ident "@(#)zpool_create_011_neg.ksh 1.5 08/11/03 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib
  31. ################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zpool_create_011_neg
  36. #
  37. # DESCRIPTION:
  38. # 'zpool create' will fail in the following cases:
  39. # existent pool; device is part of an active pool; nested virtual devices;
  40. # differently sized devices without -f option; device being currently
  41. # mounted; devices in /etc/fstab; specified as the dedicated dump device.
  42. #
  43. # STRATEGY:
  44. # 1. Create case scenarios
  45. # 2. For each scenario, try to create a new pool with the virtual devices
  46. # 3. Verify the creation is failed.
  47. #
  48. # TESTABILITY: explicit
  49. #
  50. # TEST_AUTOMATION_LEVEL: automated
  51. #
  52. # CODING_STATUS: COMPLETED (2005-07-04)
  53. #
  54. # __stc_assertion_end
  55. #
  56. ################################################################################
  57. verify_runnable "global"
  58. function cleanup
  59. {
  60. for pool in $TESTPOOL $TESTPOOL1
  61. do
  62. destroy_pool $pool
  63. done
  64. if [[ -n $specified_dump_dev ]]; then
  65. $DUMPON -r $specified_dump_dev
  66. fi
  67. }
  68. log_assert "'zpool create' should be failed with inapplicable scenarios."
  69. log_onexit cleanup
  70. if [[ -n $DISK ]]; then
  71. disk=$DISK
  72. else
  73. disk=$DISK0
  74. fi
  75. pooldev1=${disk}p1
  76. pooldev2=${disk}p2
  77. mirror1="${disk}p2 ${disk}p3"
  78. mirror2="${disk}p4 ${disk}p5"
  79. raidz1=$mirror1
  80. raidz2=$mirror2
  81. diff_size_dev="${disk}p6 ${disk}p7"
  82. fstab_dev=$(find_fstab_dev)
  83. specified_dump_dev=${disk}
  84. lba=$(get_partition_end $disk 6)
  85. $GPART delete -i 7 $disk
  86. set_partition 7 "$lba" $SIZE1 $disk
  87. create_pool "$TESTPOOL" "$pooldev1"
  88. #
  89. # Set up the testing scenarios parameters
  90. #
  91. set -A arg "$TESTPOOL $pooldev2" \
  92. "$TESTPOOL1 $pooldev1" \
  93. "$TESTPOOL1 $TESTDIR0/$FILEDISK0" \
  94. "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \
  95. "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \
  96. "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \
  97. "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \
  98. "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \
  99. "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \
  100. "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \
  101. "$TESTPOOL1 mirror $diff_size_dev" \
  102. "$TESTPOOL1 raidz $diff_size_dev" \
  103. "$TESTPOOL1 raidz1 $diff_size_dev" \
  104. "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
  105. "$TESTPOOL1 $fstab_dev" \
  106. "$TESTPOOL1 ${disk}s10" \
  107. "$TESTPOOL1 spare $pooldev2"
  108. typeset -i i=0
  109. while (( i < ${#arg[*]} )); do
  110. log_mustnot $ZPOOL create ${arg[i]}
  111. (( i = i+1 ))
  112. done
  113. # now destroy the pool to be polite
  114. log_must $ZPOOL destroy -f $TESTPOOL
  115. # create/destroy a pool as a simple way to set the partitioning
  116. # back to something normal so we can use this $disk as a dump device
  117. log_must $ZPOOL create -f $TESTPOOL3 $disk
  118. log_must $ZPOOL destroy -f $TESTPOOL3
  119. log_must dumpon $specified_dump_dev
  120. log_mustnot $ZPOOL create -f $TESTPOOL1 "$specified_dump_dev"
  121. # Also check to see that in-use checking prevents us from creating
  122. # a zpool from just the first slice on the disk.
  123. log_mustnot $ZPOOL create -f $TESTPOOL1 ${specified_dump_dev}s0
  124. log_pass "'zpool create' is failed as expected with inapplicable scenarios."