mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-12 17:00:33 +01:00
core: add test to show nm_ipX_config_replace() bug
Add test to show a wrong result of ip_ipX_config_replace() due to a bug in _nm_ip_config_add_obj(). When an address is added to the tail of the index and another address with the same id already exists, the existing object is left at the same place, breaking the order of addresses.
This commit is contained in:
parent
0300c1823a
commit
24741bff8b
1 changed files with 44 additions and 0 deletions
|
|
@ -74,6 +74,49 @@ build_test_config (void)
|
|||
return config;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue