diff options
author | Dan Winship <danw@gnome.org> | 2014-07-31 14:00:22 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-01 12:12:42 -0400 |
commit | 08b91199fb95d9178feaeaa58381847332f22ad8 (patch) | |
tree | 9cc7c3ab8c111ad8d8f5662d1220c52c3b553922 /tools | |
parent | bd8a7f74b1f7d9b1712741797096bf97ef5df9aa (diff) | |
download | NetworkManager-08b91199fb95d9178feaeaa58381847332f22ad8.tar.gz |
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.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test-networkmanager-service.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 5f1f613766..437381eb06 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -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: |