PageRenderTime 56ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

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