about summary refs log tree commit diff
path: root/libnm-core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core/tests')
-rw-r--r--libnm-core/tests/meson.build12
-rw-r--r--libnm-core/tests/test-crypto.c2
-rw-r--r--libnm-core/tests/test-general.c276
-rw-r--r--libnm-core/tests/test-keyfile.c10
-rw-r--r--libnm-core/tests/test-secrets.c4
-rw-r--r--libnm-core/tests/test-setting.c5
6 files changed, 216 insertions, 93 deletions
diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build
index 6e8a2493..2eeadd88 100644
--- a/libnm-core/tests/meson.build
+++ b/libnm-core/tests/meson.build
@@ -29,18 +29,16 @@ test_units = [
 
 test_cert_dir = join_paths(meson.current_source_dir(), 'certs')
 
-cflags = [
-  '-DNETWORKMANAGER_COMPILATION_TEST',
-  '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
-  '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir),
-]
-
 foreach test_unit: test_units
   exe = executable(
     'libnm-core-' + test_unit,
     [test_unit + '.c'] + enum,
     dependencies: nm_core_dep,
-    c_args: cflags,
+    c_args: [
+        '-DNETWORKMANAGER_COMPILATION_TEST',
+        '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
+      ] +
+      nm_build_cflags,
     link_with: libnm_core
   )
   test(
diff --git a/libnm-core/tests/test-crypto.c b/libnm-core/tests/test-crypto.c
index 0c2ef48a..fb99ffea 100644
--- a/libnm-core/tests/test-crypto.c
+++ b/libnm-core/tests/test-crypto.c
@@ -35,6 +35,8 @@
 
 #include "nm-utils/nm-test-utils.h"
 
+#define TEST_CERT_DIR              NM_BUILD_SRCDIR"/libnm-core/tests/certs"
+
 #if 0
 static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----";
 static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----";
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 544eb3c0..3b9debd9 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -26,6 +26,7 @@
 #include <string.h>
 
 #include "nm-utils/c-list-util.h"
+#include "nm-utils/nm-enum-utils.h"
 
 #include "nm-utils.h"
 #include "nm-setting-private.h"
@@ -6328,105 +6329,219 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates (void)
 }
 
 /*****************************************************************************/
+
 static void
-test_nm_utils_enum_from_str_do (GType type, const char *str,
-                                gboolean exp_result, int exp_flags,
-                                const char *exp_err_token)
+_test_nm_utils_enum_to_str_do_full (GType type,
+                                    int flags,
+                                    const char *exp_str,
+                                    const NMUtilsEnumValueInfo *value_infos)
 {
-	int flags = 1;
-	char *err_token = NULL;
+	gs_free char *str = NULL;
+	int flags2;
+	gs_free char *err_token = NULL;
 	gboolean result;
 
-	result = nm_utils_enum_from_str (type, str, &flags, &err_token);
+	g_assert (exp_str);
 
-	g_assert (result == exp_result);
-	g_assert_cmpint (flags, ==, exp_flags);
-	g_assert_cmpstr (err_token, ==, exp_err_token);
+	str = _nm_utils_enum_to_str_full (type, flags, ", ", value_infos);
+	g_assert_cmpstr (str, ==, exp_str);
+
+	if (!value_infos) {
+		gs_free char *str2 = NULL;
 
-	g_free (err_token);
+		str2 = nm_utils_enum_to_str (type, flags);
+		g_assert_cmpstr (str2, ==, exp_str);
+	}
+
+	result = _nm_utils_enum_from_str_full (type, str, &flags2, &err_token, value_infos);
+	g_assert (result == TRUE);
+	g_assert_cmpint (flags2, ==, flags);
+	g_assert_cmpstr (err_token, ==, NULL);
 }
 
+#define _test_nm_utils_enum_to_str_do(...) _test_nm_utils_enum_to_str_do_full (__VA_ARGS__, NULL)
+
 static void
-test_nm_utils_enum_to_str_do (GType type, int flags, const char *exp_str)
+_test_nm_utils_enum_from_str_do_full (GType type,
+                                     const char *str,
+                                     gboolean exp_result,
+                                     int exp_flags,
+                                     const char *exp_err_token,
+                                     const NMUtilsEnumValueInfo *value_infos)
 {
-	char *str;
+	int flags;
+	gs_free char *err_token = NULL;
+	gboolean result;
 
-	str = nm_utils_enum_to_str (type, flags);
-	g_assert_cmpstr (str, ==, exp_str);
-	g_free (str);
+	result = _nm_utils_enum_from_str_full (type, str, &flags, &err_token, value_infos);
+
+	g_assert (result == exp_result);
+	g_assert_cmpint (flags, ==, exp_flags);
+	g_assert_cmpstr (err_token, ==, exp_err_token);
+
+	if (!value_infos) {
+		int flags2;
+		gs_free char *err_token2 = NULL;
+		gboolean result2;
+
+		result2 = nm_utils_enum_from_str (type, str, &flags2, &err_token2);
+		g_assert (result2 == exp_result);
+		g_assert_cmpint (flags2, ==, exp_flags);
+		g_assert_cmpstr (err_token2, ==, exp_err_token);
+	}
+
+	if (result) {
+		int flags2;
+		gs_free char *str2 = NULL;
+		gs_free char *err_token2 = NULL;
+
+		str2 = _nm_utils_enum_to_str_full (type, flags, ", ", value_infos);
+		g_assert (str2);
+
+		result = _nm_utils_enum_from_str_full (type, str2, &flags2, &err_token2, value_infos);
+		g_assert (result == TRUE);
+		g_assert_cmpint (flags2, ==, flags);
+		g_assert_cmpstr (err_token, ==, NULL);
+	}
 }
 
+#define _test_nm_utils_enum_from_str_do(...) _test_nm_utils_enum_from_str_do_full(__VA_ARGS__, NULL)
+
 static void
-test_nm_utils_enum_get_values_do (GType type, int from, int to, const char *exp_str)
+_test_nm_utils_enum_get_values_do (GType type, int from, int to, const char *exp_str)
 {
-	const char **strv;
-	char *str;
+	gs_free const char **strv = NULL;
+	gs_free char *str = NULL;
+
+	g_assert (exp_str);
 
 	strv = nm_utils_enum_get_values (type, from, to);
 	g_assert (strv);
 	str = g_strjoinv (",", (char **) strv);
 	g_assert_cmpstr (str, ==, exp_str);
-	g_free (str);
-	g_free (strv);
 }
 
-
-static void test_nm_utils_enum (void)
+static void
+test_nm_utils_enum (void)
 {
 	GType bool_enum = nm_test_general_bool_enum_get_type();
 	GType meta_flags = nm_test_general_meta_flags_get_type();
 	GType color_flags = nm_test_general_color_flags_get_type();
+	static const NMUtilsEnumValueInfo color_value_infos[] = {
+		{
+			.nick = "nick-4d",
+			.value = 0x4D,
+		},
+		{
+			.nick = "nick-5",
+			.value = 5,
+		},
+		{
+			.nick = "nick-red",
+			.value = NM_TEST_GENERAL_COLOR_FLAGS_RED,
+		},
+		{ 0 },
+	};
 
-	test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, "yes");
-	test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "unknown");
-	test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_INVALID, "4");
-	test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_67, "67");
-	test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_46, "64");
-
-	test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, "none");
-	test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz");
-	test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO |
-	                                          NM_TEST_GENERAL_META_FLAGS_BAR |
-	                                          NM_TEST_GENERAL_META_FLAGS_BAZ, "foo, bar, baz");
-	test_nm_utils_enum_to_str_do (meta_flags, 0xFF, "foo, bar, baz, 0xf8");
-	test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x8, "0x8");
-	test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x4, "0x10");
-
-	test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED, "red");
-	test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_WHITE, "0x1");
-	test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED |
-	                                           NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "red, green");
-
-	test_nm_utils_enum_from_str_do (bool_enum, "", FALSE, 0, NULL);
-	test_nm_utils_enum_from_str_do (bool_enum, " ", FALSE, 0, NULL);
-	test_nm_utils_enum_from_str_do (bool_enum, "invalid", FALSE, 0, "invalid");
-	test_nm_utils_enum_from_str_do (bool_enum, "yes", TRUE, NM_TEST_GENERAL_BOOL_ENUM_YES, NULL);
-	test_nm_utils_enum_from_str_do (bool_enum, "no", TRUE, NM_TEST_GENERAL_BOOL_ENUM_NO, NULL);
-	test_nm_utils_enum_from_str_do (bool_enum, "yes,no", FALSE, 0, "yes,no");
-
-	test_nm_utils_enum_from_str_do (meta_flags, "", TRUE, 0, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, " ", TRUE, 0, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "foo", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "foo,baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
-	                                                             NM_TEST_GENERAL_META_FLAGS_BAZ, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "foo, baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
+	_test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, "yes");
+	_test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "unknown");
+	_test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_INVALID, "4");
+	_test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_67, "67");
+	_test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_46, "64");
+
+	_test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, "none");
+	_test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz");
+	_test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO |
+	                                           NM_TEST_GENERAL_META_FLAGS_BAR |
+	                                           NM_TEST_GENERAL_META_FLAGS_BAZ, "foo, bar, baz");
+	_test_nm_utils_enum_to_str_do (meta_flags, 0xFF, "foo, bar, baz, 0xf8");
+	_test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x8, "0x8");
+	_test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x4, "0x10");
+
+	_test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED, "red");
+	_test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_WHITE, "0x1");
+	_test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED |
+	                                            NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "red, green");
+
+	_test_nm_utils_enum_to_str_do_full (color_flags,
+	                                      NM_TEST_GENERAL_COLOR_FLAGS_RED
+	                                    | NM_TEST_GENERAL_COLOR_FLAGS_GREEN,
+	                                    "nick-red, green",
+	                                    color_value_infos);
+
+	_test_nm_utils_enum_to_str_do_full (color_flags,
+	                                      0x4D
+	                                    |  NM_TEST_GENERAL_COLOR_FLAGS_RED
+	                                    | NM_TEST_GENERAL_COLOR_FLAGS_GREEN,
+	                                    "nick-4d",
+	                                    color_value_infos);
+
+	_test_nm_utils_enum_to_str_do_full (color_flags,
+	                                      5
+	                                    | NM_TEST_GENERAL_COLOR_FLAGS_GREEN,
+	                                    "nick-5, green",
+	                                    color_value_infos);
+
+	_test_nm_utils_enum_from_str_do (bool_enum, "", FALSE, 0, NULL);
+	_test_nm_utils_enum_from_str_do (bool_enum, " ", FALSE, 0, NULL);
+	_test_nm_utils_enum_from_str_do (bool_enum, "invalid", FALSE, 0, "invalid");
+	_test_nm_utils_enum_from_str_do (bool_enum, "yes", TRUE, NM_TEST_GENERAL_BOOL_ENUM_YES, NULL);
+	_test_nm_utils_enum_from_str_do (bool_enum, "no", TRUE, NM_TEST_GENERAL_BOOL_ENUM_NO, NULL);
+	_test_nm_utils_enum_from_str_do (bool_enum, "yes,no", FALSE, 0, "yes,no");
+
+	_test_nm_utils_enum_from_str_do (meta_flags, "", TRUE, 0, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, " ", TRUE, 0, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo,baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
 	                                                              NM_TEST_GENERAL_META_FLAGS_BAZ, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "foo,,bar", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
-	                                                              NM_TEST_GENERAL_META_FLAGS_BAR, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "foo,baz,quux,bar", FALSE, 0, "quux");
-	test_nm_utils_enum_from_str_do (meta_flags, "foo,0x6", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | 0x6, NULL);
-	test_nm_utils_enum_from_str_do (meta_flags, "0x30,0x08,foo", TRUE, 0x39, NULL);
-
-	test_nm_utils_enum_from_str_do (color_flags, "green", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_GREEN, NULL);
-	test_nm_utils_enum_from_str_do (color_flags, "blue,red", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_BLUE |
-	                                                               NM_TEST_GENERAL_COLOR_FLAGS_RED, NULL);
-	test_nm_utils_enum_from_str_do (color_flags, "blue,white", FALSE, 0, "white");
-
-	test_nm_utils_enum_get_values_do (bool_enum, 0, G_MAXINT, "no,yes,maybe,unknown,67,64");
-	test_nm_utils_enum_get_values_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES,
-	                                  NM_TEST_GENERAL_BOOL_ENUM_MAYBE, "yes,maybe");
-	test_nm_utils_enum_get_values_do (meta_flags, 0, G_MAXINT, "none,foo,bar,baz,0x8,0x10");
-	test_nm_utils_enum_get_values_do (color_flags, 0, G_MAXINT, "blue,red,green");
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo, baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
+	                                                               NM_TEST_GENERAL_META_FLAGS_BAZ, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo,,bar", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO |
+	                                                               NM_TEST_GENERAL_META_FLAGS_BAR, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo,baz,quux,bar", FALSE, 0, "quux");
+	_test_nm_utils_enum_from_str_do (meta_flags, "foo,0x6", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | 0x6, NULL);
+	_test_nm_utils_enum_from_str_do (meta_flags, "0x30,0x08,foo", TRUE, 0x39, NULL);
+
+	_test_nm_utils_enum_from_str_do (color_flags, "green", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_GREEN, NULL);
+	_test_nm_utils_enum_from_str_do (color_flags, "blue,red", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_BLUE |
+	                                                                NM_TEST_GENERAL_COLOR_FLAGS_RED, NULL);
+	_test_nm_utils_enum_from_str_do (color_flags, "blue,white", FALSE, 0, "white");
+
+	_test_nm_utils_enum_from_str_do_full (color_flags,
+	                                      "nick-red",
+	                                      TRUE,
+	                                      NM_TEST_GENERAL_COLOR_FLAGS_RED,
+	                                      NULL,
+	                                      color_value_infos);
+
+	_test_nm_utils_enum_from_str_do_full (color_flags,
+	                                      "0x4D",
+	                                      TRUE,
+	                                      0x4D,
+	                                      NULL,
+	                                      color_value_infos);
+
+	_test_nm_utils_enum_from_str_do_full (color_flags,
+	                                      "green,nick-4d",
+	                                      TRUE,
+	                                        0x4D
+	                                      | NM_TEST_GENERAL_COLOR_FLAGS_GREEN,
+	                                      NULL,
+	                                      color_value_infos);
+
+	_test_nm_utils_enum_from_str_do_full (color_flags,
+	                                      "nick-4d,nick-red,nick-5,green,nick-red",
+	                                      TRUE,
+	                                        0x4D
+	                                      | NM_TEST_GENERAL_COLOR_FLAGS_GREEN,
+	                                      NULL,
+	                                      color_value_infos);
+
+	_test_nm_utils_enum_get_values_do (bool_enum, 0, G_MAXINT, "no,yes,maybe,unknown,67,64");
+	_test_nm_utils_enum_get_values_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES,
+	                                   NM_TEST_GENERAL_BOOL_ENUM_MAYBE, "yes,maybe");
+	_test_nm_utils_enum_get_values_do (meta_flags, 0, G_MAXINT, "none,foo,bar,baz,0x8,0x10");
+	_test_nm_utils_enum_get_values_do (color_flags, 0, G_MAXINT, "blue,red,green");
 }
 
 /*****************************************************************************/
