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

/tests/sys/cddl/zfs/tests/zinject/zinject_003_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 144 lines | 63 code | 27 blank | 54 comment | 6 complexity | 1d051436fbef43ffc79105650561476c 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 "@(#)zinject_003_pos.ksh 1.3 09/06/22 SMI"
  28. #
  29. ###############################################################################
  30. #
  31. # __stc_assertion_start
  32. #
  33. # ID: zinject_003_pos
  34. #
  35. # DESCRIPTION:
  36. #
  37. # Inject an error into the first metadnode in the block
  38. # Verify the filesystem unmountable since dnode be injected.
  39. #
  40. # STRATEGY:
  41. # 1) Populate ZFS file system
  42. # 2) Inject an error into the first metadnode in the block.
  43. # 3) Verify the filesystem unmountable,
  44. # and 'zpool status -v' will display the error as expect.
  45. #
  46. # TESTABILITY: explicit
  47. #
  48. # TEST_AUTOMATION_LEVEL: automated
  49. #
  50. # CODING_STATUS: COMPLETED (2007-02-01)
  51. #
  52. # __stc_assertion_end
  53. #
  54. ################################################################################
  55. . $STF_SUITE/tests/zinject/zinject.kshlib
  56. verify_runnable "global"
  57. log_assert "Verify fault inject handle into first metadnode " \
  58. "cause filesystem unmountable."
  59. log_onexit cleanup_env
  60. set -A types "" "mirror" "raidz" "raidz2"
  61. typeset -i maxnumber=1
  62. function test_zinject_unit
  63. {
  64. typeset etype=$1
  65. typeset object=$2
  66. typeset errno=$3
  67. typeset ereport=$4
  68. typeset now
  69. typeset otype="file"
  70. [[ -d $object ]] && otype="dir"
  71. now=`date '+%m/%d/%y %H:%M:%S'`
  72. inject_fault $etype $object $errno 1
  73. unmounted $TESTPOOL/$TESTFS || \
  74. log_fail "$TESTPOOL/$TESTFS mount unexpected."
  75. log_must check_status $TESTPOOL "$TESTPOOL/$TESTFS:<0x0>"
  76. inject_clear
  77. log_must $ZFS mount -a
  78. }
  79. function test_zinject
  80. {
  81. typeset basedir=$1
  82. typeset pooltype=$2
  83. typeset -i i=0
  84. typeset etype="dnode"
  85. set -A errset "io" "ereport.fs.zfs.io ereport.fs.zfs.data"
  86. ((i=${#errset[*]}))
  87. if [[ -n $pooltype ]] ; then
  88. errset[i]="checksum"
  89. errset[((i+1))]="ereport.fs.zfs.checksum ereport.fs.zfs.data"
  90. else
  91. errset[i]="checksum"
  92. errset[((i+1))]="ereport.fs.zfs.data"
  93. fi
  94. i=0
  95. while ((i < ${#errset[*]} )); do
  96. for object in $basedir/testfile.$maxnumber \
  97. $basedir/testdir.$maxnumber ; do
  98. test_zinject_unit $etype $object \
  99. ${errset[i]} "${errset[((i+1))]}"
  100. done
  101. (( i = i + 2 ))
  102. done
  103. }
  104. inject_clear
  105. for type in "${types[@]}"; do
  106. create_pool $TESTPOOL $type $pooldevs spare $sparedevs
  107. log_must $ZPOOL add -f $TESTPOOL log $logdevs
  108. log_must $ZPOOL add -f $TESTPOOL cache $cachedevs
  109. log_must $ZPOOL replace $TESTPOOL $VDEV0 $sparedevs
  110. log_must $ZFS create $TESTPOOL/$TESTFS
  111. log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  112. populate_test_env $TESTDIR/bad_dir $maxnumber
  113. test_zinject $TESTDIR/bad_dir $type
  114. cleanup_env
  115. done
  116. log_pass "Fault inject handle into first metadnode " \
  117. "cause filesystem unmountable."