about summary refs log tree commit diff
path: root/src/tests/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/config')
-rw-r--r--src/tests/config/meson.build7
-rw-r--r--src/tests/config/test-config.c60
2 files changed, 30 insertions, 37 deletions
diff --git a/src/tests/config/meson.build b/src/tests/config/meson.build
index fb40d9a9..f542c453 100644
--- a/src/tests/config/meson.build
+++ b/src/tests/config/meson.build
@@ -7,16 +7,11 @@ sources = files(
 
 test_config_dir = meson.current_source_dir()
 
-cflags = [
-  '-DSRCDIR="@0@"'.format(test_config_dir),
-  '-DBUILDDIR="@0@"'.format(test_config_dir)
-]
-
 exe = executable(
   test_unit,
   sources,
   dependencies: test_nm_dep,
-  c_args: cflags
+  c_args: nm_build_cflags,
 )
 
 test(
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 50215756..75fef4fa 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -30,6 +30,9 @@
 
 #include "nm-test-utils-core.h"
 
+#define TEST_DIR              NM_BUILD_SRCDIR"/src/tests/config"
+#define BUILD_DIR             NM_BUILD_BUILDDIR"/src/tests/config"
+
 /*****************************************************************************/
 
 static void
@@ -133,9 +136,9 @@ test_config_simple (void)
 	gs_unref_object NMDevice *dev51 = nm_test_device_new ("00:00:00:00:00:51");
 	gs_unref_object NMDevice *dev52 = nm_test_device_new ("00:00:00:00:00:52");
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL);
 
-	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf");
+	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf");
 	g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient");
 	g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO");
 	g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 100);
@@ -164,12 +167,10 @@ test_config_simple (void)
 	g_assert_cmpstr (value, ==, "51");
 	g_free (value);
 
-
 	value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "ipv6.route-metric", NULL);
 	g_assert_cmpstr (value, ==, NULL);
 	g_free (value);
 
-
 	value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "ipv4.route-metric", NULL);
 	g_assert_cmpstr (value, ==, "50");
 	g_free (value);
@@ -186,7 +187,6 @@ test_config_simple (void)
 	g_assert_cmpstr (value, ==, "52");
 	g_free (value);
 
-
 	value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "dummy.test1", dev51);
 	g_assert_cmpstr (value, ==, "yes");
 	g_free (value);
@@ -209,7 +209,7 @@ test_config_non_existent (void)
 {
 	GError *error = NULL;
 
-	setup_config (&error, SRCDIR "/no-such-file", "", NULL, "/no/such/dir", "", NULL);
+	setup_config (&error, TEST_DIR "/no-such-file", "", NULL, "/no/such/dir", "", NULL);
 	g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND);
 	g_clear_error (&error);
 }
@@ -219,7 +219,7 @@ test_config_parse_error (void)
 {
 	GError *error = NULL;
 
-	setup_config (&error, SRCDIR "/bad.conf", "", NULL, "/no/such/dir", "", NULL);
+	setup_config (&error, TEST_DIR "/bad.conf", "", NULL, "/no/such/dir", "", NULL);
 	g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE);
 	g_clear_error (&error);
 }
@@ -230,12 +230,12 @@ test_config_override (void)
 	gs_unref_object NMConfig *config = NULL;
 	gs_strfreev char **plugins = NULL;
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
 	                       "--plugins", "alpha,beta,gamma,delta",
 	                       "--connectivity-interval", "12",
 	                       NULL);
 
-	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf");
+	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf");
 	g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient");
 	g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO");
 	g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 12);
@@ -256,7 +256,7 @@ test_config_global_dns (void)
 	NMGlobalDnsDomain *domain;
 	const char *const*strv;
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL,
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL,
 	                       "/no/such/dir", "", NULL);
 
 	dns = nm_config_data_get_global_dns_config (nm_config_get_data_orig (config));
@@ -311,7 +311,7 @@ test_config_global_dns (void)
 	g_object_unref (config);
 
 	/* Check that a file without a default domain section gives a NULL configuration */
-	config = setup_config (NULL, SRCDIR "/global-dns-invalid.conf", "", NULL,
+	config = setup_config (NULL, TEST_DIR "/global-dns-invalid.conf", "", NULL,
 	                       "/no/such/dir", "", NULL);
 	dns = nm_config_data_get_global_dns_config (nm_config_get_data_orig (config));
 	g_assert (!dns);
@@ -322,12 +322,12 @@ static void
 test_config_connectivity_check (void)
 {
 #if WITH_CONCHECK
-	const char *CONFIG_INTERN = BUILDDIR"/test-connectivity-check-intern.conf";
+	const char *CONFIG_INTERN = BUILD_DIR"/test-connectivity-check-intern.conf";
 	NMConfig *config;
 	NMConnectivity *connectivity;
 
 	g_assert (g_file_set_contents (CONFIG_INTERN, "", 0, NULL));
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", CONFIG_INTERN, NULL,
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", CONFIG_INTERN, NULL,
 	                       "/no/such/dir", "", NULL);
 	connectivity = nm_connectivity_get();
 
@@ -374,7 +374,7 @@ test_config_no_auto_default (void)
 	g_assert_cmpint (nwrote, ==, 18);
 	nm_close (fd);
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
 	                       "--no-auto-default", state_file,
 	                       NULL);
 