@@ -6724,7 +6839,6 @@ test_nm_in_strset (void)
 	_ASSERT (3, !NM_IN_STRSET_SE ("a",  G(NULL), G("b"),  G("b")));
 	_ASSERT (3, !NM_IN_STRSET_SE (NULL, G("a"),  G("b"),  G("b")));
 
-
 	_ASSERT (3,  NM_IN_STRSET ("a",  G(NULL), G("b"),  G("a"),  N("a")));
 	_ASSERT (4,  NM_IN_STRSET ("a",  G(NULL), G("b"),  G("c"),  G("a")));
 	_ASSERT (4, !NM_IN_STRSET ("a",  G(NULL), G("b"),  G("c"),  G("d")));
@@ -6875,6 +6989,22 @@ test_nm_set_out (void)
 
 /*****************************************************************************/
 
+static void
+test_get_start_time_for_pid (void)
+{
+	guint64 x_start_time;
+	char x_state;
+	pid_t x_ppid;
+
+	x_start_time = nm_utils_get_start_time_for_pid (getpid (), &x_state, &x_ppid);
+
+	g_assert (x_start_time > 0);
+	g_assert (x_ppid == getppid ());
+	g_assert (!NM_IN_SET (x_state, '\0', ' '));
+}
+
+/*****************************************************************************/
+
 NMTST_DEFINE ();
 
 int main (int argc, char **argv)
