summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-12-02 10:41:48 +0100
committerMartin Pitt <martin.pitt@ubuntu.com>2016-12-02 10:44:06 +0100
commitf64106284d2ac0d522058ab6aee1b796bde8b0d2 (patch)
treedb47371b518411296d0df7dd803b866a49351745
parentf99ca608e0d9911fae49f2fdeddb00fa78a5a382 (diff)
test_polkitd.py: Fix waiting for mock polkit to start
In the common case when we got a DBusException we previously skipped the time.sleep() and thus were just racing through the retry loop without actually giving the child process any time to start up. Also raise a proper exception on timeout instead of os.abort(). The latter did not flush stderr fast enough to actually see the failure message, and as this happens in the parent pid we actually can raise an exception meaningfully. LP: #1585382
-rwxr-xr-xsrc/tests/test_polkitd.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tests/test_polkitd.py b/src/tests/test_polkitd.py
index bd313bd..3274ee3 100755
--- a/src/tests/test_polkitd.py
+++ b/src/tests/test_polkitd.py
@@ -16,7 +16,6 @@ This also provides some convenience API for launching the daemon and for
writing unittest test cases involving polkit operations.
'''
-import sys
import os
import argparse
import unittest
@@ -174,14 +173,13 @@ def spawn(allowed_actions, on_bus=None):
p = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'),
'org.freedesktop.DBus').GetConnectionUnixProcessID(
bus.get_name_owner('org.freedesktop.PolicyKit1'))
+ if p == pid:
+ break
except dbus.exceptions.DBusException:
- continue
- if p == pid:
- break
+ pass
time.sleep(0.1)
else:
- sys.stderr.write('test polkitd failed to start up\n')
- os.abort()
+ raise SystemError('test polkitd failed to start up')
return pid