g_assert (!nm_connection_get_setting_by_name (con, type));
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING);
+ nmtst_connection_normalize (con);
s_base = nm_connection_get_setting_by_name (con, type);
g_assert (s_base);
g_assert (nm_connection_get_setting_by_name (con, type) == s_base);
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY);
+ nmtst_connection_normalize (con);
g_assert_cmpstr (nm_connection_get_connection_type (con), ==, type);
g_assert (nm_connection_get_setting_by_name (con, type) == s_base);
g_assert (!nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME));
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING);
+ nmtst_connection_normalize (con);
g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME));
g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BRIDGE_SETTING_NAME);
}
g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME));
g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NULL);
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY);
+ nmtst_connection_normalize (con);
g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME));
g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BRIDGE_SETTING_NAME);
}
NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram",
NM_SETTING_INFINIBAND_MTU, (guint) 2044,
NULL);
- nmtst_assert_connection_verifies_without_normalization (con);
+ nmtst_assert_connection_verifies_and_normalizable (con);
+ nmtst_connection_normalize (con);
g_assert_cmpint (2044, ==, nm_setting_infiniband_get_mtu (s_infini));
g_object_set (s_infini,
NM_SETTING_INFINIBAND_MTU, (guint) 2045,
NULL);
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
+ nmtst_connection_normalize (con);
g_assert_cmpint (2044, ==, nm_setting_infiniband_get_mtu (s_infini));
g_object_set (s_infini,
NM_SETTING_INFINIBAND_MTU, (guint) 65521,
NULL);
nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
+ nmtst_connection_normalize (con);
g_assert_cmpint (65520, ==, nm_setting_infiniband_get_mtu (s_infini));
}
c1 = nmtst_create_minimal_connection ("test_compare_default_strv", NULL,
NM_SETTING_WIRED_SETTING_NAME, NULL);
nmtst_assert_connection_verifies_and_normalizable (c1);
+ nmtst_connection_normalize (c1);
c2 = nm_simple_connection_new_clone (c1);
nmtst_assert_connection_verifies_without_normalization (c2);
#if (defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__)) || (defined(NM_CONNECTION_H))
+inline static NMConnection *
+nmtst_clone_connection (NMConnection *connection)
+{
+ g_assert (NM_IS_CONNECTION (connection));
+
+#if defined(__NM_SIMPLE_CONNECTION_H__)
+ return nm_simple_connection_new_clone (connection);
+#else
+ return nm_connection_duplicate (connection);
+#endif
+}
+
inline static NMConnection *
nmtst_create_minimal_connection (const char *id, const char *uuid, const char *type, NMSettingConnection **out_s_con)
{
gboolean was_modified;
va_list args;
- g_assert (NM_IS_CONNECTION (connection));
-
-#if defined(__NM_SIMPLE_CONNECTION_H__)
- connection = nm_simple_connection_new_clone (connection);
-#else
- connection = nm_connection_duplicate (connection);
-#endif
+ connection = nmtst_clone_connection (connection);
va_start (args, connection);
was_modified = _nmtst_connection_normalize_v (connection, args);
}
inline static void
-nmtst_assert_connection_verifies_without_normalization (NMConnection *con)
+nmtst_assert_connection_verifies (NMConnection *con)
{
- /* assert that the connection verifies and does not need any normalization */
-
+ /* assert that the connection does verify, it might be normaliziable or not */
GError *error = NULL;
gboolean success;
- gboolean was_modified = FALSE;
- gs_unref_object NMConnection *clone = NULL;
g_assert (NM_IS_CONNECTION (con));
-#if defined(__NM_SIMPLE_CONNECTION_H__)
- clone = nm_simple_connection_new_clone (con);
-#else
- clone = nm_connection_duplicate (con);
-#endif
-
success = nm_connection_verify (con, &error);
g_assert_no_error (error);
g_assert (success);
+}
+
+inline static void
+nmtst_assert_connection_verifies_without_normalization (NMConnection *con)
+{
+ /* assert that the connection verifies and does not need any normalization */
+ GError *error = NULL;
+ gboolean success;
+ gboolean was_modified = FALSE;
+ gs_unref_object NMConnection *clone = NULL;
+
+ clone = nmtst_clone_connection (con);
+
+ nmtst_assert_connection_verifies (con);
- success = nm_connection_normalize (con, NULL, &was_modified, &error);
+ success = nm_connection_normalize (clone, NULL, &was_modified, &error);
g_assert_no_error (error);
g_assert (success);
nmtst_assert_connection_equals (con, FALSE, clone, FALSE);
GError *error = NULL;
gboolean success;
gboolean was_modified = FALSE;
+ gs_unref_object NMConnection *clone = NULL;
- g_assert (NM_IS_CONNECTION (con));
+ clone = nmtst_clone_connection (con);
- success = nm_connection_verify (con, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_clear_error (&error);
+ nmtst_assert_connection_verifies (con);
- success = nm_connection_normalize (con, NULL, &was_modified, &error);
+ success = nm_connection_normalize (clone, NULL, &was_modified, &error);
g_assert_no_error (error);
g_assert (success);
g_assert (was_modified);
/* again! */
- nmtst_assert_connection_verifies_without_normalization (con);
+ nmtst_assert_connection_verifies_without_normalization (clone);
}
inline static void
GError *error = NULL;
gboolean success;
gboolean was_modified = FALSE;
+ gs_unref_object NMConnection *clone = NULL;
- g_assert (NM_IS_CONNECTION (con));
+ clone = nmtst_clone_connection (con);
success = nm_connection_verify (con, &error);
nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL);
g_assert (!success);
g_clear_error (&error);
- success = nm_connection_normalize (con, NULL, &was_modified, &error);
+ success = nm_connection_normalize (clone, NULL, &was_modified, &error);
g_assert_no_error (error);
g_assert (success);
g_assert (was_modified);
/* again! */
- nmtst_assert_connection_verifies_without_normalization (con);
+ nmtst_assert_connection_verifies_without_normalization (clone);
}
inline static void
GError *error = NULL;
gboolean success;
gboolean was_modified = FALSE;
+ gs_unref_object NMConnection *clone = NULL;
- g_assert (NM_IS_CONNECTION (con));
+ clone = nmtst_clone_connection (con);
success = nm_connection_verify (con, &error);
nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL);
g_assert (!success);
g_clear_error (&error);
- success = nm_connection_normalize (con, NULL, &was_modified, &error);
+ success = nm_connection_normalize (clone, NULL, &was_modified, &error);
nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL);
g_assert (!success);
g_assert (!was_modified);
+ nmtst_assert_connection_equals (con, FALSE, clone, FALSE);
g_clear_error (&error);
}