summary refs log tree commit diff
path: root/src/tests
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2019-09-06 09:25:17 +0200
committerMichael Biebl <biebl@debian.org>2019-09-06 09:25:17 +0200
commit555dfa331e295a3a687a7cc6870e1349ffed8f26 (patch)
treeaebc4e1ffa38b05780f0c1fe39bf78ca63c979c6 /src/tests
parent5c79b900b59a5ad162ecc836e424468207ff031e (diff)
New upstream version 1.20.2 upstream/1.20.2
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test-core-with-expect.c5
-rw-r--r--src/tests/test-ip4-config.c42
2 files changed, 44 insertions, 3 deletions
diff --git a/src/tests/test-core-with-expect.c b/src/tests/test-core-with-expect.c
index d38025ec..2d111a41 100644
--- a/src/tests/test-core-with-expect.c
+++ b/src/tests/test-core-with-expect.c
@@ -118,13 +118,13 @@ test_nm_utils_kill_child_async_do (const char *name, pid_t pid, int sig, guint32
 	timeout_id = g_timeout_add_seconds (5, test_nm_utils_kill_child_async_fail_cb, &data);
 
 	data.loop = g_main_loop_new (NULL, FALSE);
-	g_main_run (data.loop);
+	g_main_loop_run (data.loop);
 
 	g_assert (data.called);
 	success = g_source_remove (timeout_id);
 	g_assert (success);
 
-	g_main_destroy (data.loop);
+	g_main_loop_unref (data.loop);
 }
 
 static void
@@ -578,4 +578,3 @@ main (int argc, char **argv)
 
 	return g_test_run ();
 }
-
diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c
index d4d0c1bb..5afd8670 100644
--- a/src/tests/test-ip4-config.c
+++ b/src/tests/test-ip4-config.c
@@ -75,6 +75,47 @@ build_test_config (void)
 }
 
 static void
+test_replace (void)
+{
+	gs_unref_object NMIP4Config *config1 = NULL;
+	gs_unref_object NMIP4Config *config2 = NULL;
+	NMPlatformIP4Address addr;
+	gboolean relevant_changes;
+
+	config1 = nmtst_ip4_config_new (1);
+
+	addr = *nmtst_platform_ip4_address ("172.16.0.1", NULL, 24);
+	addr.timestamp = 10;
+	addr.preferred = 3600;
+	addr.lifetime = 7200;
+	nm_ip4_config_add_address (config1, &addr);
+
+	addr = *nmtst_platform_ip4_address ("172.16.0.2", NULL, 24);
+	addr.timestamp = 10;
+	addr.preferred = 3600;
+	addr.lifetime = 7200;
+	nm_ip4_config_add_address (config1, &addr);
+
+	config2 = nmtst_ip4_config_new (1);
+
+	addr = *nmtst_platform_ip4_address ("192.168.1.1", NULL, 24);
+	addr.timestamp = 40;
+	addr.preferred = 60;
+	addr.lifetime = 120;
+	nm_ip4_config_add_address (config2, &addr);
+
+	addr = *nmtst_platform_ip4_address ("172.16.0.2", NULL, 24);
+	addr.timestamp = 40;
+	addr.preferred = 60;
+	addr.lifetime = 120;
+	nm_ip4_config_add_address (config2, &addr);
+
+	g_assert (nm_ip4_config_replace (config2, config1, &relevant_changes));
+	g_assert (relevant_changes);
+	g_assert (nm_ip4_config_equal (config1, config2));
+}
+
+static void
 test_subtract (void)
 {
 	NMIP4Config *src, *dst;
@@ -339,6 +380,7 @@ main (int argc, char **argv)
 {
 	nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT");
 
+	g_test_add_func ("/ip4-config/replace", test_replace);
 	g_test_add_func ("/ip4-config/subtract", test_subtract);
 	g_test_add_func ("/ip4-config/compare-with-source", test_compare_with_source);
 	g_test_add_func ("/ip4-config/add-address-with-source", test_add_address_with_source);