about summary refs log tree commit diff
path: root/src/devices/tests
diff options
context:
space:
mode:
authorJeremy Bicha <jbicha@ubuntu.com>2018-05-11 19:02:28 -0400
committerJeremy Bicha <jbicha@ubuntu.com>2018-05-11 19:02:28 -0400
commitee7f1100500dc431a6e8bf1e6efb2d41445fd28f (patch)
tree3eef32d0e8412f4d2126a9be5820c85d387e313c /src/devices/tests
parent01bf2f7e474588126875a29125a1e248d7ae18db (diff)
parent680d3db45106e7a18665a366e1b57e58cef61506 (diff)
Merge tag 'debian/1.10.8-1' into cosmic
network-manager Debian release 1.10.8-1
Diffstat (limited to 'src/devices/tests')
-rw-r--r--src/devices/tests/test-arping.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/devices/tests/test-arping.c b/src/devices/tests/test-arping.c
index bcbc1140..f0537545 100644
--- a/src/devices/tests/test-arping.c
+++ b/src/devices/tests/test-arping.c
@@ -65,12 +65,22 @@ test_arping_common (test_fixture *fixture, TestInfo *info)
 	gs_unref_object NMArpingManager *manager = NULL;
 	GMainLoop *loop;
 	int i;
+	const guint WAIT_TIME_OPTIMISTIC = 50;
+	guint wait_time;
+	gulong signal_id;
 
 	if (!nm_utils_find_helper ("arping", NULL, NULL)) {
 		g_test_skip ("arping binary is missing");
 		return;
 	}
 
+	/* first, try with a short waittime. We hope that this is long enough
+	 * to successfully complete the test. Only if that's not the case, we
+	 * assume the computer is currently busy (high load) and we retry with
+	 * a longer timeout. */
+	wait_time = WAIT_TIME_OPTIMISTIC;
+again:
+
 	manager = nm_arping_manager_new (fixture->ifindex0);
 	g_assert (manager != NULL);
 
@@ -83,18 +93,32 @@ test_arping_common (test_fixture *fixture, TestInfo *info)
 	}
 
 	loop = g_main_loop_new (NULL, FALSE);
-	g_signal_connect (manager, NM_ARPING_MANAGER_PROBE_TERMINATED,
-	                  G_CALLBACK (arping_manager_probe_terminated), loop);
-	g_assert (nm_arping_manager_start_probe (manager, 250, NULL));
+	signal_id = g_signal_connect (manager, NM_ARPING_MANAGER_PROBE_TERMINATED,
+	                              G_CALLBACK (arping_manager_probe_terminated), loop);
+	g_assert (nm_arping_manager_start_probe (manager, wait_time, NULL));
 	g_assert (nmtst_main_loop_run (loop, 2000));
+	g_signal_handler_disconnect (manager, signal_id);
+	g_main_loop_unref (loop);
 
 	for (i = 0; info->addresses[i]; i++) {
-		g_assert_cmpint (nm_arping_manager_check_address (manager, info->addresses[i]),
-		                 ==,
-		                 info->expected_result[i]);
+		gboolean val;
+
+		val = nm_arping_manager_check_address (manager, info->addresses[i]);
+		if (val == info->expected_result[i])
+			continue;
+
+		if (wait_time == WAIT_TIME_OPTIMISTIC) {
+			/* probably we just had a glitch and the system took longer than
+			 * expected. Re-verify with a large timeout this time. */
+			wait_time = 1000;
+			g_clear_object (&manager);
+			goto again;
+		}
+
+		g_error ("expected check for address #%d (%s) to %s, but it didn't",
+		         i, nm_utils_inet4_ntop (info->addresses[i], NULL),
+		         info->expected_result[i] ? "detect no duplicated" : "detect a duplicate");
 	}
-
-	g_main_loop_unref (loop);
 }
 
 static void