fmsim.ksh revision d9638e547d8811f2c689977f8dd2a353938b61fd
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
umask 022
else
fi
if [[ -n "$CODEMGR_WS" ]]; then
elif [[ -n "$ROOT" ]]; then
else
sysroot=/
fi
eol='\'
files=
simchan=com.sun:fm:fmd$$
simscript=run
simpid=
truss_cmd=
truss_args=
dump_args=
inj_args=
fmd_args=
opt_h=false
opt_i=false
opt_s=false
opt_w=false
opt_x=false
function cp_so
{
[[ $type != T ]] && continue
case $name in
esac
done
die "\nunknown .so type -- $1"
}
function list_cmds
{
for cmd in fmadm fmdump fmstat; do
done
}
function wait_status
{
if [[ $1 -gt 128 ]]; then
sig=$(kill -l $(($1 - 128)))
die "fmd terminated from signal $sig (see $simroot)"
elif [[ $1 -ne 0 ]]; then
die "fmd terminated with status $1 (see $simroot)"
fi
}
function wait_prompt
{
echo "fmsim: [ Press return to $* ] \c"
mode=$(stty -g)
stty -echo -isig min 1 time 0
read s; echo
stty $mode
}
function die
{
echo "fmsim: $*" >& 2
$opt_w && wait_prompt exit
[[ -n "$simpid" ]] && exit 1 || exit 2
}
while [[ $# -gt 0 ]]; do
case "$c" in
d)
simroot=$OPTARG
;;
D)
truss_cmd=dtrace
truss_args="-s $OPTARG -c"
quote="'"; eol=""
;;
e|v|V)
;;
h|i|s|w|x)
eval opt_$c'='true
;;
o)
;;
t)
truss_cmd=truss
;;
:)
;;
*)
;;
esac
done
if [[ $# -gt 0 ]]; then
if [[ -d $1 ]]; then
else
fi
shift
fi
done
for file in $files; do
done
exit 0
fi
cd $simroot || exit 1
echo "done."
echo "done."
done
cd $cwd || exit $1
for file in $files; do
case $base in
esac
done
cd $simroot || exit 1
echo " done."
cat >$simscript <<EOS
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
#
export _THREAD_ERROR_DETECTION=2
exec $truss_cmd $truss_args $quote./usr/lib/fm/fmd/fmd -R $simroot $eol
-o fg=true -o clock=simulated $eol
-o rpc.adm.prog=0 -o rpc.adm.path=$simroot/rpc $eol
EOS
chmod 0555 $simscript
echo "done."
if $opt_s; then
exit 0
fi
./$simscript &
simpid=$!
trap '' INT HUP
cd $cwd
i=0
while [[ ! -s $simroot/rpc ]]; do
let i="$i + 1"
sleep 1
done
wait $simpid
wait_status $?
}
for arg in $inj_args; do
}
echo "done."
done
if [[ $opt_i = false ]]; then
echo "done."
fi
wait $simpid
status=$?
fi
wait_status $status
$opt_w && wait_prompt exit
exit 0