Port most of the tests to the new g_test_build_filename() API.
https://bugzilla.gnome.org/show_bug.cgi?id=549783
19 files changed:
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
-static const gchar *datapath;
static const gchar *test_file;
char *test_file_buffer;
static const gchar *test_file;
char *test_file_buffer;
GError *error = NULL;
int ret;
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);
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);
g_file_get_contents (test_file, &test_file_buffer,
&test_file_size, &error);
g_assert_no_error (error);
#include <sys/stat.h>
#endif
#include <sys/stat.h>
#endif
-static const gchar *datapath;
-
static void
test_basic (void)
{
static void
test_basic (void)
{
GFile *file;
GFileType type;
GError *error = NULL;
GFile *file;
GFileType type;
GError *error = NULL;
+ datapath = g_test_build_filename (G_TEST_DISTED, ".", NULL);
datapath_f = g_file_new_for_path (datapath);
datapath_f = g_file_new_for_path (datapath);
file = g_file_get_child (datapath_f, "g-icon.c");
type = g_file_query_file_type (file, 0, NULL);
file = g_file_get_child (datapath_f, "g-icon.c");
type = g_file_query_file_type (file, 0, NULL);
int
main (int argc, char *argv[])
{
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/");
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
-static const gchar *datapath;
-
static void
test_g_icon_to_string (void)
{
static void
test_g_icon_to_string (void)
{
- 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);
file = g_file_new_for_path (path);
icon = g_file_icon_new (file);
main (int argc,
char *argv[])
{
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);
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/icons/to-string", test_g_icon_to_string);
#include "gdbus-tests.h"
#include "gdbus-sessionbus.h"
#include "gdbus-tests.h"
#include "gdbus-sessionbus.h"
-static const gchar *datapath;
-static const gchar *binpath;
-
static gint outstanding_watches;
static GMainLoop *main_loop;
static gint outstanding_watches;
static GMainLoop *main_loop;
va_start (ap, first_arg);
array = g_ptr_array_new ();
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);
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);
static void
test_nodbus (void)
{
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;
gchar *argv[] = { binpath, NULL };
GApplication *app;
static void
test_noappid (void)
{
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;
gchar *argv[] = { binpath, NULL };
GApplication *app;
test_quit (void)
{
GDBusConnection *c;
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;
gchar *argv[] = { binpath, NULL };
GApplication *app;
static void
test_actions (void)
{
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;
gchar *argv[] = { binpath, NULL };
GApplication *app;
static void
test_local_command_line (void)
{
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;
gchar *argv[] = { binpath, "-invalid", NULL };
GApplication *app;
int
main (int argc, char **argv)
{
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 ();
g_test_init (&argc, &argv, NULL);
g_test_dbus_unset ();
-static const gchar *binpath;
-
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
- 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 */
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
gchar *path;
error = NULL;
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 */
ret = g_spawn_command_line_sync (path,
NULL, /* stdout */
NULL, /* stderr */
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
main (int argc,
char *argv[])
{
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 */
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
-const gchar *srcdir;
-const gchar *builddir;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
g_assert_cmpint (data.num_outgoing, ==, 4);
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
{
g_test_init (&argc, &argv, NULL);
{
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);
/* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE);
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (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 */
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
static gboolean is_unix = FALSE;
#endif
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;
static gchar *tmp_address = NULL;
static gchar *test_guid = NULL;
static GMutex service_loop_lock;
gsize len;
gchar *buf2;
gsize len2;
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",
method_call_message = g_dbus_message_new_method_call (NULL, /* name */
"/org/gtk/GDBus/PeerTestObject",
GDBusNodeInfo *introspection_data = NULL;
gchar *tmpdir = NULL;
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);
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (test_interface_introspection_xml, NULL);
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL);
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
* the 'y' property should be back at 1...
*/
/* this is safe; testserver will exit once the bus goes away */
* 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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (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 */
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
-static const gchar *binpath;
-
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
NULL);
/* this is safe; testserver will exit once the bus goes away */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
gint ret;
GDBusNodeInfo *introspection_data = NULL;
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);
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL);
-static const gchar *binpath;
-
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
- 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 */
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);
g_assert (g_spawn_command_line_async (path, NULL));
g_free (path);
#include <gio/gio.h>
#include <gstdio.h>
#include <gio/gio.h>
#include <gstdio.h>
const gchar *glib_compile_schemas;
typedef struct {
const gchar *glib_compile_schemas;
typedef struct {
{
SchemaTest *test = (SchemaTest *) data;
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
{
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",
gchar *argv[] = {
(gchar*)glib_compile_schemas,
"--strict",
- 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
if (g_getenv ("GLIB_COMPILE_SCHEMAS"))
glib_compile_schemas = g_getenv ("GLIB_COMPILE_SCHEMAS");
else
#include "gconstructor.h"
#include "test_resources2.h"
#include "gconstructor.h"
#include "test_resources2.h"
-const gchar *datapath, *libpath;
-
static void
test_resource (GResource *resource)
{
static void
test_resource (GResource *resource)
{
g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
g_clear_error (&error);
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);
resource = g_resource_load (path, &error);
g_assert (resource != NULL);
g_assert_no_error (error);
GBytes *data;
gchar *path;
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);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
char buffer[128];
gchar *path;
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);
resource = g_resource_load (path, &error);
g_assert (resource != NULL);
g_assert_no_error (error);
- 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);
module = g_io_module_new (path);
g_free (path);
gchar *path;
const char *content_type;
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);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
gssize skipped;
gchar *path;
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);
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
g_assert (loaded_file);
g_free (path);
main (int argc,
char *argv[])
{
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 ();
g_test_init (&argc, &argv, NULL);
_g_test2_register_resource ();
#include "gtesttlsbackend.h"
#include "gtesttlsbackend.h"
typedef struct
{
gchar *cert_pems[3];
typedef struct
{
gchar *cert_pems[3];
GError *error = NULL;
/* Check PEM parsing in certificate, private key order. */
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);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
g_free (pem);
/* Check PEM parsing in private key, certificate order */
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);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
g_object_unref (cert);
/* Check certificate only PEM */
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);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
g_object_unref (cert);
/* Check error with private key only PEM */
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);
g_file_get_contents (path, &pem, NULL, &error);
g_assert_no_error (error);
g_assert (pem);
gchar *path;
GError *error = NULL;
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);
cert = g_tls_certificate_new_from_file (path, &error);
g_assert_no_error (error);
g_assert (cert);
gchar *path, *path2;
GError *error = NULL;
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);
cert = g_tls_certificate_new_from_files (path, path2, &error);
g_assert_no_error (error);
g_assert (cert);
g_object_unref (cert);
/* Missing private key */
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);
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);
g_free (path2);
/* Missing certificate */
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);
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);
/* 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
*/
/* 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);
cert = g_tls_certificate_new_from_files (path, path, &error);
g_assert_no_error (error);
g_assert (cert);
gchar *path, *path2;
GError *error = NULL;
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);
cert = g_tls_certificate_new_from_files (path, path2, &error);
g_assert_no_error (error);
g_assert (cert);
- 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);
list = g_tls_certificate_list_new_from_file (path, &error);
g_assert_no_error (error);
g_assert_cmpint (g_list_length (list), ==, 3);
g_list_free_full (list, g_object_unref);
/* Empty list is not an error */
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);
list = g_tls_certificate_list_new_from_file (path, &error);
g_assert_no_error (error);
g_assert_cmpint (g_list_length (list), ==, 0);
GError *error = NULL;
gchar *path;
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 */
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);
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);
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);
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);
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);
g_file_get_contents (path, &ref.key8_pem, NULL, &error);
g_assert_no_error (error);
g_assert (ref.key8_pem);
GError *error;
const gchar *name;
gchar *path;
GError *error;
const gchar *name;
gchar *path;
g_test_init (&argc, &argv, NULL);
g_test_init (&argc, &argv, 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);
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);
}
test_file, g_free);
g_free (path);
}
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
-static const gchar *datapath;
-
static GKeyFile *
load_data (const gchar *data,
GKeyFileFlags flags)
static GKeyFile *
load_data (const gchar *data,
GKeyFileFlags flags)
file = g_key_file_new ();
error = NULL;
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);
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);
file = g_key_file_new ();
error = NULL;
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);
g_key_file_load_from_file (file, path, G_KEY_FILE_NONE, &error);
g_free (path);
g_assert_no_error (error);
int
main (int argc, char *argv[])
{
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_setenv ("XDG_DATA_HOME", datapath, TRUE);
+ g_setenv ("XDG_DATA_HOME", g_test_build_filename (G_TEST_DISTED, ".", NULL), TRUE);
- g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
g_test_add_func ("/keyfile/line-ends", test_line_ends);
g_test_bug_base ("http://bugzilla.gnome.org/");
g_test_add_func ("/keyfile/line-ends", test_line_ends);
#include <sys/types.h>
#include <fcntl.h>
#include <sys/types.h>
#include <fcntl.h>
-static const gchar *datapath;
-
static void
test_basic (void)
{
static void
test_basic (void)
{
gchar *path;
error = NULL;
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);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
gchar *path;
error = NULL;
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);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
char *srcpath;
gchar *tmp_copy_path;
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);
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);
char *srcpath;
gchar *tmp_copy_path;
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);
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);
gchar *path;
error = NULL;
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);
file = g_mapped_file_new (path, FALSE, &error);
g_free (path);
g_assert_no_error (error);
int
main (int argc, char *argv[])
{
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);
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mappedfile/basic", test_basic);
static int depth = 0;
static GString *string;
static int depth = 0;
static GString *string;
-static const gchar *datapath;
static void
indent (int extra)
static void
indent (int extra)
const gchar *name;
gchar *path;
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, "");
g_setenv ("LANG", "en_US.utf-8", TRUE);
setlocale (LC_ALL, "");
- 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);
dir = g_dir_open (path, 0, &error);
g_free (path);
g_assert_no_error (error);
continue;
path = g_strdup_printf ("/markup/parse/%s", name);
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);
}
test_parse, g_free);
g_free (path);
}