diff options
Diffstat (limited to 'src/tests/test-general.c')
| -rw-r--r-- | src/tests/test-general.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/tests/test-general.c b/src/tests/test-general.c index de65d50f..094a4a65 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -440,6 +440,82 @@ test_connection_match_wired (void) } static void +test_connection_match_wired2 (void) +{ + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; + NMSettingWired *s_wired; + const char *mac = "52:54:00:ab:db:23"; + + orig = _match_connection_new (); + s_wired = nm_connection_get_setting_wired (orig); + g_assert (s_wired); + g_object_set (G_OBJECT (s_wired), + NM_SETTING_WIRED_PORT, "tp", /* port is not compared */ + NM_SETTING_WIRED_MAC_ADDRESS, mac, /* we allow MAC address just in one connection */ + NULL); + + copy = nm_simple_connection_new_clone (orig); + connections = g_slist_append (connections, copy); + + /* Check that if the generated connection do not have wired setting + * and s390 properties in the existing connection's setting are default, + * the connections match. It can happen if assuming VLAN devices. */ + nm_connection_remove_setting (orig, NM_TYPE_SETTING_WIRED); + + matched = nm_utils_match_connection (connections, orig, TRUE, NULL, NULL); + g_assert (matched == copy); + + g_slist_free (connections); + g_object_unref (orig); + g_object_unref (copy); +} + +static void +test_connection_match_cloned_mac (void) +{ + NMConnection *orig, *exact, *fuzzy, *matched; + GSList *connections = NULL; + NMSettingWired *s_wired; + + orig = _match_connection_new (); + + fuzzy = nm_simple_connection_new_clone (orig); + connections = g_slist_append (connections, fuzzy); + s_wired = nm_connection_get_setting_wired (orig); + g_assert (s_wired); + g_object_set (G_OBJECT (s_wired), + NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "52:54:00:ab:db:23", + NULL); + + matched = nm_utils_match_connection (connections, orig, TRUE, NULL, NULL); + g_assert (matched == fuzzy); + + exact = nm_simple_connection_new_clone (orig); + connections = g_slist_append (connections, exact); + s_wired = nm_connection_get_setting_wired (exact); + g_assert (s_wired); + g_object_set (G_OBJECT (s_wired), + NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "52:54:00:ab:db:23", + NULL); + + matched = nm_utils_match_connection (connections, orig, TRUE, NULL, NULL); + g_assert (matched == exact); + + g_object_set (G_OBJECT (s_wired), + NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "52:54:00:ab:db:24", + NULL); + + matched = nm_utils_match_connection (connections, orig, TRUE, NULL, NULL); + g_assert (matched == fuzzy); + + g_slist_free (connections); + g_object_unref (orig); + g_object_unref (fuzzy); + g_object_unref (exact); +} + +static void test_connection_no_match_ip4_addr (void) { NMConnection *orig, *copy, *matched; @@ -747,6 +823,8 @@ main (int argc, char **argv) g_test_add_func ("/general/connection-match/ip4-method", test_connection_match_ip4_method); g_test_add_func ("/general/connection-match/con-interface-name", test_connection_match_interface_name); g_test_add_func ("/general/connection-match/wired", test_connection_match_wired); + g_test_add_func ("/general/connection-match/wired2", test_connection_match_wired2); + g_test_add_func ("/general/connection-match/cloned_mac", test_connection_match_cloned_mac); g_test_add_func ("/general/connection-match/no-match-ip4-addr", test_connection_no_match_ip4_addr); g_test_add_func ("/general/connection-sort/autoconnect-priority", test_connection_sort_autoconnect_priority); |