diff options
author | Dan Winship <danw@gnome.org> | 2014-07-31 14:00:22 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-01 09:18:19 -0400 |
commit | 5aabc204ca0584a21c5f95de941a04f26302fff1 (patch) | |
tree | 7c6994bed65ecb0046a1eca2003ac7a9f0ed6f00 /tools/test-networkmanager-service.py | |
parent | bc5f0e86f639afb3d8479bb81baea8ae30bb2cd0 (diff) | |
download | NetworkManager-danw/wip/libnm-nmobj.tar.gz |
libnm: make test-networkmanager-service.py automatically exit with its parentdanw/wip/libnm-nmobj
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.
Simplify things by opening a pipe between the test program and
test-networkmanager-service.py, and having it automatically exit if
that pipe closes (as it would if the test program exits, for any
reason).
Then that lets us drop the test_assert* macros and just use g_assert*
instead.
Diffstat (limited to 'tools/test-networkmanager-service.py')
-rwxr-xr-x | tools/test-networkmanager-service.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 5f1f613766..08a06f3f04 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,12 @@ 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 + if len(sys.argv) > 1 and sys.argv[1] == '--exit-with-parent': + # Watch stdin; if it closes, assume our parent has crashed, and exit + io = GLib.IOChannel.unix_new(0) + io.add_watch(GLib.IOCondition.IN | 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: |