#!/bin/sh

#Set up the test Environment for pad_tests

# Restart the VCOM software after reconfiguration

re_st_start()
{

vcom_stat 1
vcom_rst -f 1
vcom_vld /usr/src/b_vcom5.0/x25.lod34 1
/usr/src/b_vcom5.0/sbeux/x25utils/vcomdl/vcom_cfg 1
}

#
# Confiuration files for X25
#

echo "TYPE = X25
L3PLPMODE = DCE
LAPB_MODE = DCE
LAPB_PHY_IF = DCE
LAPB_MAXFRAME = 4096
LAPB_BAUD = 2000000
X25_VSN = 84
HTC = 255 " > /tmp/x25port.1A
    
echo "TYPE = X25
L3PLPMODE = DTE
LAPB_MODE = DTE
LAPB_PHY_IF = DTE
LAPB_MAXFRAME = 4096
LAPB_BAUD = 0
X25_VSN = 84
HTC=255 " > /tmp/x25port.1C


echo "
TYPE = WAN " > /tmp/x25port.1B

echo "
TYPE = WAN " > /tmp/x25port.1D

/usr/src/b_vcom5.0/sbeux/x25utils/xcf/xcf -b1 /tmp/x25port
rm /tmp/x25port.*

# Make a fresh start for the test
re_st_start

Num_cnct=15
TEST_NUM="1 2"
brd_num=1
subnet_id="c"
Pkt_num=1000
Pkt_sz=1020

#echo Num_cnct = $Num_cnct brd = $brd_num, subnet_id = $subnet_id
for Test_num in $TEST_NUM
do

(
xx=1
while : 
do
	if [ $xx -le $Num_cnct ]
	then
		echo "####### Starting the $xx x1 #######"
		./xtest1 -b$brd_num &
		xx=`expr $xx + 1`
	else
		break
	fi
done

xx=1
while :
do
	if [ $xx -lt $Num_cnct ]
	then
		echo "####### Starting the $xx x2 #######"
		if [ x$Test_num = x1 ]
		then
			./xtest2 -b$brd_num -s$subnet_id -t$Test_num -n$Pkt_num \
				-z$Pkt_sz &
		else
			./xtest2 -b$brd_num -s$subnet_id -t$Test_num &
		fi

		xx=`expr $xx + 1`
	else
		break
	fi
done
		echo "####### Starting the Last x2 #######"
		if [ x$Test_num = x1 ]
		then
			./xtest2 -b$brd_num -s$subnet_id -t$Test_num -n$Pkt_num \
				-z$Pkt_sz
		else
			./xtest2 -b$brd_num -s$subnet_id -t$Test_num
		fi

wait
) > x25_multi$Test_num.log 2>&1

done
