about summary refs log tree commit diff
path: root/src/devices/tests/test-acd.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2019-04-21 21:09:51 +0200
committerMichael Biebl <biebl@debian.org>2019-04-21 21:09:51 +0200
commit85563b7fc7ec2cd21e38debb9b28db342e2e8e7c (patch)
treecce7b0b02d28fae2df9fdf2c1804cacd1500f2d7 /src/devices/tests/test-acd.c
parent9a6dcbf895f9da01768e64b73cec88c16157d91e (diff)
New upstream version 1.18.0 upstream/1.18.0
Diffstat (limited to 'src/devices/tests/test-acd.c')
-rw-r--r--src/devices/tests/test-acd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/devices/tests/test-acd.c b/src/devices/tests/test-acd.c
index aff71825..8b52ee2c 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;
@@ -120,6 +120,7 @@ test_acd_common (test_fixture *fixture, TestInfo *info)
 		.probe_terminated_callback = acd_manager_probe_terminated,
 		.user_data_destroy         = (GDestroyNotify) g_main_loop_unref,
 	};
+	int r;
 
 	if (_skip_acd_test ())
 		return;
@@ -131,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,
@@ -148,9 +151,10 @@ again:
 		                        24, 0, 3600, 1800, 0, NULL);
 	}
 
-	g_assert (nm_acd_manager_start_probe (manager, wait_time));
+	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;
@@ -164,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;
 		}
 
@@ -172,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
@@ -199,8 +200,9 @@ 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;
+	int r;
 
 	if (_skip_acd_test ())
 		return;
@@ -216,11 +218,9 @@ test_acd_announce (test_fixture *fixture, gconstpointer user_data)
 	g_assert (nm_acd_manager_add_address (manager, ADDR2));
 
 	loop = g_main_loop_new (NULL, FALSE);
-	nm_acd_manager_announce_addresses (manager);
+	r = nm_acd_manager_announce_addresses (manager);
+	g_assert_cmpint (r, ==, 0);
 	g_assert (!nmtst_main_loop_run (loop, 200));
-	g_main_loop_unref (loop);
-
-	nm_acd_manager_free (manager);
 }
 
 static void