diff options
author | Simon McVittie <smcv@collabora.com> | 2018-05-11 18:36:47 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2018-06-21 17:43:46 +0100 |
commit | d26639ecc2c7ed9355277b0ff0db9d8a39c081ca (patch) | |
tree | 87b5cb4ca13faffae5e1f774f7edf2c9f7d41e2b /test/containers.c | |
parent | eaaa2b67e487f76f266508a6064e0cebf6c90214 (diff) | |
download | dbus-d26639ecc2c7ed9355277b0ff0db9d8a39c081ca.tar.gz |
containers test: Factor out disconnecting the unconfined manager
As this test's coverage expands, this function will have to do more
(clear up name watches, filters, etc.) so it'll be helpful to keep it
all in one place.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105656
Diffstat (limited to 'test/containers.c')
-rw-r--r-- | test/containers.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/test/containers.c b/test/containers.c index 18c2f241..b226189f 100644 --- a/test/containers.c +++ b/test/containers.c @@ -1,6 +1,6 @@ /* Integration tests for restricted sockets for containers * - * Copyright © 2017 Collabora Ltd. + * Copyright © 2017-2018 Collabora Ltd. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files @@ -156,6 +156,24 @@ instance_removed_cb (GDBusConnection *observer, } static void +fixture_disconnect_unconfined (Fixture *f) +{ + if (f->unconfined_conn != NULL) + { + GError *error = NULL; + + g_dbus_connection_close_sync (f->unconfined_conn, NULL, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED)) + g_clear_error (&error); + else + g_assert_no_error (error); + } + + g_clear_object (&f->unconfined_conn); +} + +static void setup (Fixture *f, gconstpointer context) { @@ -851,8 +869,7 @@ test_stop_server (Fixture *f, NULL, name_gone_set_boolean_cb, &gone, NULL); - g_dbus_connection_close_sync (f->unconfined_conn, NULL, &f->error); - g_assert_no_error (f->error); + fixture_disconnect_unconfined (f); g_test_message ("Waiting for container manager bus name to disappear..."); @@ -1599,19 +1616,7 @@ teardown (Fixture *f, dbus_clear_connection (&f->libdbus_observer); - if (f->unconfined_conn != NULL) - { - GError *error = NULL; - - g_dbus_connection_close_sync (f->unconfined_conn, NULL, &error); - - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED)) - g_clear_error (&error); - else - g_assert_no_error (error); - } - - g_clear_object (&f->unconfined_conn); + fixture_disconnect_unconfined (f); if (f->confined_conn != NULL) { |