[network-manager-openvpn/NM_0_8] test: fix distcheck



commit 2f418e1836e65ba9e570680cf1098256682f74aa
Author: Dan Williams <dcbw redhat com>
Date:   Tue Apr 5 23:14:41 2011 -0500

    test: fix distcheck
    
    The tests need to write somewhere, and $srcdir is read-only, so
    we have to pass $builddir as well for tempfiles.

 properties/tests/Makefile.am          |    2 +-
 properties/tests/test-import-export.c |   85 +++++++++++++++++----------------
 2 files changed, 44 insertions(+), 43 deletions(-)
---
diff --git a/properties/tests/Makefile.am b/properties/tests/Makefile.am
index 6d2314b..7457f5b 100644
--- a/properties/tests/Makefile.am
+++ b/properties/tests/Makefile.am
@@ -27,7 +27,7 @@ test_import_export_LDADD = \
 if WITH_TESTS
 
 check-local: test-import-export
-	$(abs_builddir)/test-import-export $(abs_srcdir)/conf
+	$(abs_builddir)/test-import-export $(abs_srcdir)/conf $(abs_builddir)/conf
 
 endif
 
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index bb861cf..395c873 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -199,7 +199,7 @@ remove_secrets (NMConnection *connection)
 
 #define PASSWORD_EXPORTED_NAME "password.ovpntest"
 static void
