Commit Diff


commit - 90ab7c7c48da57bcd7890b5809e99aa4b685c72a
commit + efedfe12ff27a450e85ff0b13c028c2dad1a72e4
blob - 271aeb292ec12e646519f7bc2fd040c6cfffa81b
blob + c5eccc3c5760edebb836b5ba331898558ca9c74d
--- src/testsuite/Makefile.am
+++ src/testsuite/Makefile.am
@@ -9,7 +9,7 @@
 # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #
-# $Id: Makefile.am,v 1.3 2002/09/12 02:26:17 alex Exp $
+# $Id: Makefile.am,v 1.4 2002/09/20 14:46:55 alex Exp $
 #
 
 AUTOMAKE_OPTIONS = ../portab/ansi2knr
@@ -17,6 +17,7 @@ AUTOMAKE_OPTIONS = ../portab/ansi2knr
 INCLUDES = -I$(srcdir)/../portab
 
 EXTRA_DIST = \
+	getpid.sh \
 	start-server.sh stop-server.sh tests.sh stress-server.sh \
 	connect-test.e channel-test.e mode-test.e \
 	stress-A.e stress-B.e check-idle.e \
blob - /dev/null
blob + 973c67f3912210defa40a1129994246332347dcd (mode 755)
--- /dev/null
+++ src/testsuite/getpid.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# ngIRCd Test Suite
+# $Id: getpid.sh,v 1.1 2002/09/20 14:46:55 alex Exp $
+
+# wurde ein Name uebergeben?
+[ $# -ne 1 ] && exit 1
+
+# Flags fuer "ps" ermitteln
+if [ `uname` = "FreeBSD" ]; then
+  PS_FLAGS=-a; PS_PIDCOL=1
+else
+  PS_FLAGS=-f; PS_PIDCOL=2
+  ps $PS_FLAGS > /dev/null 2>&1
+  if [ $? -ne 0 ]; then PS_FLAGS=a; PS_PIDCOL=1; fi
+fi
+
+# PID ermitteln
+ps $PS_FLAGS > procs.tmp
+pid=`cat procs.tmp | grep "$1" | awk "{ print \\\$$PS_PIDCOL }" | sort -n | head -n 1`
+
+# ermittelte PID validieren
+[ "$pid" -gt 1 ] > /dev/null 2>&1
+[ $? -ne 0 ] && exit 1
+
+echo $pid
+exit 0
+
+# -eof-
blob - 8eef8b47d2390a9d2bb0b27523d56b5fb41f86c8
blob + cdb802f4107a1d153e9d2aeb7a02b027ef3a9760
--- src/testsuite/start-server.sh
+++ src/testsuite/start-server.sh
@@ -1,22 +1,30 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: start-server.sh,v 1.7 2002/09/20 13:57:01 alex Exp $
+# $Id: start-server.sh,v 1.8 2002/09/20 14:46:55 alex Exp $
 
 echo "      starting server ..."
 
-rm -rf logs
+# alte Logfiles loeschen
+rm -rf logs *.log
 
+# pruefen, ob getpid.sh gueltige PID's liefert. Wenn dem nicht so ist,
+# wird kein ngIRCd gestartet, da dieser ansonsten nicht mehr am Ende
+# des Testlaufs beendet werden koennte!
+./getpid.sh make > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+  echo "      error: getpid.sh FAILED!"
+  exit 1
+fi
+
+# MOTD fuer Test-Server erzeugen
 echo "This is an ngIRCd Test Server" > ngircd-test.motd
 
+# Test-Server starten ...
 ./ngircd-TEST -np -f ${srcdir}/ngircd-test.conf > ngircd-test.log 2>&1 &
 sleep 1
 
-PS_FLAGS=-f; PS_PIDCOL=2
-ps $PS_FLAGS > /dev/null 2>&1
-if [ $? -ne 0 ]; then PS_FLAGS=a; PS_PIDCOL=1; fi
-
-ps $PS_FLAGS > procs.tmp
-pid=`cat procs.tmp | grep ngircd-TEST | awk "{ print \\\$$PS_PIDCOL }"`
+# validieren, dass Server laeuft
+pid=`./getpid.sh ngircd-TEST`
 [ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1 || exit 1
 
 # -eof-
blob - 0064baf2bf3662b0903f8356452347d327f009c4
blob + 3d1937045532b6f728aef3ab1b4bc6baab5b60e0
--- src/testsuite/stop-server.sh
+++ src/testsuite/stop-server.sh
@@ -1,15 +1,15 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: stop-server.sh,v 1.6 2002/09/20 13:57:01 alex Exp $
+# $Id: stop-server.sh,v 1.7 2002/09/20 14:46:55 alex Exp $
 
 echo "      stopping server ..."
 
-PS_FLAGS=-f; PS_PIDCOL=2
-ps $PS_FLAGS > /dev/null 2>&1
-if [ $? -ne 0 ]; then PS_FLAGS=a; PS_PIDCOL=1; fi
+# Test-Server stoppen ...
+pid=`./getpid.sh ngircd-TEST`
+[ -n "$pid" ] && kill $pid > /dev/null 2>&1 || exit 1
+sleep 1
 
-ps $PS_FLAGS > procs.tmp
-pid=`cat procs.tmp | grep ngircd-TEST | awk "{ print \\\$$PS_PIDCOL }"`
-[ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1 || exit 1
+# jetzt duerfte der Prozess nicht mehr laufen
+kill -0 $pid > /dev/null 2>&1 && exit 1 || exit 0
 
 # -eof-