@@ -396,7 +396,7 @@ test_config_no_auto_default (void)
 
 	g_object_unref (config);
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
 	                       "--no-auto-default", state_file,
 	                       NULL);
 
@@ -424,9 +424,9 @@ test_config_confdir (void)
 	char *value;
 	GSList *specs;
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
 
-	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf");
+	g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf");
 	g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhcpcd");
 	g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO");
 	g_assert_cmpstr (nm_config_get_log_domains (config), ==, "PLATFORM,DNS,WIFI");
@@ -527,8 +527,8 @@ test_config_confdir_parse_error (void)
 {
 	GError *error = NULL;
 
-	/* Using SRCDIR as the conf dir will pick up bad.conf */
-	setup_config (&error, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR, "", NULL);
+	/* Using TEST_DIR as the conf dir will pick up bad.conf */
+	setup_config (&error, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR, "", NULL);
 	g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE);
 	g_clear_error (&error);
 }
@@ -811,8 +811,8 @@ static void
 test_config_set_values (void)
 {
 	gs_unref_object NMConfig *config = NULL;
-	const char *CONFIG_USER = BUILDDIR"/test-set-values-user.conf";
-	const char *CONFIG_INTERN = BUILDDIR"/test-set-values-intern.conf";
+	const char *CONFIG_USER = BUILD_DIR"/test-set-values-user.conf";
+	const char *CONFIG_INTERN = BUILD_DIR"/test-set-values-intern.conf";
 	const char *atomic_section_prefixes[] = {
 		"atomic-prefix-1.",
 		"atomic-prefix-2.",
@@ -896,7 +896,7 @@ test_config_signal (void)
 	NMConfigChangeFlags expected;
 	gs_unref_object NMConfigData *config_data_orig = NULL;
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
 
 	config_data_orig = g_object_ref (nm_config_get_data_orig (config));
 
@@ -917,7 +917,6 @@ test_config_signal (void)
 	NMTST_EXPECT_NM_INFO ("config: signal: SIGHUP (no changes from disk)*");
 	nm_config_reload (config, expected);
 
-
 	/* test with subscribing two signals...
 	 *
 	 * This test exposes glib bug https://bugzilla.redhat.com/show_bug.cgi?id=1260577
@@ -931,7 +930,6 @@ test_config_signal (void)
 	nm_config_reload (config, NM_CONFIG_CHANGE_CAUSE_SIGUSR2);
 	g_signal_handlers_disconnect_by_func (config, _test_signal_config_changed_cb2, &expected);
 
-
 	g_signal_handlers_disconnect_by_func (config, _test_signal_config_changed_cb, &expected);
 
 	g_assert (config_data_orig == nm_config_get_data (config));
@@ -950,19 +948,19 @@ test_config_enable (void)
 	_nm_config_match_env = g_strdup ("something-else");
 
 	_nm_config_match_nm_version = nm_encode_version (1, 3, 4);
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
 	assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", NULL);
 	g_clear_object (&config);
 
 	_nm_config_match_nm_version = nm_encode_version (1, 5, 32);
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
 	assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", "enabled");
 	g_clear_object (&config);
 
 	_nm_config_match_nm_version = nm_encode_version (1, 5, 3);
 	g_clear_pointer (&_nm_config_match_env, g_free);
 	_nm_config_match_env = g_strdup ("test-match-env-1");
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL);
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
 	assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", "enabled");
 	g_clear_object (&config);
 
@@ -982,14 +980,14 @@ test_config_state_file (void)
 	gboolean ret;
 	gs_free char *file_data = NULL;
 	gsize file_size;
-	const char *const TMP_FILE = BUILDDIR "/tmp.state";
+	const char *const TMP_FILE = BUILD_DIR "/tmp.state";
 
-	ret = g_file_get_contents (SRCDIR "/NetworkManager.state", &file_data, &file_size, &error);
+	ret = g_file_get_contents (TEST_DIR "/NetworkManager.state", &file_data, &file_size, &error);
 	nmtst_assert_success (ret, error);
 	ret = g_file_set_contents (TMP_FILE, file_data, file_size, &error);
 	nmtst_assert_success (ret, error);
 
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "",
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "",
 	                       "--state-file", TMP_FILE, NULL);
 	g_assert (config);
 
@@ -1015,7 +1013,7 @@ test_config_state_file (void)
 	g_object_unref (config);
 
 	/* Reload configuration */
-	config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "",
+	config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "",
 	                       "--state-file", TMP_FILE, NULL);
 	g_assert (config);