mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
tests: move tests to new _get_filename() API
This API was introduced to save a few lines of code here and there, so let's start by removing a bunch from our own tests. https://bugzilla.gnome.org/show_bug.cgi?id=549783
This commit is contained in:
parent
575a9da718
commit
17ded322c5
@ -83,11 +83,8 @@ 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);
|
||||
datapath_f = g_file_new_for_path (g_test_get_dir (G_TEST_DISTED));
|
||||
|
||||
file = g_file_get_child (datapath_f, "g-icon.c");
|
||||
type = g_file_query_file_type (file, 0, NULL);
|
||||
|
@ -465,11 +465,8 @@ test_file_icon (void)
|
||||
GError *error;
|
||||
GInputStream *stream;
|
||||
gchar *str;
|
||||
gchar *path;
|
||||
|
||||
path = g_test_build_filename (G_TEST_DISTED, "g-icon.c", NULL);
|
||||
|
||||
file = g_file_new_for_path (path);
|
||||
file = g_file_new_for_path (g_test_get_filename (G_TEST_DISTED, "g-icon.c", NULL));
|
||||
icon = g_file_icon_new (file);
|
||||
g_object_unref (file);
|
||||
|
||||
@ -487,8 +484,6 @@ test_file_icon (void)
|
||||
|
||||
g_object_unref (icon);
|
||||
g_object_unref (icon2);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -61,6 +61,7 @@ test_connection_flush (void)
|
||||
GError *error;
|
||||
guint n;
|
||||
guint signal_handler_id;
|
||||
const gchar *flush_helper;
|
||||
|
||||
session_bus_up ();
|
||||
|
||||
@ -81,16 +82,15 @@ test_connection_flush (void)
|
||||
NULL);
|
||||
g_assert_cmpint (signal_handler_id, !=, 0);
|
||||
|
||||
flush_helper = g_test_get_filename (G_TEST_BUILT, "gdbus-connection-flush-helper", NULL);
|
||||
for (n = 0; n < 50; n++)
|
||||
{
|
||||
gboolean ret;
|
||||
gint exit_status;
|
||||
guint timeout_mainloop_id;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
path = g_test_build_filename (G_TEST_BUILT, "gdbus-connection-flush-helper", NULL);
|
||||
ret = g_spawn_command_line_sync (path,
|
||||
ret = g_spawn_command_line_sync (flush_helper,
|
||||
NULL, /* stdout */
|
||||
NULL, /* stderr */
|
||||
&exit_status,
|
||||
@ -99,7 +99,6 @@ test_connection_flush (void)
|
||||
g_spawn_check_exit_status (exit_status, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
g_free (path);
|
||||
|
||||
timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n));
|
||||
g_main_loop_run (loop);
|
||||
@ -186,15 +185,12 @@ static void
|
||||
test_connection_large_message (void)
|
||||
{
|
||||
guint watcher_id;
|
||||
gchar *path;
|
||||
guint timeout_id;
|
||||
|
||||
session_bus_up ();
|
||||
|
||||
/* this is safe; testserver will exit once the bus goes away */
|
||||
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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
timeout_id = g_timeout_add_seconds (LARGE_MESSAGE_TIMEOUT_SECONDS,
|
||||
large_message_timeout_cb,
|
||||
|
@ -919,7 +919,6 @@ test_connection_filter (void)
|
||||
FilterEffects effects;
|
||||
GVariant *result;
|
||||
const gchar *s;
|
||||
gchar *path;
|
||||
|
||||
memset (&data, '\0', sizeof (FilterData));
|
||||
|
||||
@ -1002,9 +1001,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_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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
/* wait for service to be available */
|
||||
signal_handler_id = g_dbus_connection_signal_subscribe (c,
|
||||
|
@ -107,7 +107,6 @@ test_introspection_parser (void)
|
||||
GDBusProxy *proxy;
|
||||
GDBusConnection *connection;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
|
||||
@ -126,9 +125,7 @@ test_introspection_parser (void)
|
||||
g_assert_no_error (error);
|
||||
|
||||
/* this is safe; testserver will exit once the bus goes away */
|
||||
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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
_g_assert_property_notify (proxy, "g-name-owner");
|
||||
|
||||
|
@ -787,7 +787,7 @@ test_peer (void)
|
||||
gsize len;
|
||||
gchar *buf2;
|
||||
gsize len2;
|
||||
char *testfile = g_test_build_filename (G_TEST_DISTED, "file.c", NULL);
|
||||
const char *testfile = g_test_get_filename (G_TEST_DISTED, "file.c", NULL);
|
||||
|
||||
method_call_message = g_dbus_message_new_method_call (NULL, /* name */
|
||||
"/org/gtk/GDBus/PeerTestObject",
|
||||
@ -830,7 +830,6 @@ test_peer (void)
|
||||
g_assert (memcmp (buf, buf2, len) == 0);
|
||||
g_free (buf2);
|
||||
g_free (buf);
|
||||
g_free (testfile);
|
||||
}
|
||||
#else
|
||||
error = NULL;
|
||||
|
@ -60,7 +60,6 @@ test_proxy_well_known_name (void)
|
||||
gchar **property_names;
|
||||
GVariant *variant;
|
||||
GVariant *result;
|
||||
gchar *path;
|
||||
|
||||
session_bus_up ();
|
||||
|
||||
@ -99,9 +98,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_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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
/* check that we get the notify::g-name-owner signal */
|
||||
_g_assert_property_notify (p, "g-name-owner");
|
||||
@ -227,9 +224,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_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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
/* check that we get the notify::g-name-owner signal */
|
||||
_g_assert_property_notify (p, "g-name-owner");
|
||||
|
@ -762,7 +762,6 @@ test_proxy (void)
|
||||
GDBusProxy *proxy;
|
||||
GDBusConnection *connection;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
|
||||
@ -781,9 +780,7 @@ test_proxy (void)
|
||||
g_assert_no_error (error);
|
||||
|
||||
/* this is safe; testserver will exit once the bus goes away */
|
||||
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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
_g_assert_property_notify (proxy, "g-name-owner");
|
||||
|
||||
@ -834,8 +831,6 @@ fail_test (gpointer user_data)
|
||||
static void
|
||||
test_async (void)
|
||||
{
|
||||
gchar *path;
|
||||
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL, /* GDBusInterfaceInfo */
|
||||
@ -847,9 +842,7 @@ test_async (void)
|
||||
NULL);
|
||||
|
||||
/* this is safe; testserver will exit once the bus goes away */
|
||||
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 (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
|
||||
|
||||
g_timeout_add (10000, fail_test, NULL);
|
||||
g_main_loop_run (loop);
|
||||
|
@ -143,18 +143,15 @@ test_resource_file (void)
|
||||
{
|
||||
GResource *resource;
|
||||
GError *error = NULL;
|
||||
gchar *path;
|
||||
|
||||
resource = g_resource_load ("not-there", &error);
|
||||
g_assert (resource == NULL);
|
||||
g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
|
||||
g_clear_error (&error);
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
|
||||
resource = g_resource_load (path, &error);
|
||||
resource = g_resource_load (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL), &error);
|
||||
g_assert (resource != NULL);
|
||||
g_assert_no_error (error);
|
||||
g_free (path);
|
||||
|
||||
test_resource (resource);
|
||||
g_resource_unref (resource);
|
||||
@ -169,12 +166,10 @@ test_resource_data (void)
|
||||
char *content;
|
||||
gsize content_size;
|
||||
GBytes *data;
|
||||
gchar *path;
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
|
||||
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
|
||||
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
||||
&content, &content_size, NULL);
|
||||
g_assert (loaded_file);
|
||||
g_free (path);
|
||||
|
||||
data = g_bytes_new_take (content, content_size);
|
||||
resource = g_resource_new_from_data (data, &error);
|
||||
@ -199,13 +194,10 @@ test_resource_registered (void)
|
||||
char **children;
|
||||
GInputStream *in;
|
||||
char buffer[128];
|
||||
gchar *path;
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
|
||||
resource = g_resource_load (path, &error);
|
||||
resource = g_resource_load (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL), &error);
|
||||
g_assert (resource != NULL);
|
||||
g_assert_no_error (error);
|
||||
g_free (path);
|
||||
|
||||
found = g_resources_get_info ("/test1.txt",
|
||||
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||
@ -404,11 +396,8 @@ test_resource_module (void)
|
||||
|
||||
if (g_module_supported ())
|
||||
{
|
||||
char *path;
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "libresourceplugin", NULL);
|
||||
module = g_io_module_new (path);
|
||||
g_free (path);
|
||||
/* For in-tree, this will find the .la file and use it to get to the .so in .libs/ */
|
||||
module = g_io_module_new (g_test_get_filename (G_TEST_BUILT, "libresourceplugin", NULL));
|
||||
|
||||
error = NULL;
|
||||
|
||||
@ -461,13 +450,11 @@ test_uri_query_info (void)
|
||||
GBytes *data;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
gchar *path;
|
||||
const char *content_type;
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
|
||||
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
|
||||
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
||||
&content, &content_size, NULL);
|
||||
g_assert (loaded_file);
|
||||
g_free (path);
|
||||
|
||||
data = g_bytes_new_take (content, content_size);
|
||||
resource = g_resource_new_from_data (data, &error);
|
||||
@ -514,12 +501,10 @@ test_uri_file (void)
|
||||
gchar buf[1024];
|
||||
gboolean ret;
|
||||
gssize skipped;
|
||||
gchar *path;
|
||||
|
||||
path = g_test_build_filename (G_TEST_BUILT, "test.gresource", NULL);
|
||||
loaded_file = g_file_get_contents (path, &content, &content_size, NULL);
|
||||
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
||||
&content, &content_size, NULL);
|
||||
g_assert (loaded_file);
|
||||
g_free (path);
|
||||
|
||||
data = g_bytes_new_take (content, content_size);
|
||||
resource = g_resource_new_from_data (data, &error);
|
||||
|
@ -40,15 +40,12 @@ pem_parser (const Reference *ref)
|
||||
gchar *pem;
|
||||
gchar *parsed_cert_pem = NULL;
|
||||
const gchar *parsed_key_pem = NULL;
|
||||
gchar *path;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Check PEM parsing in certificate, private key order. */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert-key.pem", NULL);
|
||||
g_file_get_contents (path, &pem, NULL, &error);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert-key.pem", NULL), &pem, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (pem);
|
||||
g_free (path);
|
||||
|
||||
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -73,11 +70,9 @@ pem_parser (const Reference *ref)
|
||||
g_free (pem);
|
||||
|
||||
/* Check PEM parsing in private key, certificate order */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
|
||||
g_file_get_contents (path, &pem, NULL, &error);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL), &pem, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (pem);
|
||||
g_free (path);
|
||||
|
||||
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -97,11 +92,9 @@ pem_parser (const Reference *ref)
|
||||
g_object_unref (cert);
|
||||
|
||||
/* Check certificate only PEM */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL);
|
||||
g_file_get_contents (path, &pem, NULL, &error);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL), &pem, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (pem);
|
||||
g_free (path);
|
||||
|
||||
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -120,11 +113,9 @@ pem_parser (const Reference *ref)
|
||||
g_object_unref (cert);
|
||||
|
||||
/* Check error with private key only PEM */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
|
||||
g_file_get_contents (path, &pem, NULL, &error);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL), &pem, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (pem);
|
||||
g_free (path);
|
||||
|
||||
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
|
||||
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
|
||||
@ -139,14 +130,12 @@ from_file (const Reference *ref)
|
||||
GTlsCertificate *cert;
|
||||
gchar *parsed_cert_pem = NULL;
|
||||
const gchar *parsed_key_pem = NULL;
|
||||
gchar *path;
|
||||
GError *error = NULL;
|
||||
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
|
||||
cert = g_tls_certificate_new_from_file (path, &error);
|
||||
cert = g_tls_certificate_new_from_file (g_test_get_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (cert);
|
||||
g_free (path);
|
||||
|
||||
g_object_get (cert,
|
||||
"certificate-pem", &parsed_cert_pem,
|
||||
@ -167,16 +156,13 @@ from_files (const Reference *ref)
|
||||
GTlsCertificate *cert;
|
||||
gchar *parsed_cert_pem = NULL;
|
||||
const gchar *parsed_key_pem = NULL;
|
||||
gchar *path, *path2;
|
||||
GError *error = 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);
|
||||
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL),
|
||||
g_test_get_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (cert);
|
||||
g_free (path);
|
||||
g_free (path2);
|
||||
|
||||
g_object_get (cert,
|
||||
"certificate-pem", &parsed_cert_pem,
|
||||
@ -191,32 +177,30 @@ from_files (const Reference *ref)
|
||||
g_object_unref (cert);
|
||||
|
||||
/* Missing private key */
|
||||
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);
|
||||
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL),
|
||||
g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert2.pem", NULL),
|
||||
&error);
|
||||
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
|
||||
g_clear_error (&error);
|
||||
g_assert (cert == NULL);
|
||||
g_free (path);
|
||||
g_free (path2);
|
||||
|
||||
/* Missing certificate */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL);
|
||||
cert = g_tls_certificate_new_from_files (path, path, &error);
|
||||
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL),
|
||||
g_test_get_filename (G_TEST_DISTED, "cert-tests", "key.pem", NULL),
|
||||
&error);
|
||||
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
|
||||
g_clear_error (&error);
|
||||
g_assert (cert == NULL);
|
||||
g_free (path);
|
||||
|
||||
/* 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_test_build_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL);
|
||||
cert = g_tls_certificate_new_from_files (path, path, &error);
|
||||
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL),
|
||||
g_test_get_filename (G_TEST_DISTED, "cert-tests", "key-cert.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (cert);
|
||||
g_object_unref (cert);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
|
||||
@ -226,16 +210,13 @@ from_files_pkcs8 (const Reference *ref)
|
||||
GTlsCertificate *cert;
|
||||
gchar *parsed_cert_pem = NULL;
|
||||
const gchar *parsed_key_pem = NULL;
|
||||
gchar *path, *path2;
|
||||
GError *error = 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);
|
||||
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert1.pem", NULL),
|
||||
g_test_get_filename (G_TEST_DISTED, "cert-tests", "key8.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (cert);
|
||||
g_free (path);
|
||||
g_free (path2);
|
||||
|
||||
g_object_get (cert,
|
||||
"certificate-pem", &parsed_cert_pem,
|
||||
@ -255,14 +236,12 @@ list_from_file (const Reference *ref)
|
||||
{
|
||||
GList *list, *l;
|
||||
GError *error = NULL;
|
||||
gchar *path;
|
||||
int i;
|
||||
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "cert-list.pem", NULL);
|
||||
list = g_tls_certificate_list_new_from_file (path, &error);
|
||||
list = g_tls_certificate_list_new_from_file (g_test_get_filename (G_TEST_DISTED, "cert-tests", "cert-list.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (g_list_length (list), ==, 3);
|
||||
g_free (path);
|
||||
|
||||
l = list;
|
||||
for (i = 0; i < 3; i++)
|
||||
@ -280,11 +259,10 @@ list_from_file (const Reference *ref)
|
||||
g_list_free_full (list, g_object_unref);
|
||||
|
||||
/* Empty list is not an error */
|
||||
path = g_test_build_filename (G_TEST_DISTED, "cert-tests", "nothing.pem", NULL);
|
||||
list = g_tls_certificate_list_new_from_file (path, &error);
|
||||
list = g_tls_certificate_list_new_from_file (g_test_get_filename (G_TEST_DISTED, "cert-tests", "nothing.pem", NULL),
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (g_list_length (list), ==, 0);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1337,13 +1337,10 @@ test_load_fail (void)
|
||||
{
|
||||
GKeyFile *file;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
file = g_key_file_new ();
|
||||
error = 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 (!g_key_file_load_from_file (file, g_test_get_filename (G_TEST_DISTED, "keyfile.c", NULL), 0, &error));
|
||||
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE);
|
||||
g_clear_error (&error);
|
||||
g_assert (!g_key_file_load_from_file (file, "/nosuchfile", 0, &error));
|
||||
@ -1398,7 +1395,6 @@ test_page_boundary (void)
|
||||
GKeyFile *file;
|
||||
GError *error;
|
||||
gint i;
|
||||
gchar *path;
|
||||
|
||||
#define GROUP "main_section"
|
||||
#define KEY_PREFIX "fill_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw_"
|
||||
@ -1411,9 +1407,7 @@ test_page_boundary (void)
|
||||
file = g_key_file_new ();
|
||||
|
||||
error = 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_key_file_load_from_file (file, g_test_get_filename (G_TEST_DISTED, "pages.ini", NULL), G_KEY_FILE_NONE, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
for (i = FIRST_KEY; i <= LAST_KEY; i++)
|
||||
@ -1578,7 +1572,7 @@ main (int argc, char *argv[])
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
g_setenv ("XDG_DATA_HOME", g_test_build_filename (G_TEST_DISTED, ".", NULL), TRUE);
|
||||
g_setenv ("XDG_DATA_HOME", g_test_get_dir (G_TEST_DISTED), TRUE);
|
||||
#endif
|
||||
|
||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||
|
@ -16,12 +16,9 @@ test_basic (void)
|
||||
{
|
||||
GMappedFile *file;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
|
||||
file = g_mapped_file_new (path, FALSE, &error);
|
||||
g_free (path);
|
||||
file = g_mapped_file_new (g_test_get_filename (G_TEST_DISTED, "empty", NULL), FALSE, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_mapped_file_ref (file);
|
||||
@ -35,12 +32,9 @@ test_empty (void)
|
||||
{
|
||||
GMappedFile *file;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
|
||||
file = g_mapped_file_new (path, FALSE, &error);
|
||||
g_free (path);
|
||||
file = g_mapped_file_new (g_test_get_filename (G_TEST_DISTED, "empty", NULL), FALSE, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert (g_mapped_file_get_contents (file) == NULL);
|
||||
@ -85,13 +79,11 @@ test_writable (void)
|
||||
gsize len;
|
||||
const gchar *old = "MMMMMMMMMMMMMMMMMMMMMMMMM";
|
||||
const gchar *new = "abcdefghijklmnopqrstuvxyz";
|
||||
char *srcpath;
|
||||
gchar *tmp_copy_path;
|
||||
|
||||
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);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "4096-random-bytes", NULL), &contents, &len, &error);
|
||||
g_assert_no_error (error);
|
||||
g_file_set_contents (tmp_copy_path, contents, len, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -118,7 +110,6 @@ test_writable (void)
|
||||
|
||||
g_mapped_file_free (file);
|
||||
|
||||
g_free (srcpath);
|
||||
g_free (tmp_copy_path);
|
||||
}
|
||||
|
||||
@ -132,13 +123,11 @@ test_writable_fd (void)
|
||||
const gchar *new = "abcdefghijklmnopqrstuvxyz";
|
||||
gsize len;
|
||||
int fd;
|
||||
char *srcpath;
|
||||
gchar *tmp_copy_path;
|
||||
|
||||
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);
|
||||
g_file_get_contents (g_test_get_filename (G_TEST_DISTED, "4096-random-bytes", NULL), &contents, &len, &error);
|
||||
g_assert_no_error (error);
|
||||
g_file_set_contents (tmp_copy_path, contents, len, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -170,7 +159,6 @@ test_writable_fd (void)
|
||||
|
||||
g_mapped_file_free (file);
|
||||
|
||||
g_free (srcpath);
|
||||
g_free (tmp_copy_path);
|
||||
}
|
||||
|
||||
@ -180,12 +168,9 @@ test_gbytes (void)
|
||||
GMappedFile *file;
|
||||
GBytes *bytes;
|
||||
GError *error;
|
||||
gchar *path;
|
||||
|
||||
error = NULL;
|
||||
path = g_test_build_filename (G_TEST_DISTED, "empty", NULL);
|
||||
file = g_mapped_file_new (path, FALSE, &error);
|
||||
g_free (path);
|
||||
file = g_mapped_file_new (g_test_get_filename (G_TEST_DISTED, "empty", NULL), FALSE, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
bytes = g_mapped_file_get_bytes (file);
|
||||
|
Loading…
Reference in New Issue
Block a user