#!/bin/sh

# $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/laos-drot/test/LaosDrotServiceWorkerTest.sh 14693 2017-09-15 16:07:45Z briegel $

export INSROOT_ETC_PATH=../etc/

if [ "x$srcdir" = "x" ]; 
then
    srcdir="."
fi

if [ "x$NICE_TYPE_PATH" = "x" ]; 
then
    NICE_TYPE_PATH="."
fi

#LOGLEVEL=ERROR
 LOGLEVEL=DEBUG

LD_LIBRARY_PATH=`cd $SHARKNIR_DROT_LIB_PATH && pwd`:`cd $INTERFACE_DROT_LIB_PATH && pwd`:$LD_LIBRARY_PATH

echo "start IIF simulator"
LbtoIIFSimulator --CONFIG=lbto.iifSimulator-svr.cfg \
                 --LOGGER.LEVEL=$LOGLEVEL &
                                          
LbcsIIFSimulator_pid=$!
sleep 5
echo "IIF simulator is running"
#netstat -lntp

echo "start IIF server"
basdard --CONFIG=lbcs.iifDummyLocalhost-svr.cfg \
        --LOGGER.LEVEL:LogLevel=$LOGLEVEL &
LbcsIIFService_pid=$!
sleep 5
echo "IIF server is running"
#netstat -lntp                                         

echo "run test"
./SharknirDrotServiceWorkerTest --CONFIG:Endpoint=[ALIAS=drot] \
                            --LOGGER.LEVEL=$LOGLEVEL \
                            --log_level=test_suite

CLIENT_EXIT_CODE=$?

kill -TERM $LbcsIIFService_pid
kill -TERM $LbcsIIFSimulator_pid
                            
exit $CLIENT_EXIT_CODE
