Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / n2 / api / sam / src / getnetwork
#!/bin/sh
tool=$0
usage()
{
echo ""
echo "usage: `/bin/basename $tool` -i <nic> <installdir>"
echo ""
echo ' -i <nic> : specify the nic used.'
echo ""
echo " Get network veracity scripts: clientdump.ver,client.ver and server.ver with the specified nic and put them in <installdir>."
echo " Before you use this, you should run "getstart" to generate start.ver which is included in the above files."
echo ""
}
while getopts hi: OPT; do
case $OPT in
i)
nic="$OPTARG"
;;
h)
usage
exit 0
;;
*)
usage
exit 2
;;
esac
done
shift `/bin/expr $OPTIND - 1`
if [ "$nic" = " " ]; then
echo "Error: I need one -i argument."
usage
exit 2
fi
installclientdump=$1/clientdump.ver
installclient=$1/client.ver
installserver=$1/server.ver
for installfile in $installclientdump $installclient $installserver;
do
cat >$installfile <<EOF
include "start.ver"
timeout -1
expect
set switchmachine [lindex \$argv 3]
set serverport [lindex \$argv 4]
EOF
if [ $installfile = $installclientdump ]; then
if [ $nic = "niu" ]; then
cat >>$installclientdump <<EOF
set clientip0 [lindex \$argv 5]
set clientip1 [lindex \$argv 6]
end_expect
EOF
else
cat >>$installclientdump <<EOF
set clientip [lindex \$argv 5]
end_expect
EOF
fi
elif [ $installfile = $installclient ]; then
cat >>$installclient <<EOF
end_expect
EOF
else
if [ $nic = "niu" ]; then
cat >>$installserver <<EOF
set serverip0 [lindex \$argv 5]
set clientip0 [lindex \$argv 6]
set serverip1 [lindex \$argv 7]
set clientip1 [lindex \$argv 8]
end_expect
EOF
else
cat >>$installserver <<EOF
set serverip [lindex \$argv 5]
set clientip [lindex \$argv 6]
end_expect
EOF
fi
fi
cat >>$installfile <<EOF
#set prompt for guest console
set_prompt GUEST '# '
#set prompt for SAM
set_prompt SAM 'stop: |sam>>> '
#set error patterns
error GUEST "\[Ee]rror|ERR|\[Pp]anic"
EOF
case $nic in
ce)
echo 'send_wait SAM "simce connect $switchmachine/$serverport"' >>$installfile
;;
ge)
echo 'send_wait SAM "simge connect $switchmachine/$serverport"' >>$installfile
;;
niu)
echo 'send_wait SAM "niu 0 connect $switchmachine/$serverport"' >>$installfile
echo 'send_wait SAM "niu 1 connect $switchmachine/$serverport"' >>$installfile
;;
*)
usage
exit 2
;;
esac
done
#generate the remaining part for clientdump.ver
cat >>$installclientdump <<EOF
send SAM "run"
wait SAM 'run: '
#sleep for a while to wait GUEST.
expect
sleep 5
end_expect
EOF
if [ $nic = "niu" ]; then
cat >>$installclientdump <<EOF
#execute commands.
send_wait GUEST "/ll/cwd/sam.client \$clientip0 nxge0"
send_wait GUEST "/ll/cwd/sam.client \$clientip1 nxge1"
EOF
else
cat >>$installclientdump <<EOF
#execute commands.
send_wait GUEST "/ll/cwd/sam.client \$clientip"
EOF
fi
cat >>$installclientdump <<EOF
send_wait SAM "stop"
send_wait SAM "dump client.dump"
send_fini SAM "quit"
EOF
#generate the remaining part for client.ver
cat >>$installclient <<EOF
#execute commands.
send_wait SAM "stepi 900000000000"
send_fini SAM "quit"
EOF
#generate the remaining part for server.ver
cat >>$installserver <<EOF
#execute commands.
send SAM "run"
wait SAM 'run: '
#sleep for a while to wait GUEST.
expect
sleep 5
end_expect
EOF
if [ $nic = "niu" ]; then
cat >>$installserver <<EOF
send_wait GUEST "/ll/cwd/sam.server -s \$serverip0 -c \$clientip1 -i nxge0"
send_wait GUEST "/ll/cwd/sam.server -s \$serverip1 -c \$clientip0 -i nxge1"
EOF
else
cat >>$installserver <<EOF
send_wait GUEST "/ll/cwd/sam.server -s \$serverip -c \$clientip"
EOF
fi
cat >>$installserver <<EOF
send_fini SAM "quit"
EOF