chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Include sys/time.h in a few places, necessary for older libc versions.
[disorder]
/
tests
/
dtest.py
diff --git
a/tests/dtest.py
b/tests/dtest.py
index 38eadf8e3f4a2bff3bd7f76c9d601f2598ec5e2e..8a4644a128e2efc94887ab6d72a9749fdc7e66c5 100644
(file)
--- a/
tests/dtest.py
+++ b/
tests/dtest.py
@@
-1,7
+1,7
@@
#-*-python-*-
#
# This file is part of DisOrder.
#-*-python-*-
#
# This file is part of DisOrder.
-# Copyright (C) 2007
, 2008
Richard Kettlewell
+# Copyright (C) 2007
-2009
Richard Kettlewell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@
-19,7
+19,7
@@
"""Utility module used by tests"""
"""Utility module used by tests"""
-import os,os.path,subprocess,sys,re,time,unicodedata,random,socket
+import os,os.path,subprocess,sys,re,time,unicodedata,random,socket
,traceback
def fatal(s):
"""Write an error message and exit"""
def fatal(s):
"""Write an error message and exit"""
@@
-202,10
+202,10
@@
def common_setup():
os.mkdir(testroot)
# Choose a port
global port
os.mkdir(testroot)
# Choose a port
global port
- port = random.randint(49152, 6553
5
)
+ port = random.randint(49152, 6553
0
)
while not bindable(port + 1):
print "port %d is not bindable, trying another" % (port + 1)
while not bindable(port + 1):
print "port %d is not bindable, trying another" % (port + 1)
- port = random.randint(49152, 6553
5
)
+ port = random.randint(49152, 6553
0
)
# Log anything sent to that port
packetlog = "%s/packetlog" % testroot
subprocess.Popen(["disorder-udplog",
# Log anything sent to that port
packetlog = "%s/packetlog" % testroot
subprocess.Popen(["disorder-udplog",
@@
-287,10
+287,10
@@
Stop the daemon if it has not stopped already"""
rc = daemon.poll()
if rc == None:
print " stopping daemon"
rc = daemon.poll()
if rc == None:
print " stopping daemon"
-
disorder.client().shutdown(
)
+
os.kill(daemon.pid, 15
)
print " waiting for daemon"
rc = daemon.wait()
print " waiting for daemon"
rc = daemon.wait()
- print " daemon has stopped
"
+ print " daemon has stopped
(rc=%d)" % rc
else:
print " daemon already stopped"
daemon = None
else:
print " daemon already stopped"
daemon = None
@@
-302,7
+302,7
@@
def run(module=None, report=True):
Run the test in MODULE. This can be a string (in which case the module
will be imported) or a module object."""
Run the test in MODULE. This can be a string (in which case the module
will be imported) or a module object."""
- global tests
+ global tests
, failures
tests += 1
# Locate the test module
if module is None:
tests += 1
# Locate the test module
if module is None:
@@
-333,8
+333,10
@@
def run(module=None, report=True):
stdtracks()
try:
module.test()
stdtracks()
try:
module.test()
- finally:
- stop_daemon()
+ except:
+ traceback.print_exc(None, sys.stderr)
+ failures += 1
+ stop_daemon()
if report:
if failures:
print " FAILED"
if report:
if failures:
print " FAILED"