#!/bin/ksh

#
# remove different echo command behaviour on different OS
#
if test "`echo -e xxx`" = "xxx"
then
    echo="echo -e"
else
    echo=echo
fi

if [ $# = 0 ]
then
	$echo "\nusage:  runtest ds_system\n"
	$echo "ds_system can be solaris, suse64, hpux ou nt"
	exit 1
fi

#
# test host
#
SOL_HOST=corvus
SUSE_HOST=amber12.esrf.fr
HP_HOST=libra
NT_HOST=libra

HOST=`hostname`
SERV_NAME=devTest


case $1 in
hpux )
	if [ $HOST != $HP_HOST ]
	then
		$echo "For hp, test should run on "$HP_HOST
		exit 1
	fi
	BASE_DIR=/segfs/tango/tools/test_system/ref/device/bin/hpux10.2
	DIR=hpux10.2
	;;
#
solaris )
	if [ $HOST != $SOL_HOST ]
	then
		$echo "For solaris, test should run on "$SOL_HOST
		exit 1
	fi
	BASE_DIR=/segfs/tango/tools/test_system/ref/device/bin/solaris
	DIR=solaris
	;;
#
suse64 )
	if [ $HOST != $SUSE_HOST ]
	then
		$echo "For suse64, test should run on "$SUSE_HOST
		exit 1
	fi
	BASE_DIR=/segfs/tango/tools/test_system/ref/device/bin/suse64
	DIR=suse64
	;;
#
nt )
	if [ $HOST != $NT_HOST ]
	then
		$echo "For nt, test should run on "$NT_HOST
		exit 1
	fi
	BASE_DIR=/segfs/tango/tools/test_system/ref/device/bin/hpux10.2
	DIR=nt
	;;
#
* )
	$echo "\nunknown system"
	exit 1
	;;
esac

#
# First, test device server startup sequence
#

./Start $1
if test $? -ne 0
then
	exit 1
fi

#
# Start the test server
#

sleep 3
SERV_PATH=$BASE_DIR/$SERV_NAME
$SERV_PATH api >/dev/null 2>&1 &
sleep 3

#
# Then, start features test
#

./Tango_test $1

#

