#!/bin/sh
#
# Copyright (c) 2001-2002 by Leni Mayo
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License, version 2, as
#	published by the Free Software Foundation.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
if [ "$srcdir" != "" ]; then
	srcdir=$srcdir"/"
else
	srcdir="./"
fi

# Test the locally built versions, in preference to the installed ones.
# Also, there might not be anything installed as yet (eg. during "make check")
export PATH=../src:../scripts:$PATH

# Source some functions
. $srcdir"testfunctions"

echo -n "Test starting and stopping services directly ... "
directory=$srcdir"1"

startServer

# always stop the server, no matter what
trap "serelc --control stop > /dev/null 2>&1" EXIT

for i in "$directory"/*; do
	[ ! -d $i ] && $i start &
done

wait

testStatus $directory "eStateIn"

for i in $directory/*; do
	[ ! -d $i ] && $i stop &
done

wait

testStatus $directory "service unknown"

serelc --control stop

success
