# HG changeset patch # User Matt Mackall # Date 1226096933 21600 # Node ID 58fd3c718ca4f95678f3fd7f20107326defadccd # Parent e47dab64be8dfef7e158ea052a4f3a26efb32e0d tests: add killdaemons helper script diff -r e47dab64be8d -r 58fd3c718ca4 tests/killdaemons.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/killdaemons.py Fri Nov 07 16:28:53 2008 -0600 @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import os, sys, time, errno, signal + +# Kill off any leftover daemon processes +try: + fp = file(os.environ['DAEMON_PIDS']) + for line in fp: + try: + pid = int(line) + except ValueError: + continue + try: + os.kill(pid, 0) + os.kill(pid, signal.SIGTERM) + for i in range(10): + time.sleep(0.05) + os.kill(pid, 0) + os.kill(pid, signal.SIGKILL) + except OSError, err: + if err.errno != errno.ESRCH: + raise + fp.close() +except IOError: + pass diff -r e47dab64be8d -r 58fd3c718ca4 tests/test-archive --- a/tests/test-archive Fri Nov 07 16:28:52 2008 -0600 +++ b/tests/test-archive Fri Nov 07 16:28:53 2008 -0600 @@ -24,7 +24,7 @@ echo % $3 and $4 disallowed should both give 403 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1 - kill `cat hg.pid` + "$TESTDIR/killdaemons.py" cat errors.log cp .hg/hgrc-base .hg/hgrc } @@ -63,6 +63,8 @@ http_proxy= python getarchive.py "$TIP" zip > archive.zip unzip -t archive.zip | sed "s/$QTIP/TIP/" +"$TESTDIR/killdaemons.py" + hg archive -t tar test.tar tar tf test.tar diff -r e47dab64be8d -r 58fd3c718ca4 tests/test-fetch --- a/tests/test-fetch Fri Nov 07 16:28:52 2008 -0600 +++ b/tests/test-fetch Fri Nov 07 16:28:53 2008 -0600 @@ -37,6 +37,7 @@ hg --cwd c fetch -d '4 0' -m 'automated merge' ../a ls c +netstat -tnap 2>/dev/null | grep $HGPORT | grep LISTEN hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid cat a/hg.pid >> "$DAEMON_PIDS" @@ -169,4 +170,6 @@ hg -R n2 parents --template '{rev}\n' rm -fr n1 n2 +"$TESTDIR/killdaemons.py" + true