]> arthur.barton.de Git - ngircd-alex.git/blob - src/testsuite/start-server.sh
ngIRCd Release 27
[ngircd-alex.git] / src / testsuite / start-server.sh
1 #!/bin/sh
2 # ngIRCd Test Suite
3
4 [ -z "$srcdir" ] && srcdir=`dirname "$0"`
5 set -u
6
7 # read in functions
8 . "${srcdir}/functions.inc"
9
10 if [ -n "$1" ]; then
11         id="$1"; shift
12 else
13         id="1"
14 fi
15
16 echo_n "starting server ${id} ..."
17
18 # remove old logfiles, if this is the first server (ID 1)
19 [ "$id" = "1" ] && rm -rf logs *.log
20
21 # check weather getpid.sh returns valid PIDs. If not, don't start up the
22 # test-server, because we won't be able to kill it at the end of the test.
23 ./getpid.sh sh >/dev/null
24 if [ $? -ne 0 ]; then
25         echo " getpid.sh failed!"
26         exit 1
27 fi
28
29 # check if there is a test-server already running
30 ./getpid.sh T-ngircd${id} >/dev/null 2>&1
31 if [ $? -eq 0 ]; then
32         echo " failure: test-server ${id} already running!"
33         exit 1
34 fi
35
36 # generate MOTD for test-server
37 echo "This is an ngIRCd Test Server" >ngircd-test${id}.motd
38
39 # glibc memory checking, see malloc(3)
40 MALLOC_CHECK_=3
41 export MALLOC_CHECK_
42
43 # starting up test-server ...
44 ./T-ngircd${id} -n -f "${srcdir}/ngircd-test${id}.conf" "$@" \
45  >ngircd-test${id}.log 2>&1 &
46 sleep 1
47
48 # validate running test-server
49 r=1
50 pid=`./getpid.sh T-ngircd${id}`
51 [ -n "$pid" ] && kill -0 $pid >/dev/null 2>&1; r=$?
52 [ $r -eq 0 ] && echo " ok." || echo " failure!"
53 exit $r