@@ -7028,6 +7158,8 @@ int main (int argc, char **argv)
 	g_test_add_func ("/core/general/route_attributes/parse", test_route_attributes_parse);
 	g_test_add_func ("/core/general/route_attributes/format", test_route_attributes_format);
 
+	g_test_add_func ("/core/general/get_start_time_for_pid", test_get_start_time_for_pid);
+
 	return g_test_run ();
 }
 
diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c
index 543ca629..672c72b6 100644
--- a/libnm-core/tests/test-keyfile.c
+++ b/libnm-core/tests/test-keyfile.c
@@ -33,7 +33,7 @@
 
 #include "nm-utils/nm-test-utils.h"
 
-
+#define TEST_CERT_DIR              NM_BUILD_SRCDIR"/libnm-core/tests/certs"
 #define TEST_WIRED_TLS_CA_CERT     TEST_CERT_DIR"/test-ca-cert.pem"
 #define TEST_WIRED_TLS_PRIVKEY     TEST_CERT_DIR"/test-key-and-cert.pem"
 
@@ -203,7 +203,6 @@ _nm_keyfile_read (GKeyFile *keyfile,
 	return con;
 }
 
-
 static void
 _keyfile_convert (NMConnection **con,
                   GKeyFile **keyfile,
@@ -412,14 +411,12 @@ test_8021x_cert (void)
 	g_assert_no_error (error);
 	g_assert (success);
 
-
 	/* test reseting ca-cert to different values and see whether we can write/read. */
 
 	nm_connection_add_setting (con, NM_SETTING (s_8021x));
 	nmtst_assert_connection_verifies_and_normalizable (con);
 	nmtst_connection_normalize (con);
 
-
 	_test_8021x_cert_check (con, scheme, full_TEST_WIRED_TLS_CA_CERT, -1);
 
 	scheme = NM_SETTING_802_1X_CK_SCHEME_BLOB;
@@ -457,7 +454,6 @@ test_8021x_cert_read (void)
 	      "/test_8021x_cert_read/test0", NULL);
 	CLEAR (&con, &keyfile);
 
