4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 #pragma ident "%Z%%M% %I% %E% SMI"
28 # usage: force_state_change <path> <target state>
32 [[ $2 != "online" && $2 != "offline" ]] && exit 1
33 th_manage
$1 getstate |
read path state busy
34 [[ $?
!= 0 ]] && exit 1
35 [[ "$state" = "$2" ]] && return 0
37 [[ $?
!= 0 ]] && exit 1
38 th_manage
$1 getstate |
read path state busy
39 [[ $?
!= 0 ]] && exit 1
40 [[ "$state" != "$2" ]] && exit 1
46 trap ' terminate $script_pid ' 1 2 3 15
49 [[ $1 -gt 0 ]] && kill $1 > /dev
/null
2>&1
54 # usage: control_workload <path> <pid>
55 # The following function is called (as a background task) prior to taking a
56 # driver instance offline and immediately after it is brought online. If the
57 # th_define process which created this script did not specify a script with the
58 # -e option then the default action is to run in the background this script
59 # which will continuously offline and online the instance until the injected
60 # error is detected by the driver or until the errdef is aborted.
70 # Default workload - continuously offline and online the driver instance
71 # while injecting errors
74 if [[ $2 -gt 0 ]]; then
75 kill $2 > /dev
/null
2>&1
78 echo syntax
: $0 path pid
79 elif [ $DRIVER_UNCONFIGURE = 1 ]; then
80 : no unconfigure action required
;
81 elif [ $DRIVER_CONFIGURE = 1 ]; then
84 force_state_change
$1 offline
85 force_state_change
$1 online
92 # usage: prepare_for_errdef <path> <driver> <instance> <do_unconfigure>
98 export DRIVER_INSTANCE
=$3
99 export DRIVER_UNCONFIGURE
=1
100 export DRIVER_CONFIGURE
=0
101 control_workload
$1 $script_pid
104 th_manage
$2 $3 get_handles
>/dev
/null
2>&1
105 [[ $?
!= 0 ]] && exit 1
106 force_state_change
$1 offline
107 force_state_change
$1 online
109 export DRIVER_UNCONFIGURE
=0
110 export DRIVER_CONFIGURE
=1
112 control_workload
$1 $script_pid
115 # usage: monitor_edef <driver> <instance> <nsteps>
119 trap ' (( aborted += 1 )) ' 16
120 sleep 2 # Wait for the errdef to be added
121 th_manage
$1 $2 start
122 [[ $?
!= 0 ]] && exit 1
126 set -A stats
0 0 1 0 0 0 0 ""
129 # Loop for x reports unless the error is reported or the access fail
130 # count goes to zero.
132 while (( (x
-= 1) >= 0 ))
134 (( aborted
> 0 )) && break
136 [ -z "$line" ] && break
137 set -A stats $
(echo "$line" |
138 /usr
/bin
/awk -F: '{for (i = 1; i <= NF; i++) print $i}')
139 [ "${stats[6]}" -ne "0" ] && break # Fault was reported
141 # If fail count is zero - increment a loop counter 3 times
142 # before aborting this errdef.
144 [ "${stats[3]}" = "0" ] && (( (s
+= 1) > 3 )) && break
146 th_manage
$1 $2 clear_errdefs
# Clear errors.
147 [[ $?
!= 0 ]] && exit 1
152 # Install, activate and monitor some error definitions
153 # usage: run_subtest <driver> <instance> < errdefs
160 if [ $devpath = "NULL" ]
162 path
=$
(th_manage
$1 $2 getpath
)
168 set -- $
(echo "$line" | \
169 /usr
/bin
/awk '{for (i = 1; i <= NF; i++) print $i}')
174 (( a
% b
> 0 )) && (( x
+= 1 ))
175 prepare_for_errdef
$path $drv $inst 1
176 set -A status $
(th_define $
* 2>.
/elog | \
177 monitor_edef
$drv $inst $x)
178 if [ "${status[2]}" -gt 0 ]; then
179 res
="test not triggered"
180 elif [ "${status[1]}" -eq 0 ]; then
181 res
="success (error undetected)"
182 elif [ "${status[1]}" -gt 0 ]; then
183 if [ "${status[6]}" -eq 16 ]; then
184 res
="failure (no service impact reported)"
186 res
="success (error reported)"
191 echo "Subtest $edefid: Result: \"$res\""
193 if [ -n "${status[7]}" ]; then
196 echo " Fail Msg :\t\c"
197 while (( (i
+= 1) <= l
))
199 echo "${status[$i]} \c"
203 echo "\tFail Time :\t${status[0]}\tMsg Time :\t${status[1]}"
204 echo "\tAcc count :\t${status[2]}\tFail count:\t${status[3]}"
205 echo "\tAccess Chk:\t${status[4]}\tEmsg count:\t${status[5]}"
206 if [ "${status[6]}" -eq 0 ]; then
207 echo "\tSeverity:\tSERVICE UNAFFECTED"
208 elif [ "${status[6]}" -eq -16 ]; then
209 echo "\tSeverity:\tSERVICE DEGRADED"
210 elif [ "${status[6]}" -eq -32 ]; then
211 echo "\tSeverity:\tSERVICE LOST"
217 prepare_for_errdef
$path $drv $inst 0