1 #!/usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)zinject_001_pos.ksh 1.3 09/06/22 SMI"
32 ###############################################################################
34 # __stc_assertion_start
40 # Inject an error into the plain file contents of a file.
41 # Verify fmdump will get the expect ereport
44 # 1) Populate ZFS file system
45 # 2) Inject an error into the plain file contents of a file.
46 # 3) Verify fmdump get the ereport as expect.
47 # <Errno> <Expect ereport> <Comments>
48 # io ereport.fs.zfs.io
50 # checksum ereport.fs.zfs.checksum Non-stripe pool
52 # checksum ereport.fs.zfs.data Stripe pool only
54 # TESTABILITY: explicit
56 # TEST_AUTOMATION_LEVEL: automated
58 # CODING_STATUS: COMPLETED (2007-02-01)
62 ################################################################################
64 . $STF_SUITE/tests/zinject/zinject.kshlib
66 verify_runnable "global"
68 log_assert "Verify fault inject handle content error successfully."
69 log_onexit cleanup_env
71 set -A types "" "mirror" "raidz" "raidz2"
73 typeset -i maxnumber=300
75 function test_zinject_unit
84 [[ -d $object ]] && otype="dir"
86 now=`date '+%m/%d/%y %H:%M:%S'`
87 inject_fault $etype $object $errno
89 trigger_inject $etype $object $otype
91 log_must check_ereport "$now" $ereport
93 log_must check_status $TESTPOOL $object
105 set -A errset "io" "ereport.fs.zfs.io ereport.fs.zfs.data"
108 if [[ -n $pooltype ]] ; then
110 errset[((i+1))]="ereport.fs.zfs.checksum ereport.fs.zfs.data"
113 errset[((i+1))]="ereport.fs.zfs.data"
117 while ((i < ${#errset[*]} )); do
119 for object in $basedir/testfile.$maxnumber \
120 $basedir/testdir.$maxnumber ; do
122 test_zinject_unit $etype $object \
123 ${errset[i]} "${errset[((i+1))]}"
131 for type in "${types[@]}"; do
132 create_pool $TESTPOOL $type $pooldevs spare $sparedevs
134 log_must $ZPOOL add -f $TESTPOOL log $logdevs
135 log_must $ZPOOL add -f $TESTPOOL cache $cachedevs
137 log_must $ZPOOL replace $TESTPOOL $VDEV0 $sparedevs
138 log_must $ZFS create $TESTPOOL/$TESTFS
139 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
141 populate_test_env $TESTDIR $maxnumber
142 test_zinject $TESTDIR $type
147 log_pass "Fault inject handle content error successfully."