summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-08 13:13:13 +0200
committerThomas Haller <thaller@redhat.com>2014-08-22 15:24:30 +0200
commit80e1b05c316ffbde059d9478237f8683405e63a8 (patch)
treef960c25c7a305f8dfe3d6ce3881a71d427502c97
parent0da0293f7ed60965fb0d7365972f654d21210ad7 (diff)
downloadNetworkManager-80e1b05c316ffbde059d9478237f8683405e63a8.tar.gz
nmtst: add nmtst_assert_connection_equals() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--include/nm-test-utils.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h
index b8db189445..aeba15269e 100644
--- a/include/nm-test-utils.h
+++ b/include/nm-test-utils.h
@@ -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