#!/bin/ksh
#
#pragma ident "@(#)testio3.tst	1.0      03/11/12 SMI"
# 
# Copyright 2004 by Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#
#
# Original Author: Erica Zhang
#

# variables
hctsdir=SUNWhcts			# base directory
#hname=$1			# test system
testcmd=tests/ser/txrx.stf	# serial IO test
prgdir=prgs			# program directory
dls=				# data list
rhost=$1				
inst=1
# functions

# do function
go_fun()
{
	$prgdir/funcs "$*" 2>&1
}	

### MAIN ###

# change to base directory
cd `dirname $0`
while [ `basename $PWD` != $hctsdir ]
do
	cd ..
done

# set remote hostname name
rhost=`tail -1 /tmp/rhnames`
if [ -z "$rhost" ]
then
	rhost=`tail -1 /tmp/ppp_rhname`
	if [ -n "$rhost" ]
	then
		dev=`tail -1 /tmp/devlist3.$rhost | sed -e 's/*/\//g'`
		localdev=`echo $dev | cut -f1 -d .`
		remotedev=`echo $dev | cut -f2 -d .`
	else
		dls="!ERROR: No ppp client found"
	fi
		
else
	dev=`tail -1 /tmp/devlist2.$rhost | sed -e 's/*/\//g'`
	localdev=`echo $dev | cut -f1 -d .`
	remotedev=`echo $dev | cut -f2 -d .`
fi


# SERIO
if [ -z "$dls" ]
then
	echo "h:<HR><B><U>Serial IO driver test - txrx</U></B>:"		
	echo "X:4:$testcmd"    
	 
	echo "T:Enter Remote Hostname:$rhost"
	echo "x:5:"
	
	echo "T:Enter local serial port used:$localdev"
	echo "x:6:"

	echo "T:Enter remote serial port used:$remotedev"
	echo "x:7:"
	
	echo "T:Enter baudrate:38400"
	echo "x:8:"

	go_fun runt 1 0 1 $inst
else
	echo "$dls"
	exit 1
fi

