svn commit: samba r21554 - in branches/SAMBA_4_0/source/script/tests: .

abartlet at samba.org abartlet at samba.org
Tue Feb 27 02:59:23 GMT 2007


Author: abartlet
Date: 2007-02-27 02:59:22 +0000 (Tue, 27 Feb 2007)
New Revision: 21554

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21554

Log:
Use a snippet from tridge's junkcode to cause us to wait for smbd to
exit.

If we kill smbd right away, we can interrupt the gcov data file
writeout.  Instead, we now wait up to 20 seconds for the process to
exit, before sending it a kill -9.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/script/tests/selftest.sh
   branches/SAMBA_4_0/source/script/tests/test_functions.sh


Changeset:
Modified: branches/SAMBA_4_0/source/script/tests/selftest.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/selftest.sh	2007-02-27 02:19:16 UTC (rev 21553)
+++ branches/SAMBA_4_0/source/script/tests/selftest.sh	2007-02-27 02:59:22 UTC (rev 21554)
@@ -247,7 +247,11 @@
 ) 9>$SMBD_TEST_FIFO
 totalfailed=$?
 
-kill `cat $PIDDIR/smbd.pid`
+smbd_PID=`cat $PIDDIR/smbd.pid`
+waitforpid $smbd_PID 20 || {
+    echo "smbd process $1 took more than 20 seconds to exit, killing"
+    kill -9 $smbd_PID
+}
 
 if [ "$TEST_LDAP"x = "yesx" ]; then
     if test -z "$FEDORA_DS_PREFIX"; then

Modified: branches/SAMBA_4_0/source/script/tests/test_functions.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/test_functions.sh	2007-02-27 02:19:16 UTC (rev 21553)
+++ branches/SAMBA_4_0/source/script/tests/test_functions.sh	2007-02-27 02:59:22 UTC (rev 21554)
@@ -113,6 +113,22 @@
 	exit $failed
 }
 
+# wait for a pid with given timeout
+# returns 1 if it timed out, 0 if the process exited itself
+waitforpid() {
+    pid=$1
+    timeout=$2 # in seconds
+    _wcount=0
+    while kill -0 $pid 2> /dev/null; do
+	sleep 1;
+	_wcount=`expr $_wcount + 1`
+	if [ $_wcount -eq $timeout ]; then
+	    return "1";
+	fi
+    done
+    return "0";
+}
+
 if [ -z "$VALGRIND" ]; then
     MALLOC_CHECK_=2
     export MALLOC_CHECK_



More information about the samba-cvs mailing list