diff options
author | Thomas Haller <thaller@redhat.com> | 2019-04-03 09:49:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-04-04 09:56:19 +0200 |
commit | 331073e03ca4b68726e86f496a4f94242ef173a2 (patch) | |
tree | 80012e320bf8eaa4d7a60f92774c70998d953e00 | |
parent | e90f4c31b0ed2605bcf8702c82f501040677892b (diff) | |
download | NetworkManager-331073e03ca4b68726e86f496a4f94242ef173a2.tar.gz |
acd/tests: use nm_auto cleanup attributes for mainloop and NMAcdManager
-rw-r--r-- | src/devices/tests/test-acd.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/devices/tests/test-acd.c b/src/devices/tests/test-acd.c index 0f56a0effc..735037ee1b 100644 --- a/src/devices/tests/test-acd.c +++ b/src/devices/tests/test-acd.c @@ -111,8 +111,8 @@ acd_manager_probe_terminated (NMAcdManager *acd_manager, gpointer user_data) static void test_acd_common (test_fixture *fixture, TestInfo *info) { - NMAcdManager *manager; - GMainLoop *loop; + nm_auto_free_acdmgr NMAcdManager *manager = NULL; + nm_auto_unref_gmainloop GMainLoop *loop = NULL; int i; const guint WAIT_TIME_OPTIMISTIC = 50; guint wait_time; @@ -132,8 +132,10 @@ test_acd_common (test_fixture *fixture, TestInfo *info) wait_time = WAIT_TIME_OPTIMISTIC; again: + nm_clear_pointer (&loop, g_main_loop_unref); loop = g_main_loop_new (NULL, FALSE); + nm_clear_pointer (&manager, nm_acd_manager_free); manager = nm_acd_manager_new (fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len, @@ -151,8 +153,8 @@ again: r = nm_acd_manager_start_probe (manager, wait_time); g_assert_cmpint (r, ==, 0); + g_assert (nmtst_main_loop_run (loop, 2000)); - g_main_loop_unref (loop); for (i = 0; info->addresses[i]; i++) { gboolean val; @@ -166,7 +168,6 @@ again: /* probably we just had a glitch and the system took longer than * expected. Re-verify with a large timeout this time. */ wait_time = 1000; - nm_clear_pointer (&manager, nm_acd_manager_free); goto again; } @@ -174,8 +175,6 @@ again: i, nm_utils_inet4_ntop (info->addresses[i], sbuf), info->expected_result[i] ? "detect no duplicated" : "detect a duplicate"); } - - nm_acd_manager_free (manager); } static void @@ -201,8 +200,8 @@ test_acd_probe_2 (test_fixture *fixture, gconstpointer user_data) static void test_acd_announce (test_fixture *fixture, gconstpointer user_data) { - NMAcdManager *manager; - GMainLoop *loop; + nm_auto_free_acdmgr NMAcdManager *manager = NULL; + nm_auto_unref_gmainloop GMainLoop *loop = NULL; if (_skip_acd_test ()) return; @@ -220,9 +219,6 @@ test_acd_announce (test_fixture *fixture, gconstpointer user_data) loop = g_main_loop_new (NULL, FALSE); nm_acd_manager_announce_addresses (manager); g_assert (!nmtst_main_loop_run (loop, 200)); - g_main_loop_unref (loop); - - nm_acd_manager_free (manager); } static void |