]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/testsuite/start-server.sh
Two new scripts: test-loop.sh and wait-tests.sh
[ngircd-alex.git] / src / testsuite / start-server.sh
index 8b1550395b95839f4a6541efd57ccb81d88ce39e..dd59719c29d862e2405d530c230779670b1cda88 100755 (executable)
@@ -1,22 +1,38 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: start-server.sh,v 1.5 2002/09/16 09:53:16 alex Exp $
+# $Id: start-server.sh,v 1.12 2004/09/04 13:58:31 alex Exp $
+
+[ -z "$srcdir" ] && srcdir=`dirname $0`
 
 echo "      starting server ..."
 
-rm -rf logs
+# remove old logfiles
+rm -rf logs *.log
+
+# check weather getpid.sh returns valid PIDs. If not, don't start up the
+# test-server, because we won't be able to kill it at the end of the test.
+./getpid.sh sh > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+  echo "      error: getpid.sh FAILED!"
+  exit 1
+fi
 
+# check if there is a test-server already running
+./getpid.sh T-ngircd > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+  echo "      error: test-server already running!"
+  exit 1
+fi
+
+# generate MOTD for test-server
 echo "This is an ngIRCd Test Server" > ngircd-test.motd
 
-./ngircd-TEST -np -f ${srcdir}/ngircd-test.conf > ngircd-test.log 2>&1 &
+# starting up test-server ...
+./T-ngircd -np -f ${srcdir}/ngircd-test.conf $* > ngircd-test.log 2>&1 &
 sleep 1
 
-PS_FLAGS=a; PS_PIDCOL=1
-ps a > /dev/null 2>&1
-if [ $? -ne 0 ]; then PS_FLAGS=-f; PS_PIDCOL=2; fi
-
-ps $PS_FLAGS > procs.tmp
-pid=`cat procs.tmp | grep ngircd-TEST | awk "{ print \\\$$PS_PIDCOL }"`
-kill -0 $pid > /dev/null 2>&1
+# validate running test-server
+pid=`./getpid.sh T-ngircd`
+[ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1 || exit 1
 
 # -eof-