-test_password_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_password_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -211,7 +211,7 @@ test_password_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("password-export", plugin, dir, "password.conf");
 	ASSERT (connection != NULL, "password-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, PASSWORD_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, PASSWORD_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -221,8 +221,8 @@ test_password_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("password-export", plugin, dir, PASSWORD_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("password-export", plugin, tmpdir, PASSWORD_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "password-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -314,7 +314,7 @@ test_tls_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define TLS_EXPORTED_NAME "tls.ovpntest"
 static void
-test_tls_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_tls_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -326,7 +326,7 @@ test_tls_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("tls-export", plugin, dir, "tls.ovpn");
 	ASSERT (connection != NULL, "tls-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, TLS_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, TLS_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -336,8 +336,8 @@ test_tls_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("tls-export", plugin, dir, TLS_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("tls-export", plugin, tmpdir, TLS_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "tls-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -423,7 +423,7 @@ test_pkcs12_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define PKCS12_EXPORTED_NAME "pkcs12.ovpntest"
 static void
-test_pkcs12_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_pkcs12_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -435,7 +435,7 @@ test_pkcs12_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("pkcs12-export", plugin, dir, "pkcs12.ovpn");
 	ASSERT (connection != NULL, "pkcs12-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, PKCS12_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, PKCS12_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -445,8 +445,8 @@ test_pkcs12_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("pkcs12-export", plugin, dir, PKCS12_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("pkcs12-export", plugin, tmpdir, PKCS12_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "pkcs12-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -566,7 +566,7 @@ test_static_key_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define STATIC_KEY_EXPORTED_NAME "static.ovpntest"
 static void
-test_static_key_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_static_key_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -578,7 +578,7 @@ test_static_key_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("static-key-export", plugin, dir, "static.ovpn");
 	ASSERT (connection != NULL, "static-key-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, STATIC_KEY_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, STATIC_KEY_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -588,8 +588,8 @@ test_static_key_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("static-key-export", plugin, dir, STATIC_KEY_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("static-key-export", plugin, tmpdir, STATIC_KEY_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "static-key-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -644,6 +644,7 @@ static void
 test_port_export (NMVpnPluginUiInterface *plugin,
                   const char *detail,
                   const char *dir,
+                  const char *tmpdir,
                   const char *file,
                   const char *exported_name)
 {
@@ -657,7 +658,7 @@ test_port_export (NMVpnPluginUiInterface *plugin,
 	connection = get_basic_connection (detail, plugin, dir, file);
 	ASSERT (connection != NULL, detail, "failed to import connection");
 
-	path = g_build_path ("/", dir, exported_name, NULL);
+	path = g_build_path ("/", tmpdir, exported_name, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -667,8 +668,8 @@ test_port_export (NMVpnPluginUiInterface *plugin,
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection (detail, plugin, dir, exported_name);
-	ret = unlink (path);
+	reimported = get_basic_connection (detail, plugin, tmpdir, exported_name);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, detail, "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -708,7 +709,7 @@ test_tun_opts_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define TUNOPTS_EXPORTED_NAME "tun-opts.ovpntest"
 static void
-test_tun_opts_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_tun_opts_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -720,7 +721,7 @@ test_tun_opts_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("tunopts-export", plugin, dir, "tun-opts.conf");
 	ASSERT (connection != NULL, "tunopts-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, TUNOPTS_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, TUNOPTS_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -730,8 +731,8 @@ test_tun_opts_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("tunopts-export", plugin, dir, TUNOPTS_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("tunopts-export", plugin, tmpdir, TUNOPTS_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "tunopts-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -791,7 +792,7 @@ test_proxy_http_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define PROXY_HTTP_EXPORTED_NAME "proxy-http.ovpntest"
 static void
-test_proxy_http_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_proxy_http_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -804,7 +805,7 @@ test_proxy_http_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("proxy-http-export", plugin, dir, "proxy-http.ovpn");
 	ASSERT (connection != NULL, "proxy-http-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, PROXY_HTTP_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, PROXY_HTTP_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -814,8 +815,8 @@ test_proxy_http_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("proxy-http-export", plugin, dir, PROXY_HTTP_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("proxy-http-export", plugin, tmpdir, PROXY_HTTP_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "proxy-http-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -879,7 +880,7 @@ test_proxy_socks_import (NMVpnPluginUiInterface *plugin, const char *dir)
 
 #define PROXY_SOCKS_EXPORTED_NAME "proxy-socks.ovpntest"
 static void
-test_proxy_socks_export (NMVpnPluginUiInterface *plugin, const char *dir)
+test_proxy_socks_export (NMVpnPluginUiInterface *plugin, const char *dir, const char *tmpdir)
 {
 	NMConnection *connection;
 	NMConnection *reimported;
@@ -891,7 +892,7 @@ test_proxy_socks_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	connection = get_basic_connection ("proxy-socks-export", plugin, dir, "proxy-socks.ovpn");
 	ASSERT (connection != NULL, "proxy-socks-export", "failed to import connection");
 
-	path = g_build_path ("/", dir, PROXY_SOCKS_EXPORTED_NAME, NULL);
+	path = g_build_path ("/", tmpdir, PROXY_SOCKS_EXPORTED_NAME, NULL);
 	success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
 	if (!success) {
 		if (!error)
@@ -901,8 +902,8 @@ test_proxy_socks_export (NMVpnPluginUiInterface *plugin, const char *dir)
 	}
 
 	/* Now re-import it and compare the connections to ensure they are the same */
-	reimported = get_basic_connection ("proxy-socks-export", plugin, dir, PROXY_SOCKS_EXPORTED_NAME);
-	ret = unlink (path);
+	reimported = get_basic_connection ("proxy-socks-export", plugin, tmpdir, PROXY_SOCKS_EXPORTED_NAME);
+	(void) unlink (path);
 	ASSERT (reimported != NULL, "proxy-socks-export", "failed to re-import connection");
 
 	/* Clear secrets first, since they don't get exported, and thus would
@@ -926,8 +927,8 @@ int main (int argc, char **argv)
 	NMVpnPluginUiInterface *plugin = NULL;
 	char *tmp, *tmp2, *test_dir;
 
-	if (argc != 2)
-		FAIL ("args", "usage: %s <conf path>", argv[0]);
+	if (argc != 3)
+		FAIL ("args", "usage: %s <conf path> <tmp dir>", argv[0]);
 
 	g_type_init ();
 	bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
@@ -956,33 +957,33 @@ int main (int argc, char **argv)
 
 	/* The tests */
 	test_password_import (plugin, test_dir);
-	test_password_export (plugin, test_dir);
+	test_password_export (plugin, test_dir, argv[2]);
 
 	test_tls_import (plugin, test_dir);
-	test_tls_export (plugin, test_dir);
+	test_tls_export (plugin, test_dir, argv[2]);
 
 	test_pkcs12_import (plugin, test_dir);
-	test_pkcs12_export (plugin, test_dir);
+	test_pkcs12_export (plugin, test_dir, argv[2]);
 
 	test_non_utf8_import (plugin, test_dir);
 
 	test_static_key_import (plugin, test_dir);
-	test_static_key_export (plugin, test_dir);
+	test_static_key_export (plugin, test_dir, argv[2]);
 
 	test_port_import (plugin, "port-import", test_dir, "port.ovpn", "port", "2345");
-	test_port_export (plugin, "port-export", test_dir, "port.ovpn", "port.ovpntest");
+	test_port_export (plugin, "port-export", test_dir, argv[2], "port.ovpn", "port.ovpntest");
 
 	test_port_import (plugin, "rport-import", test_dir, "rport.ovpn", "rport", "6789");
-	test_port_export (plugin, "rport-export", test_dir, "rport.ovpn", "rport.ovpntest");
+	test_port_export (plugin, "rport-export", test_dir, argv[2], "rport.ovpn", "rport.ovpntest");
 
 	test_tun_opts_import (plugin, test_dir);
-	test_tun_opts_export (plugin, test_dir);
+	test_tun_opts_export (plugin, test_dir, argv[2]);
 
 	test_proxy_http_import (plugin, test_dir);
-	test_proxy_http_export (plugin, test_dir);
+	test_proxy_http_export (plugin, test_dir, argv[2]);
 
 	test_proxy_socks_import (plugin, test_dir);
-	test_proxy_socks_export (plugin, test_dir);
+	test_proxy_socks_export (plugin, test_dir, argv[2]);
 
 	g_object_unref (plugin);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]