libnm-glib: make test-networkmanager-service.py automatically exit with its parent
test-nm-client.c and test-remote-settings-client.c were using their own assertion macros so they could kill the test service on assertion failure. Except that some new code didn't get the memo and used the g_assert* macros. Not to mention that sometimes the tests would crash outside of an assertion macro. We can make test-networkmanager-service.py notice that its parent has crashed by opening a pipe between them and taking advantage of the fact that the pipe will be automatically closed if the parent crashes. So then test-networkmanager-service.py just has to watch for that, and exit if the pipe closes. Then that lets us drop the test_assert* macros and just use g_assert* instead.
This commit is contained in:
@@ -858,6 +858,9 @@ class Settings(dbus.service.Object):
|
||||
|
||||
###################################################################
|
||||
|
||||
def stdin_cb(io, condition):
|
||||
mainloop.quit()
|
||||
|
||||
def quit_cb(user_data):
|
||||
mainloop.quit()
|
||||
|
||||
@@ -872,7 +875,11 @@ def main():
|
||||
if not bus.request_name("org.freedesktop.NetworkManager"):
|
||||
sys.exit(1)
|
||||
|
||||
# quit after inactivity to ensure we don't stick around if tests fail
|
||||
# Watch stdin; if it closes, assume our parent has crashed, and exit
|
||||
io = GLib.IOChannel.unix_new(0)
|
||||
io.add_watch(GLib.IOCondition.HUP, stdin_cb)
|
||||
|
||||
# also quit after inactivity to ensure we don't stick around if the above fails somehow
|
||||
GLib.timeout_add_seconds(20, quit_cb, None)
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user