From 879c8ea79ec0bf5a23fa2f29b1e423625dcc3654 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 11 May 2018 18:38:07 +0100 Subject: [PATCH 16/39] containers test: Factor out fixture_disconnect_observer Signed-off-by: Simon McVittie --- test/containers.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/test/containers.c b/test/containers.c index b226189f..e745d6ea 100644 --- a/test/containers.c +++ b/test/containers.c @@ -173,6 +173,27 @@ fixture_disconnect_unconfined (Fixture *f) g_clear_object (&f->unconfined_conn); } +static void +fixture_disconnect_observer (Fixture *f) +{ + if (f->observer_conn != NULL) + { + GError *error = NULL; + + g_dbus_connection_signal_unsubscribe (f->observer_conn, + f->removed_sub); + + g_dbus_connection_close_sync (f->observer_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->observer_conn); +} + static void setup (Fixture *f, gconstpointer context) @@ -1590,22 +1611,8 @@ teardown (Fixture *f, { g_clear_object (&f->proxy); - if (f->observer_conn != NULL) - { - GError *error = NULL; - - g_dbus_connection_signal_unsubscribe (f->observer_conn, - f->removed_sub); - g_dbus_connection_close_sync (f->observer_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); - } - + fixture_disconnect_observer (f); g_clear_pointer (&f->containers_removed, g_hash_table_unref); - g_clear_object (&f->observer_conn); if (f->libdbus_observer != NULL) { -- 2.17.0