-
 	keyfile = _keyfile_load_from_data (
 	          "[connection]\n"
 	          "type=ethernet"
@@ -480,7 +476,6 @@ test_8021x_cert_read (void)
 	_keyfile_convert (&con, &keyfile, "/test_8021x_cert_read/test2", NULL, NULL, NULL, NULL, NULL, TRUE);
 	CLEAR (&con, &keyfile);
 
-
 	keyfile = _keyfile_load_from_data (
 	          "[connection]\n"
 	          "type=802-3-ethernet\n"
@@ -523,7 +518,6 @@ test_8021x_cert_read (void)
 	g_assert_cmpint (strlen (nm_setting_802_1x_get_private_key_path (s_8021x)), ==, 505);
 	CLEAR (&con, &keyfile);
 
-
 	keyfile = _keyfile_load_from_data (
 	          "[connection]\n"
 	          "type=802-3-ethernet\n"
@@ -549,7 +543,6 @@ test_8021x_cert_read (void)
 	_assert_gbytes (nm_setting_802_1x_get_private_key_blob (s_8021x), "hallo", -1);
 	CLEAR (&con, &keyfile);
 
-
 	keyfile = _keyfile_load_from_data (
 	          "[connection]\n"
 	          "type=802-3-ethernet\n"
@@ -575,7 +568,6 @@ test_8021x_cert_read (void)
 	_assert_gbytes (nm_setting_802_1x_get_private_key_blob (s_8021x), "abc.deR\0", 8);
 	CLEAR (&con, &keyfile);
 
-
 	keyfile = _keyfile_load_from_data (
 	          "[connection]\n"
 	          "type=802-3-ethernet\n"
diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c
index 5961b6fc..d31c43d2 100644
--- a/libnm-core/tests/test-secrets.c
+++ b/libnm-core/tests/test-secrets.c
@@ -40,7 +40,8 @@
 
 #include "nm-utils/nm-test-utils.h"
 
-#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem"
+#define TEST_CERT_DIR                         NM_BUILD_SRCDIR"/libnm-core/tests/certs"
+#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT     TEST_CERT_DIR "/test_ca_cert.pem"
 #define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem"
 #define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem"
 
@@ -259,7 +260,6 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
 	                                       &error);
 	nmtst_assert_success (success, error);
 
-
 	/* IP4 setting */
 	s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
 	nm_connection_add_setting (connection, NM_SETTING (s_ip4));
diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c
index d0e0b377..6c5c6ad9 100644
--- a/libnm-core/tests/test-setting.c
+++ b/libnm-core/tests/test-setting.c
@@ -37,6 +37,8 @@
 
 #include "nm-utils/nm-test-utils.h"
 
+#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs"
+
 /*****************************************************************************/
 
 static void
@@ -599,7 +601,6 @@ test_bond_normalize (void)
                        NM_SETTING_DCB_FLAG_ADVERTISE | \
                        NM_SETTING_DCB_FLAG_WILLING)
 
-
 static void
 test_dcb_flags_valid (void)
 {
@@ -943,7 +944,6 @@ _test_team_config_sync (const char *team_config,
 	g_assert (nm_setting_verify ((NMSetting *) s_team, NULL, NULL));
 }
 
-
 static void
 test_runner_roundrobin_sync_from_config (void)
 {
@@ -1183,7 +1183,6 @@ _test_team_port_config_sync (const char *team_port_config,
 	g_assert (nm_setting_verify ((NMSetting *) s_team_port, NULL, NULL));
 }
 
-
 static void
 test_team_port_default (void)
 {