test: add nmtst_create_connection_from_keyfile()

This commit is contained in:
Thomas Haller 2015-02-27 10:24:09 +01:00
parent c9a8764ad2
commit 997fc07ca5
2 changed files with 37 additions and 0 deletions

View file

@ -1061,6 +1061,36 @@ nmtst_assert_hwaddr_equals (gconstpointer hwaddr1, gssize hwaddr1_len, const cha
nmtst_assert_hwaddr_equals (hwaddr1, hwaddr1_len, expected, G_STRLOC)
#endif
#if defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__) && defined(__NM_KEYFILE_INTERNAL_H__)
inline static NMConnection *
nmtst_create_connection_from_keyfile (const char *keyfile_str, const char *keyfile_name, const char *base_dir)
{
GKeyFile *keyfile;
GError *error = NULL;
gboolean success;
NMConnection *con;
g_assert (keyfile_str);
keyfile = g_key_file_new ();
success = g_key_file_load_from_data (keyfile, keyfile_str, strlen (keyfile_str), G_KEY_FILE_NONE, &error);
g_assert_no_error (error);
g_assert (success);
con = nm_keyfile_read (keyfile, keyfile_name, base_dir, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (NM_IS_CONNECTION (con));
g_key_file_unref (keyfile);
nmtst_connection_normalize (con);
return con;
}
#endif
#ifdef __NM_CONNECTION_H__
typedef enum {

View file

@ -345,6 +345,13 @@ test_8021x_cert_read (void)
gs_unref_object NMConnection *con = NULL;
NMSetting8021x *s_8021x;
con = nmtst_create_connection_from_keyfile (
"[connection]\n"
"type=ethernet",
"/test_8021x_cert_read/test0", NULL);
CLEAR (&con, &keyfile);
keyfile = _keyfile_load_from_data (
"[connection]\n"
"type=ethernet"