#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# usage: force_state_change <path> <target state>
#
{
[[ $2 != "online" && $2 != "offline" ]] && exit 1
[[ $? != 0 ]] && exit 1
th_manage $1 $2
[[ $? != 0 ]] && exit 1
[[ $? != 0 ]] && exit 1
return 0
}
trap ' terminate $script_pid ' 1 2 3 15
{
exit 1
}
#
# usage: control_workload <path> <pid>
# The following function is called (as a background task) prior to taking a
# driver instance offline and immediately after it is brought online. If the
# th_define process which created this script did not specify a script with the
# -e option then the default action is to run in the background this script
# which will continuously offline and online the instance until the injected
# error is detected by the driver or until the errdef is aborted.
#
{
if [ $? == 0 ]; then
return
fi
#
# Default workload - continuously offline and online the driver instance
# while injecting errors
#
if [[ $2 -gt 0 ]]; then
fi
if [ $# -lt 2 ]; then
elif [ $DRIVER_UNCONFIGURE = 1 ]; then
: no unconfigure action required ;
elif [ $DRIVER_CONFIGURE = 1 ]; then
while [ 1 ]; do
sleep 2
done &
script_pid=$!
fi
}
#
# usage: prepare_for_errdef <path> <driver> <instance> <do_unconfigure>
#
{
export DRIVER_PATH=$1
export DRIVER_NAME=$2
export DRIVER_INSTANCE=$3
export DRIVER_UNCONFIGURE=1
export DRIVER_CONFIGURE=0
th_manage $2 $3 get_handles >/dev/null 2>&1
[[ $? != 0 ]] && exit 1
export DRIVER_UNCONFIGURE=0
export DRIVER_CONFIGURE=1
[[ $4 == 1 ]] &&
}
# usage: monitor_edef <driver> <instance> <nsteps>
{
let aborted=0
trap ' (( aborted += 1 )) ' 16
sleep 2 # Wait for the errdef to be added
[[ $? != 0 ]] && exit 1
let s=0
let x=$3
set -A stats 0 0 1 0 0 0 0 ""
#
# Loop for x reports unless the error is reported or the access fail
# count goes to zero.
#
while (( (x -= 1) >= 0 ))
do
read line
#
# If fail count is zero - increment a loop counter 3 times
# before aborting this errdef.
#
[ "${stats[3]}" = "0" ] && (( (s += 1) > 3 )) && break
done
th_manage $1 $2 clear_errdefs # Clear errors.
[[ $? != 0 ]] && exit 1
echo "${stats[@]}"
}
#
# Install, activate and monitor some error definitions
# usage: run_subtest <driver> <instance> < errdefs
#
{
let edefid=0
drv=$1
inst=$2
then
else
fi
while read line
do
w=${line##*"-w "}
let a=${w%%" "*}
let b=${w##*" "}
let x='a / b'
(( a % b > 0 )) && (( x += 1 ))
monitor_edef $drv $inst $x)
res="test not triggered"
res="success (error undetected)"
res="failure (no service impact reported)"
else
res="success (error reported)"
fi
else
res=
fi
echo $line
if [ -n "${status[7]}" ]; then
let i=6
let l=${#status[@]}
echo " Fail Msg :\t\c"
while (( (i += 1) <= l ))
do
echo "${status[$i]} \c"
done
echo ""
fi
echo "\tFail Time :\t${status[0]}\tMsg Time :\t${status[1]}"
echo "\tAcc count :\t${status[2]}\tFail count:\t${status[3]}"
echo "\tAccess Chk:\t${status[4]}\tEmsg count:\t${status[5]}"
echo "\tSeverity:\tSERVICE UNAFFECTED"
echo "\tSeverity:\tSERVICE DEGRADED"
echo "\tSeverity:\tSERVICE LOST"
fi
done
}