summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-05-28 12:48:37 -0400
committerRyan Lortie <desrt@desrt.ca>2013-05-29 09:03:31 -0400
commit58c6ca32aac6e0735d7325ce0b876025c722bae3 (patch)
tree0ee91b5bb779d352c91621e87d78093ab678f1f3
parent0c4806733cb30f56325b0f1c4e95a400e4998c14 (diff)
downloadglib-58c6ca32aac6e0735d7325ce0b876025c722bae3.tar.gz
tests: use new g_test_build_filename() API
Port most of the tests to the new g_test_build_filename() API. https://bugzilla.gnome.org/show_bug.cgi?id=549783
-rw-r--r--gio/tests/contexts.c8
-rw-r--r--gio/tests/file.c10
-rw-r--r--gio/tests/g-icon.c9
-rw-r--r--gio/tests/gapplication.c23
-rw-r--r--gio/tests/gdbus-connection-loss.c9
-rw-r--r--gio/tests/gdbus-connection-slow.c11
-rw-r--r--gio/tests/gdbus-connection.c13
-rw-r--r--gio/tests/gdbus-introspection.c9
-rw-r--r--gio/tests/gdbus-peer.c9
-rw-r--r--gio/tests/gdbus-proxy-well-known-name.c11
-rw-r--r--gio/tests/gdbus-proxy.c11
-rw-r--r--gio/tests/gdbus-threading.c9
-rw-r--r--gio/tests/gschema-compile.c8
-rw-r--r--gio/tests/resources.c25
-rw-r--r--gio/tests/tls-certificate.c47
-rw-r--r--glib/tests/bookmarkfile.c9
-rw-r--r--glib/tests/keyfile.c14
-rw-r--r--glib/tests/mappedfile.c17
-rw-r--r--glib/tests/markup-parse.c10
19 files changed, 62 insertions, 200 deletions
diff --git a/gio/tests/contexts.c b/gio/tests/contexts.c
index a69e46c8f..f1ed62b6e 100644
--- a/gio/tests/contexts.c
+++ b/gio/tests/contexts.c
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
-static const gchar *datapath;
static const gchar *test_file;
char *test_file_buffer;
@@ -187,14 +186,9 @@ main (int argc, char **argv)
GError *error = NULL;
int ret;
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_test_init (&argc, &argv, NULL);
- test_file = g_strconcat (datapath, "/contexts.c", NULL);
+ test_file = g_test_build_filename (G_TEST_DISTED, "contexts.c", NULL);
g_file_get_contents (test_file, &test_file_buffer,
&test_file_size, &error);
g_assert_no_error (error);
diff --git a/gio/tests/file.c b/gio/tests/file.c
index ee923d6bb..2ef037bdc 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -7,8 +7,6 @@
#include <sys/stat.h>
#endif
-static const gchar *datapath;
-
static void
test_basic (void)
{
@@ -85,8 +83,11 @@ test_type (void)
GFile *file;
GFileType type;
GError *error = NULL;
+ gchar *datapath;
+ datapath = g_test_build_filename (G_TEST_DISTED, ".", NULL);
datapath_f = g_file_new_for_path (datapath);
+ g_free (datapath);
file = g_file_get_child (datapath_f, "g-icon.c");
type = g_file_query_file_type (file, 0, NULL);
@@ -793,11 +794,6 @@ test_copy_preserve_mode (void)
int
main (int argc, char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
diff --git a/gio/tests/g-icon.c b/gio/tests/g-icon.c
index 8e18a25db..f339c6eff 100644
--- a/gio/tests/g-icon.c
+++ b/gio/tests/g-icon.c
@@ -27,8 +27,6 @@
#include <stdlib.h>
#include <string.h>
-static const gchar *datapath;
-
static void
test_g_icon_to_string (void)
{
@@ -469,7 +467,7 @@ test_file_icon (void)
gchar *str;
gchar *path;
- path = g_strconcat (datapath, "/g-icon.c", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "g-icon.c", NULL);
file = g_file_new_for_path (path);
icon = g_file_icon_new (file);
@@ -497,11 +495,6 @@ int
main (int argc,
char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/icons/to-string", test_g_icon_to_string);
diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c
index 81d5892a3..2d234bf42 100644
--- a/gio/tests/gapplication.c
+++ b/gio/tests/gapplication.c
@@ -6,9 +6,6 @@
#include "gdbus-tests.h"
#include "gdbus-sessionbus.h"
-static const gchar *datapath;
-static const gchar *binpath;
-
static gint outstanding_watches;
static GMainLoop *main_loop;
@@ -68,7 +65,7 @@ spawn (const gchar *expected_stdout,
va_start (ap, first_arg);
array = g_ptr_array_new ();
- g_ptr_array_add (array, g_build_filename (binpath, "basic-application", NULL));
+ g_ptr_array_add (array, g_test_build_filename (G_TEST_BUILT, "basic-application", NULL));
for (arg = first_arg; arg; arg = va_arg (ap, const gchar *))
g_ptr_array_add (array, g_strdup (arg));
g_ptr_array_add (array, NULL);
@@ -323,7 +320,7 @@ nodbus_activate (GApplication *app)
static void
test_nodbus (void)
{
- char *binpath = g_build_filename (datapath, "unimportant", NULL);
+ char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
gchar *argv[] = { binpath, NULL };
GApplication *app;
@@ -353,7 +350,7 @@ noappid_activate (GApplication *app)
static void
test_noappid (void)
{
- char *binpath = g_build_filename (datapath, "unimportant", NULL);
+ char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
gchar *argv[] = { binpath, NULL };
GApplication *app;
@@ -392,7 +389,7 @@ static void
test_quit (void)
{
GDBusConnection *c;
- char *binpath = g_build_filename (datapath, "unimportant", NULL);
+ char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
gchar *argv[] = { binpath, NULL };
GApplication *app;
@@ -448,7 +445,7 @@ on_activate (GApplication *app)
static void
test_actions (void)
{
- char *binpath = g_build_filename (datapath, "unimportant", NULL);
+ char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
gchar *argv[] = { binpath, NULL };
GApplication *app;
@@ -504,7 +501,7 @@ test_loc_cmd_app_class_init (TestLocCmdAppClass *klass)
static void
test_local_command_line (void)
{
- char *binpath = g_build_filename (datapath, "unimportant", NULL);
+ char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
gchar *argv[] = { binpath, "-invalid", NULL };
GApplication *app;
@@ -522,14 +519,6 @@ test_local_command_line (void)
int
main (int argc, char **argv)
{
- if (g_getenv ("G_TEST_DATA"))
- datapath = binpath = g_getenv ("G_TEST_DATA");
- else
- {
- datapath = SRCDIR;
- binpath = BUILDDIR;
- }
-
g_test_init (&argc, &argv, NULL);
g_test_dbus_unset ();
diff --git a/gio/tests/gdbus-connection-loss.c b/gio/tests/gdbus-connection-loss.c
index 87dc1b711..ed4142dff 100644
--- a/gio/tests/gdbus-connection-loss.c
+++ b/gio/tests/gdbus-connection-loss.c
@@ -26,8 +26,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
@@ -116,11 +114,6 @@ main (int argc,
gint ret;
gchar *path;
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
@@ -129,7 +122,7 @@ main (int argc,
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
diff --git a/gio/tests/gdbus-connection-slow.c b/gio/tests/gdbus-connection-slow.c
index 4b5e0868d..2f943c3d9 100644
--- a/gio/tests/gdbus-connection-slow.c
+++ b/gio/tests/gdbus-connection-slow.c
@@ -28,8 +28,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@@ -91,7 +89,7 @@ test_connection_flush (void)
gchar *path;
error = NULL;
- path = g_build_filename (binpath, "gdbus-connection-flush-helper", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-connection-flush-helper", NULL);
ret = g_spawn_command_line_sync (path,
NULL, /* stdout */
NULL, /* stderr */
@@ -194,7 +192,7 @@ test_connection_large_message (void)
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -221,11 +219,6 @@ int
main (int argc,
char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c
index ef4cd52a5..724acc0f1 100644
--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -28,9 +28,6 @@
#include "gdbus-tests.h"
-const gchar *srcdir;
-const gchar *builddir;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@@ -1005,7 +1002,7 @@ test_connection_filter (void)
g_assert_cmpint (data.num_outgoing, ==, 4);
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (builddir, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -1228,14 +1225,6 @@ main (int argc,
{
g_test_init (&argc, &argv, NULL);
- if (g_getenv ("G_TEST_DATA"))
- srcdir = builddir = g_getenv ("G_TEST_DATA");
- else
- {
- srcdir = SRCDIR;
- builddir = BUILDDIR;
- }
-
/* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE);
diff --git a/gio/tests/gdbus-introspection.c b/gio/tests/gdbus-introspection.c
index 89e5f502b..cbba696de 100644
--- a/gio/tests/gdbus-introspection.c
+++ b/gio/tests/gdbus-introspection.c
@@ -26,8 +26,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@@ -128,7 +126,7 @@ test_introspection_parser (void)
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -308,11 +306,6 @@ main (int argc,
{
gint ret;
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index e614e057e..1f3f33042 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -62,8 +62,6 @@ static gboolean is_unix = TRUE;
static gboolean is_unix = FALSE;
#endif
-static const gchar *datapath;
-
static gchar *tmp_address = NULL;
static gchar *test_guid = NULL;
static GMutex service_loop_lock;
@@ -789,7 +787,7 @@ test_peer (void)
gsize len;
gchar *buf2;
gsize len2;
- char *testfile = g_build_filename (datapath, "file.c", NULL);
+ char *testfile = g_test_build_filename (G_TEST_DISTED, "file.c", NULL);
method_call_message = g_dbus_message_new_method_call (NULL, /* name */
"/org/gtk/GDBus/PeerTestObject",
@@ -1847,11 +1845,6 @@ main (int argc,
GDBusNodeInfo *introspection_data = NULL;
gchar *tmpdir = NULL;
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (test_interface_introspection_xml, NULL);
diff --git a/gio/tests/gdbus-proxy-well-known-name.c b/gio/tests/gdbus-proxy-well-known-name.c
index bc22537e8..db2e5cc1d 100644
--- a/gio/tests/gdbus-proxy-well-known-name.c
+++ b/gio/tests/gdbus-proxy-well-known-name.c
@@ -26,8 +26,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@@ -101,7 +99,7 @@ test_proxy_well_known_name (void)
g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL);
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -229,7 +227,7 @@ test_proxy_well_known_name (void)
* the 'y' property should be back at 1...
*/
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -267,11 +265,6 @@ main (int argc,
{
gint ret;
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c
index 202bee39a..0e510af85 100644
--- a/gio/tests/gdbus-proxy.c
+++ b/gio/tests/gdbus-proxy.c
@@ -26,8 +26,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@@ -783,7 +781,7 @@ test_proxy (void)
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -849,7 +847,7 @@ test_async (void)
NULL);
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
@@ -921,11 +919,6 @@ main (int argc,
gint ret;
GDBusNodeInfo *introspection_data = NULL;
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL);
diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c
index ceb20c174..58511144a 100644
--- a/gio/tests/gdbus-threading.c
+++ b/gio/tests/gdbus-threading.c
@@ -26,8 +26,6 @@
#include "gdbus-tests.h"
-static const gchar *binpath;
-
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
@@ -585,17 +583,12 @@ main (int argc,
gint ret;
gchar *path;
- if (g_getenv ("G_TEST_DATA"))
- binpath = g_getenv ("G_TEST_DATA");
- else
- binpath = BUILDDIR;
-
g_test_init (&argc, &argv, NULL);
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- path = g_build_filename (binpath, "gdbus-testserver", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "gdbus-testserver", NULL);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c
index ab4adf742..f00fbfad3 100644
--- a/gio/tests/gschema-compile.c
+++ b/gio/tests/gschema-compile.c
@@ -5,7 +5,6 @@
#include <gio/gio.h>
#include <gstdio.h>
-const gchar *datapath;
const gchar *glib_compile_schemas;
typedef struct {
@@ -19,7 +18,7 @@ test_schema_do_compile (gpointer data)
{
SchemaTest *test = (SchemaTest *) data;
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
- gchar *path = g_build_filename (datapath, "schema-tests", filename, NULL);
+ gchar *path = g_test_build_filename (G_TEST_DISTED, "schema-tests", filename, NULL);
gchar *argv[] = {
(gchar*)glib_compile_schemas,
"--strict",
@@ -142,11 +141,6 @@ main (int argc, char *argv[])
setlocale (LC_ALL, "");
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
if (g_getenv ("GLIB_COMPILE_SCHEMAS"))
glib_compile_schemas = g_getenv ("GLIB_COMPILE_SCHEMAS");
else
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index eb7d1b7b1..3a4edb870 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -23,8 +23,6 @@
#include "gconstructor.h"
#include "test_resources2.h"
-const gchar *datapath, *libpath;
-
static void
test_resource (GResource *resource)
{
@@ -152,7 +150,7 @@ test_resource_file (void)
g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
g_clear_error (&error);
- path = g_build_filename (datapath, "test.gresource", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
resource = g_resource_load (path, &error);
g_assert (resource != NULL);
g_assert_no_error (error);
@@ -173,7 +171,7 @@ test_resource_data (void)
GBytes *data;
gchar *path;
- path = g_build_filename (datapath, "test.gresource", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
@@ -203,7 +201,7 @@ test_resource_registered (void)
char buffer[128];
gchar *path;
- path = g_build_filename (datapath, "test.gresource", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
resource = g_resource_load (path, &error);
g_assert (resource != NULL);
g_assert_no_error (error);
@@ -408,7 +406,7 @@ test_resource_module (void)
{
char *path;
- path = g_build_filename (libpath, "libresourceplugin", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "libresourceplugin", NULL);
module = g_io_module_new (path);
g_free (path);
@@ -466,7 +464,7 @@ test_uri_query_info (void)
gchar *path;
const char *content_type;
- path = g_build_filename (datapath, "test.gresource", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
@@ -518,7 +516,7 @@ test_uri_file (void)
gssize skipped;
gchar *path;
- path = g_build_filename (datapath, "test.gresource", NULL);
+ path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
@@ -641,17 +639,6 @@ int
main (int argc,
char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- {
- datapath = g_getenv ("G_TEST_DATA");
- libpath = g_getenv ("G_TEST_DATA");
- }
- else
- {
- datapath = SRCDIR;
- libpath = ".libs";
- }
-
g_test_init (&argc, &argv, NULL);
_g_test2_register_resource ();
diff --git a/gio/tests/tls-certificate.c b/gio/tests/tls-certificate.c
index d186d9073..a6338c0f4 100644
--- a/gio/tests/tls-certificate.c
+++ b/gio/tests/tls-certificate.c
@@ -26,8 +26,6 @@
#include "gtesttlsbackend.h"
-gchar *datapath;
-
typedef struct
{
gchar *cert_pems[3];
@@ -46,7 +44,7 @@ pem_parser (const Reference *ref)
GError *error = NULL;
/* Check PEM parsing in certificate, private key order. */
- path = g_build_filename (datapath, "cert-key.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert-key.pem", NULL);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
@@ -75,7 +73,7 @@ pem_parser (const Reference *ref)
g_free (pem);
/* Check PEM parsing in private key, certificate order */
- path = g_build_filename (datapath, "key-cert.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
@@ -99,7 +97,7 @@ pem_parser (const Reference *ref)
g_object_unref (cert);
/* Check certificate only PEM */
- path = g_build_filename (datapath, "cert1.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
@@ -122,7 +120,7 @@ pem_parser (const Reference *ref)
g_object_unref (cert);
/* Check error with private key only PEM */
- path = g_build_filename (datapath, "key.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
@@ -144,7 +142,7 @@ from_file (const Reference *ref)
gchar *path;
GError *error = NULL;
- path = g_build_filename (datapath, "key-cert.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
cert = g_tls_certificate_new_from_file (path, &error);
g_assert_no_error (error);
g_assert (cert);
@@ -172,8 +170,8 @@ from_files (const Reference *ref)
gchar *path, *path2;
GError *error = NULL;
- path = g_build_filename (datapath, "cert1.pem", NULL);
- path2 = g_build_filename (datapath, "key.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
+ path2 = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
cert = g_tls_certificate_new_from_files (path, path2, &error);
g_assert_no_error (error);
g_assert (cert);
@@ -193,8 +191,8 @@ from_files (const Reference *ref)
g_object_unref (cert);
/* Missing private key */
- path = g_build_filename (datapath, "cert1.pem", NULL);
- path2 = g_build_filename (datapath, "cert2.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
+ path2 = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert2.pem", NULL);
cert = g_tls_certificate_new_from_files (path, path2, &error);
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_clear_error (&error);
@@ -203,7 +201,7 @@ from_files (const Reference *ref)
g_free (path2);
/* Missing certificate */
- path = g_build_filename (datapath, "key.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
cert = g_tls_certificate_new_from_files (path, path, &error);
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_clear_error (&error);
@@ -213,7 +211,7 @@ from_files (const Reference *ref)
/* Using this method twice with a file containing both private key and
* certificate as a way to inforce private key presence is a fair use
*/
- path = g_build_filename (datapath, "key-cert.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
cert = g_tls_certificate_new_from_files (path, path, &error);
g_assert_no_error (error);
g_assert (cert);
@@ -231,8 +229,8 @@ from_files_pkcs8 (const Reference *ref)
gchar *path, *path2;
GError *error = NULL;
- path = g_build_filename (datapath, "cert1.pem", NULL);
- path2 = g_build_filename (datapath, "key8.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
+ path2 = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key8.pem", NULL);
cert = g_tls_certificate_new_from_files (path, path2, &error);
g_assert_no_error (error);
g_assert (cert);
@@ -260,7 +258,7 @@ list_from_file (const Reference *ref)
gchar *path;
int i;
- path = g_build_filename (datapath, "cert-list.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert-list.pem", NULL);
list = g_tls_certificate_list_new_from_file (path, &error);
g_assert_no_error (error);
g_assert_cmpint (g_list_length (list), ==, 3);
@@ -282,7 +280,7 @@ list_from_file (const Reference *ref)
g_list_free_full (list, g_object_unref);
/* Empty list is not an error */
- path = g_build_filename (datapath, "nothing.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "nothing.pem", NULL);
list = g_tls_certificate_list_new_from_file (path, &error);
g_assert_no_error (error);
g_assert_cmpint (g_list_length (list), ==, 0);
@@ -298,37 +296,32 @@ main (int argc,
GError *error = NULL;
gchar *path;
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_build_filename (g_getenv ("G_TEST_DATA"), "cert-tests", NULL);
- else
- datapath = g_build_filename (SRCDIR, "cert-tests", NULL);
-
g_test_init (&argc, &argv, NULL);
_g_test_tls_backend_get_type ();
/* Load reference PEM */
- path = g_build_filename (datapath, "cert1.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[0], NULL, &error);
g_assert_no_error (error);
g_assert (ref.cert_pems[0]);
g_free (path);
- path = g_build_filename (datapath, "cert2.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert2.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[1], NULL, &error);
g_assert_no_error (error);
g_assert (ref.cert_pems[1]);
g_free (path);
- path = g_build_filename (datapath, "cert3.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert3.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[2], NULL, &error);
g_assert_no_error (error);
g_assert (ref.cert_pems[2]);
g_free (path);
- path = g_build_filename (datapath, "key.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
g_file_get_contents (path, &ref.key_pem, NULL, &error);
g_assert_no_error (error);
g_assert (ref.key_pem);
g_free (path);
- path = g_build_filename (datapath, "key8.pem", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key8.pem", NULL);
g_file_get_contents (path, &ref.key8_pem, NULL, &error);
g_assert_no_error (error);
g_assert (ref.key8_pem);
diff --git a/glib/tests/bookmarkfile.c b/glib/tests/bookmarkfile.c
index 22df6a9c9..90a4b714a 100644
--- a/glib/tests/bookmarkfile.c
+++ b/glib/tests/bookmarkfile.c
@@ -268,7 +268,6 @@ main (int argc, char *argv[])
GError *error;
const gchar *name;
gchar *path;
- const gchar *datapath;
g_test_init (&argc, &argv, NULL);
@@ -279,18 +278,14 @@ main (int argc, char *argv[])
}
error = NULL;
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
- path = g_build_filename (datapath, "bookmarks", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "bookmarks", NULL);
dir = g_dir_open (path, 0, &error);
g_free (path);
g_assert_no_error (error);
while ((name = g_dir_read_name (dir)) != NULL)
{
path = g_strdup_printf ("/bookmarks/parse/%s", name);
- g_test_add_data_func_full (path, g_build_filename (datapath, "bookmarks", name, NULL),
+ g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DISTED, "bookmarks", name, NULL),
test_file, g_free);
g_free (path);
}
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
index d37a9a010..a0df824ab 100644
--- a/glib/tests/keyfile.c
+++ b/glib/tests/keyfile.c
@@ -3,8 +3,6 @@
#include <string.h>
#include <stdlib.h>
-static const gchar *datapath;
-
static GKeyFile *
load_data (const gchar *data,
GKeyFileFlags flags)
@@ -1343,7 +1341,7 @@ test_load_fail (void)
file = g_key_file_new ();
error = NULL;
- path = g_build_filename (datapath, "keyfile.c", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "keyfile.c", NULL);
g_assert (!g_key_file_load_from_file (file, path, 0, &error));
g_free (path);
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE);
@@ -1413,7 +1411,7 @@ test_page_boundary (void)
file = g_key_file_new ();
error = NULL;
- path = g_build_filename (datapath, "pages.ini", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "pages.ini", NULL);
g_key_file_load_from_file (file, path, G_KEY_FILE_NONE, &error);
g_free (path);
g_assert_no_error (error);
@@ -1577,16 +1575,12 @@ test_roundtrip (void)
int
main (int argc, char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
+ g_test_init (&argc, &argv, NULL);
#ifdef G_OS_UNIX
- g_setenv ("XDG_DATA_HOME", datapath, TRUE);
+ g_setenv ("XDG_DATA_HOME", g_test_build_filename (G_TEST_DISTED, ".", NULL), TRUE);
#endif
- g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
g_test_add_func ("/keyfile/line-ends", test_line_ends);
diff --git a/glib/tests/mappedfile.c b/glib/tests/mappedfile.c
index f366ee9a7..7984da3b6 100644
--- a/glib/tests/mappedfile.c
+++ b/glib/tests/mappedfile.c
@@ -11,8 +11,6 @@
#include <sys/types.h>
#include <fcntl.h>
-static const gchar *datapath;
-
static void
test_basic (void)
{
@@ -21,7 +19,7 @@ test_basic (void)
gchar *path;
error = NULL;
- path = g_build_filename (datapath, "empty", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
@@ -40,7 +38,7 @@ test_empty (void)
gchar *path;
error = NULL;
- path = g_build_filename (datapath, "empty", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
@@ -90,7 +88,7 @@ test_writable (void)
char *srcpath;
gchar *tmp_copy_path;
- srcpath = g_build_filename (datapath, "4096-random-bytes", NULL);
+ srcpath = g_test_build_filename (G_TEST_DISTED, "4096-random-bytes", NULL);
tmp_copy_path = g_build_filename (g_get_user_runtime_dir (), "glib-test-4096-random-bytes", NULL);
g_file_get_contents (srcpath, &contents, &len, &error);
@@ -137,7 +135,7 @@ test_writable_fd (void)
char *srcpath;
gchar *tmp_copy_path;
- srcpath = g_build_filename (datapath, "4096-random-bytes", NULL);
+ srcpath = g_test_build_filename (G_TEST_DISTED, "4096-random-bytes", NULL);
tmp_copy_path = g_build_filename (g_get_user_runtime_dir (), "glib-test-4096-random-bytes", NULL);
g_file_get_contents (srcpath, &contents, &len, &error);
@@ -185,7 +183,7 @@ test_gbytes (void)
gchar *path;
error = NULL;
- path = g_build_filename (datapath, "empty", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
@@ -200,11 +198,6 @@ test_gbytes (void)
int
main (int argc, char *argv[])
{
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mappedfile/basic", test_basic);
diff --git a/glib/tests/markup-parse.c b/glib/tests/markup-parse.c
index e2c8e9a86..722a04961 100644
--- a/glib/tests/markup-parse.c
+++ b/glib/tests/markup-parse.c
@@ -8,7 +8,6 @@
static int depth = 0;
static GString *string;
-static const gchar *datapath;
static void
indent (int extra)
@@ -278,11 +277,6 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- if (g_getenv ("G_TEST_DATA"))
- datapath = g_getenv ("G_TEST_DATA");
- else
- datapath = SRCDIR;
-
g_setenv ("LANG", "en_US.utf-8", TRUE);
setlocale (LC_ALL, "");
@@ -298,7 +292,7 @@ main (int argc, char *argv[])
}
error = NULL;
- path = g_build_filename (datapath, "markups", NULL);
+ path = g_test_build_filename (G_TEST_DISTED, "markups", NULL);
dir = g_dir_open (path, 0, &error);
g_free (path);
g_assert_no_error (error);
@@ -308,7 +302,7 @@ main (int argc, char *argv[])
continue;
path = g_strdup_printf ("/markup/parse/%s", name);
- g_test_add_data_func_full (path, g_build_filename (datapath, "markups", name, NULL),
+ g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DISTED, "markups", name, NULL),
test_parse, g_free);
g_free (path);
}