summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-08 12:28:20 +0200
committerThomas Haller <thaller@redhat.com>2014-07-27 23:57:35 +0200
commite5448361378707188880c93cc7456850967a0b31 (patch)
tree6f921f58e826fe21e2ecb0e11dcc36bba5eafbed
parent83cda23e93a58753fc4fea842f43350a7db35e2f (diff)
downloadNetworkManager-e5448361378707188880c93cc7456850967a0b31.tar.gz
nmtst: add nmtst_connection_normalize() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--include/nm-test-utils.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h
index 09ab1ad988..83c7807d09 100644
--- a/include/nm-test-utils.h
+++ b/include/nm-test-utils.h
@@ -679,5 +679,73 @@ nmtst_ip6_config_clone (NMIP6Config *config)
#endif
+#ifdef NM_CONNECTION_H
+
+inline static gboolean
+_nmtst_connection_normalize_v (NMConnection *connection, va_list args)
+{
+ GError *error = NULL;
+ gboolean success;
+ gboolean was_modified = FALSE;
+ GHashTable *parameters = NULL;
+ const char *p_name;
+
+ g_assert (NM_IS_CONNECTION (connection));
+
+ while ((p_name = va_arg (args, const char *))) {
+ if (!parameters)
+ parameters = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (parameters, (gpointer *) p_name, va_arg (args, gpointer));
+ }
+
+ success = nm_connection_normalize (connection,
+ parameters,
+ &was_modified,
+ &error);
+ g_assert_no_error (error);
+ g_assert (success);
+
+ if (parameters)
+ g_hash_table_destroy (parameters);
+
+ return was_modified;
+}
+
+inline static gboolean
+_nmtst_connection_normalize (NMConnection *connection, ...)
+{
+ gboolean was_modified;
+ va_list args;
+
+ va_start (args, connection);
+ was_modified = _nmtst_connection_normalize_v (connection, args);
+ va_end (args);
+
+ return was_modified;
+}
+#define nmtst_connection_normalize(connection, ...) \
+ _nmtst_connection_normalize(connection, ##__VA_ARGS__, NULL)
+
+inline static NMConnection *
+_nmtst_connection_duplicate_and_normalize (NMConnection *connection, ...)
+{
+ gboolean was_modified;
+ va_list args;
+
+ g_assert (NM_IS_CONNECTION (connection));
+
+ connection = nm_connection_duplicate (connection);
+
+ va_start (args, connection);
+ was_modified = _nmtst_connection_normalize_v (connection, args);
+ va_end (args);
+
+ return connection;
+}
+#define nmtst_connection_duplicate_and_normalize(connection, ...) \
+ _nmtst_connection_duplicate_and_normalize(connection, ##__VA_ARGS__, NULL)
+
+#endif
+
#endif /* __NM_TEST_UTILS_H__ */