#!/bin/csh

echo "------------------------------------"
echo "---------- AUTOTEST 001 ------------"
echo "------------------------------------"
echo " - Tests Multiple clients / multiple server connections"
echo " - Tests correctness of transmitted data stream for 1000 symbols, 100Hz, same phase (800000 values)"
echo " - Tests server information string value"
echo " - Tests total list of symbol names managed by server"


setenv STRACE_DEBUG 2

#starts 3 servers (1 useful, plus 2 dummies)

#useful : will talk to clients 1,2 and 3
tsp_stub_server --tsp-server-number 0  > /dev/null &

#dummy 1
tsp_stub_server --tsp-server-number 1  > /dev/null &

#dummy 2
tsp_stub_server --tsp-server-number 2  > /dev/null &
sleep 1

#start 2 clients (1 useful, plus 2 dummies)


#dummy 1 : will connect to servers 1,2,3 et talks to 1
tsp_stdout_client localhost 10 > /dev/null &

#dummy 2 : will connect to servers 1,2,3 et talks to 1
tsp_stdout_client localhost 10 > /dev/null &

#useful : will connect to servers 1,2,3 et talks to 1
tsp_stdout_client localhost 1 test

# The lastest client returns the number of opened providers
set NB_OPENED=$status

#kill our army of dummies
custom_killall tsp_stub_server
custom_killall tsp_stdout_client

#we are expecting 3 opened providers by client1
if ( "$NB_OPENED" == "3") then
    echo "TEST||STAGE 001 | STEP 007 : PASSED"
    echo "TEST||++++ STAGE 001 : PASSED ++++"
    set RET=0
else
    echo "TEST||STAGE 001 | STEP 007 : FAILED"
    echo "TEST||@@@@ STAGE 001 : FAILED @@@@"
    echo "If script doesn't find tsp_xxx_server of client"
    echo "please add $DEVBASE/exec/DEV/bin.xxx in your path\n"
    set RET=1
endif


echo "------------------------------------"
echo "-------- END AUTOTEST 001 ----------"
echo "------------------------------------"
exit $RET










