mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 20:40:34 +01:00
nmtst: add nmtst_assert_connection_equals() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
0da0293f7e
commit
80e1b05c31
1 changed files with 38 additions and 0 deletions
|
|
@ -788,6 +788,44 @@ _nmtst_connection_duplicate_and_normalize (NMConnection *connection, ...)
|
|||
#define nmtst_connection_duplicate_and_normalize(connection, ...) \
|
||||
_nmtst_connection_duplicate_and_normalize(connection, ##__VA_ARGS__, NULL)
|
||||
|
||||
inline static void
|
||||
nmtst_assert_connection_equals (NMConnection *a, gboolean normalize_a, NMConnection *b, gboolean normalize_b)
|
||||
{
|
||||
gboolean compare;
|
||||
gs_unref_object NMConnection *a2 = NULL;
|
||||
gs_unref_object NMConnection *b2 = NULL;
|
||||
GHashTable *out_settings = NULL;
|
||||
|
||||
g_assert (NM_IS_CONNECTION (a));
|
||||
g_assert (NM_IS_CONNECTION (b));
|
||||
|
||||
if (normalize_a)
|
||||
a = a2 = nmtst_connection_duplicate_and_normalize (a);
|
||||
if (normalize_b)
|
||||
b = b2 = nmtst_connection_duplicate_and_normalize (b);
|
||||
|
||||
compare = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_settings);
|
||||
if (!compare && out_settings) {
|
||||
const char *name, *pname;
|
||||
GHashTable *setting;
|
||||
GHashTableIter iter, iter2;
|
||||
|
||||
g_hash_table_iter_init (&iter, out_settings);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &setting)) {
|
||||
__NMTST_LOG (g_message, ">>> differences in setting '%s':", name);
|
||||
|
||||
g_hash_table_iter_init (&iter2, out_settings);
|
||||
while (g_hash_table_iter_next (&iter2, (gpointer *) &pname, NULL))
|
||||
__NMTST_LOG (g_message, ">>> differences in setting '%s.%s':", name, pname);
|
||||
}
|
||||
}
|
||||
g_assert (compare);
|
||||
g_assert (!out_settings);
|
||||
|
||||
compare = nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT);
|
||||
g_assert (compare);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue