summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-01-10 18:05:30 +0100
committerThomas Haller <thaller@redhat.com>2014-06-30 18:35:16 +0200
commit542f1fe3c996f900615f8d47de4c6dc667134a5a (patch)
treead8eb4ed219b4b26cadf3cb5d18248adcb8bdbe3
parent28169725d7efbca26ce08549cc02b6727c95e2fa (diff)
downloadNetworkManager-542f1fe3c996f900615f8d47de4c6dc667134a5a.tar.gz
test: nm_connection_verify() sets the interface-name to virtual_iface_name.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-util/tests/test-general.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c
index 5a54c558cb..df62dd9344 100644
--- a/libnm-util/tests/test-general.c
+++ b/libnm-util/tests/test-general.c
@@ -2484,6 +2484,49 @@ test_setting_old_uuid (void)
g_assert (success == TRUE);
}
+/*
+ * nm_connection_verify() modifies the connection by setting
+ * the interface-name property to the virtual_iface_name of
+ * the type specific settings.
+ *
+ * It would be preferable of verify() not to touch the connection,
+ * but as it is now, stick with it and test it.
+ **/
+static void
+test_connection_verify_sets_interface_name (void)
+{
+ NMConnection *con;
+ NMSettingConnection *s_con;
+ NMSettingBond *s_bond;
+ GError *error = NULL;
+ gboolean success;
+
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ g_object_set (G_OBJECT (s_con),
+ NM_SETTING_CONNECTION_ID, "test1",
+ NM_SETTING_CONNECTION_UUID, "22001632-bbb4-4616-b277-363dce3dfb5b",
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME,
+ NULL);
+ s_bond = (NMSettingBond *) nm_setting_bond_new ();
+ g_object_set (G_OBJECT (s_bond),
+ NM_SETTING_BOND_INTERFACE_NAME, "bond-x",
+ NULL);
+
+ con = nm_connection_new ();
+ nm_connection_add_setting (con, NM_SETTING (s_con));
+ nm_connection_add_setting (con, NM_SETTING (s_bond));
+
+ g_assert_cmpstr (nm_connection_get_interface_name (con), ==, NULL);
+
+ /* for backward compatiblity, normalizes the interface name */
+ success = nm_connection_verify (con, &error);
+ g_assert (success && !error);
+
+ g_assert_cmpstr (nm_connection_get_interface_name (con), ==, "bond-x");
+
+ g_object_unref (con);
+}
+
NMTST_DEFINE ();
int main (int argc, char **argv)
@@ -2521,6 +2564,7 @@ int main (int argc, char **argv)
test_connection_replace_settings ();
test_connection_replace_settings_from_connection ();
test_connection_new_from_hash ();
+ test_connection_verify_sets_interface_name ();
test_setting_connection_permissions_helpers ();
test_setting_connection_permissions_property ();