X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftestsuite%2Fstart-server.sh;h=90832a39f68913d757a46320bf96fd672446944b;hb=ff2a425ab899a782145186d4e9a829ea9950fb47;hp=8b1550395b95839f4a6541efd57ccb81d88ce39e;hpb=508fa48aa6342beb50e510285b683abe54e0fe92;p=ngircd-alex.git diff --git a/src/testsuite/start-server.sh b/src/testsuite/start-server.sh index 8b155039..90832a39 100755 --- a/src/testsuite/start-server.sh +++ b/src/testsuite/start-server.sh @@ -1,22 +1,50 @@ #!/bin/sh # ngIRCd Test Suite -# $Id: start-server.sh,v 1.5 2002/09/16 09:53:16 alex Exp $ -echo " starting server ..." +[ -z "$srcdir" ] && srcdir=`dirname $0` -rm -rf logs +# read in functions +. ${srcdir}/functions.inc -echo "This is an ngIRCd Test Server" > ngircd-test.motd +if [ -n "$1" ]; then + id="$1"; shift +else + id="1" +fi -./ngircd-TEST -np -f ${srcdir}/ngircd-test.conf > ngircd-test.log 2>&1 & +echo_n " starting server ${id} ..." + +# remove old logfiles, if this is the first server (ID 1) +[ "$id" = "1" ] && 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 " getpid.sh failed!" + exit 1 +fi + +# check if there is a test-server already running +./getpid.sh T-ngircd${id} >/dev/null 2>&1 +if [ $? -eq 0 ]; then + echo " failure: test-server ${id} already running!" + exit 1 +fi + +# generate MOTD for test-server +echo "This is an ngIRCd Test Server" > ngircd-test${id}.motd + +# starting up test-server ... +./T-ngircd${id} -n -f ${srcdir}/ngircd-test${id}.conf $* \ + >ngircd-test${id}.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 +# validate running test-server +pid=`./getpid.sh T-ngircd${id}` +[ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1; r=$? -ps $PS_FLAGS > procs.tmp -pid=`cat procs.tmp | grep ngircd-TEST | awk "{ print \\\$$PS_PIDCOL }"` -kill -0 $pid > /dev/null 2>&1 +[ $r -eq 0 ] && echo " ok." || echo " failure!" +exit $r # -eof-