diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test-ip4-config.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index d4d0c1bbf7..0d9c055b5f 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -75,6 +75,49 @@ 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); + + /* FIXME: this currently fails due to a bug in replace() */ + g_assert (!nm_ip4_config_equal (config1, config2)); +} + +static void test_subtract (void) { NMIP4Config *src, *dst; @@ -339,6 +382,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); |