D-Bus testing: catch server startup failure

When starting the server fails, an exception gets thrown when
trying to determine its pid. This used to abort the whole
test script without recording much information. In particular
the server's output was not included.

Now the exception is caught, recorded as error and testing continues
with the next test.

This did not fix the root cause (a stuck process occupied the
D-Bus name) but at least it helped to identify the problem.
This commit is contained in:
Patrick Ohly 2013-03-04 07:23:42 -08:00
parent e8f7753573
commit f5286a09fa
1 changed files with 9 additions and 3 deletions

View File

@ -564,7 +564,13 @@ class DBusUtil(Timeout):
# pserver.pid is not necessarily the pid of syncevo-dbus-server.
# It might be the child of the pserver process.
self.pserverpid = self.serverPid()
try:
self.pserverpid = self.serverPid()
self.running = True
except:
result.errors.append((self,
"server startup failed: %s\nchildren: %s" % (traceback.format_exc(), self.getChildren())))
self.running = False
numerrors = len(result.errors)
numfailures = len(result.failures)
@ -587,8 +593,8 @@ class DBusUtil(Timeout):
else:
logging.printf('killing test disabled')
try:
self.running = True
unittest.TestCase.run(self, result)
if self.running:
unittest.TestCase.run(self, result)
except KeyboardInterrupt, ex:
# somehow this happens when timedout() above raises the exception
# while inside glib main loop