mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-08 18:24:04 +02:00
@@ -38,6 +38,8 @@ test_launch (void)
|
|||||||
g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error));
|
g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error));
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_list_free (l);
|
g_list_free (l);
|
||||||
|
|
||||||
|
g_object_unref (appinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -119,6 +119,9 @@ test1_thread (gpointer user_data)
|
|||||||
g_cond_signal (&test1_cond);
|
g_cond_signal (&test1_cond);
|
||||||
g_mutex_unlock (&test1_mutex);
|
g_mutex_unlock (&test1_mutex);
|
||||||
|
|
||||||
|
g_main_context_pop_thread_default (context);
|
||||||
|
g_main_context_unref (context);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +167,9 @@ test_context_independence (void)
|
|||||||
g_source_remove (default_timeout);
|
g_source_remove (default_timeout);
|
||||||
g_source_destroy (thread_default_timeout);
|
g_source_destroy (thread_default_timeout);
|
||||||
g_source_unref (thread_default_timeout);
|
g_source_unref (thread_default_timeout);
|
||||||
|
|
||||||
|
g_main_context_pop_thread_default (context);
|
||||||
|
g_main_context_unref (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -177,6 +183,7 @@ int
|
|||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
@@ -188,5 +195,9 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/gio/contexts/thread-independence", test_thread_independence);
|
g_test_add_func ("/gio/contexts/thread-independence", test_thread_independence);
|
||||||
g_test_add_func ("/gio/contexts/context-independence", test_context_independence);
|
g_test_add_func ("/gio/contexts/context-independence", test_context_independence);
|
||||||
|
|
||||||
return g_test_run();
|
ret = g_test_run();
|
||||||
|
|
||||||
|
g_free (test_file_buffer);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1138,6 +1138,7 @@ test_truncation (gconstpointer data)
|
|||||||
|
|
||||||
g_output_stream_splice (ostream2, cistream1, 0, NULL, &error);
|
g_output_stream_splice (ostream2, cistream1, 0, NULL, &error);
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT);
|
||||||
|
g_error_free (error);
|
||||||
|
|
||||||
g_object_unref (istream1);
|
g_object_unref (istream1);
|
||||||
g_object_unref (decompressor);
|
g_object_unref (decompressor);
|
||||||
|
@@ -122,8 +122,11 @@ monitor_changed (GFileMonitor *monitor,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CreateDeleteData *data = user_data;
|
CreateDeleteData *data = user_data;
|
||||||
|
gchar *path;
|
||||||
|
|
||||||
g_assert_cmpstr (data->monitor_path, ==, g_file_get_path (file));
|
path = g_file_get_path (file);
|
||||||
|
g_assert_cmpstr (data->monitor_path, ==, path);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
if (event_type == G_FILE_MONITOR_EVENT_CREATED)
|
if (event_type == G_FILE_MONITOR_EVENT_CREATED)
|
||||||
data->monitor_created++;
|
data->monitor_created++;
|
||||||
|
@@ -431,6 +431,7 @@ test_initial_structure (gconstpointer test_data)
|
|||||||
test_attributes (item, info);
|
test_attributes (item, info);
|
||||||
|
|
||||||
g_object_unref (child);
|
g_object_unref (child);
|
||||||
|
g_object_unref (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read and test the pattern file */
|
/* read and test the pattern file */
|
||||||
@@ -447,6 +448,7 @@ test_initial_structure (gconstpointer test_data)
|
|||||||
g_assert (info != NULL);
|
g_assert (info != NULL);
|
||||||
size = g_file_info_get_size (info);
|
size = g_file_info_get_size (info);
|
||||||
g_assert_cmpint (size, ==, PATTERN_FILE_SIZE);
|
g_assert_cmpint (size, ==, PATTERN_FILE_SIZE);
|
||||||
|
g_object_unref (info);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
ins = g_file_read (child, NULL, &error);
|
ins = g_file_read (child, NULL, &error);
|
||||||
@@ -538,6 +540,9 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
|||||||
|
|
||||||
g_object_unref (descend);
|
g_object_unref (descend);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
g_object_unref (info);
|
||||||
|
g_free (relative_path);
|
||||||
|
|
||||||
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
||||||
}
|
}
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@@ -891,6 +896,7 @@ test_create (gconstpointer test_data)
|
|||||||
error->code, error->message);
|
error->code, error->message);
|
||||||
g_assert_cmpint (res, ==, TRUE);
|
g_assert_cmpint (res, ==, TRUE);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
g_object_unref (os);
|
||||||
}
|
}
|
||||||
g_object_unref (child);
|
g_object_unref (child);
|
||||||
}
|
}
|
||||||
@@ -961,6 +967,7 @@ test_open (gconstpointer test_data)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_cmpint (res, ==, TRUE);
|
g_assert_cmpint (res, ==, TRUE);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
g_object_unref (input_stream);
|
||||||
}
|
}
|
||||||
g_object_unref (child);
|
g_object_unref (child);
|
||||||
}
|
}
|
||||||
@@ -977,6 +984,7 @@ test_delete (gconstpointer test_data)
|
|||||||
GError *error;
|
GError *error;
|
||||||
guint i;
|
guint i;
|
||||||
struct StructureItem item;
|
struct StructureItem item;
|
||||||
|
gchar *path;
|
||||||
|
|
||||||
g_assert (test_data != NULL);
|
g_assert (test_data != NULL);
|
||||||
log ("\n");
|
log ("\n");
|
||||||
@@ -1000,8 +1008,10 @@ test_delete (gconstpointer test_data)
|
|||||||
g_assert (child != NULL);
|
g_assert (child != NULL);
|
||||||
/* we don't care about result here */
|
/* we don't care about result here */
|
||||||
|
|
||||||
log (" Deleting %s, path = %s\n", item.filename,
|
path = g_file_get_path (child);
|
||||||
g_file_get_path (child));
|
log (" Deleting %s, path = %s\n", item.filename, path);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if ((item.extra_flags & TEST_DELETE_NORMAL) == TEST_DELETE_NORMAL)
|
if ((item.extra_flags & TEST_DELETE_NORMAL) == TEST_DELETE_NORMAL)
|
||||||
res = g_file_delete (child, NULL, &error);
|
res = g_file_delete (child, NULL, &error);
|
||||||
@@ -1138,11 +1148,10 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
|||||||
|
|
||||||
g_assert (root != NULL);
|
g_assert (root != NULL);
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
enumerator =
|
enumerator =
|
||||||
g_file_enumerate_children (parent, "*",
|
g_file_enumerate_children (parent, "*",
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
|
||||||
&error);
|
NULL);
|
||||||
if (! enumerator)
|
if (! enumerator)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1154,6 +1163,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
|||||||
g_assert (descend != NULL);
|
g_assert (descend != NULL);
|
||||||
relative_path = g_file_get_relative_path (root, descend);
|
relative_path = g_file_get_relative_path (root, descend);
|
||||||
g_assert (relative_path != NULL);
|
g_assert (relative_path != NULL);
|
||||||
|
g_free (relative_path);
|
||||||
|
|
||||||
log (" deleting '%s'\n", g_file_info_get_display_name (info));
|
log (" deleting '%s'\n", g_file_info_get_display_name (info));
|
||||||
|
|
||||||
@@ -1166,6 +1176,8 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
|||||||
|
|
||||||
g_object_unref (descend);
|
g_object_unref (descend);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
g_object_unref (info);
|
||||||
|
|
||||||
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
||||||
}
|
}
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@@ -1263,6 +1275,7 @@ main (int argc, char *argv[])
|
|||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_option_context_free (context);
|
||||||
|
|
||||||
/* Write test - clean target directory first */
|
/* Write test - clean target directory first */
|
||||||
/* this can be also considered as a test - enumerate + delete */
|
/* this can be also considered as a test - enumerate + delete */
|
||||||
|
@@ -217,6 +217,9 @@ test_read_bytes (void)
|
|||||||
data = g_bytes_get_data (bytes, &size);
|
data = g_bytes_get_data (bytes, &size);
|
||||||
g_assert_cmpint (size, ==, 26);
|
g_assert_cmpint (size, ==, 26);
|
||||||
g_assert (strncmp (data, data1, 26) == 0);
|
g_assert (strncmp (data, data1, 26) == 0);
|
||||||
|
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
g_object_unref (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@@ -349,6 +349,7 @@ test_mime_file (void)
|
|||||||
str = g_key_file_get_string (keyfile, "Default Applications", contenttype, &error);
|
str = g_key_file_get_string (keyfile, "Default Applications", contenttype, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert_cmpstr (str, ==, "myapp.desktop");
|
g_assert_cmpstr (str, ==, "myapp.desktop");
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
g_key_file_free (keyfile);
|
g_key_file_free (keyfile);
|
||||||
|
|
||||||
|
@@ -52,6 +52,7 @@ test_parse_uri (void)
|
|||||||
address = (GNetworkAddress*)g_network_address_parse_uri ("ftp://joe%x-@ftp.gnome.org:2020/start", 8080, &error);
|
address = (GNetworkAddress*)g_network_address_parse_uri ("ftp://joe%x-@ftp.gnome.org:2020/start", 8080, &error);
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
||||||
g_assert (address == NULL);
|
g_assert (address == NULL);
|
||||||
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _ParseTest ParseTest;
|
typedef struct _ParseTest ParseTest;
|
||||||
|
@@ -230,6 +230,8 @@ run_tests (GNetworkMonitor *monitor,
|
|||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_main_loop_unref (data.loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -473,6 +475,16 @@ init_test (TestMask *test)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup_test (TestMask *test)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
g_object_unref (test->mask);
|
||||||
|
for (i = 0; test->addresses[i].string; i++)
|
||||||
|
g_object_unref (test->addresses[i].address);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
watch_network_changed (GNetworkMonitor *monitor,
|
watch_network_changed (GNetworkMonitor *monitor,
|
||||||
gboolean available,
|
gboolean available,
|
||||||
@@ -500,6 +512,8 @@ do_watch_network (void)
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
if (argc == 2 && !strcmp (argv[1], "--watch"))
|
if (argc == 2 && !strcmp (argv[1], "--watch"))
|
||||||
@@ -523,5 +537,15 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/network-monitor/add_networks", test_add_networks);
|
g_test_add_func ("/network-monitor/add_networks", test_add_networks);
|
||||||
g_test_add_func ("/network-monitor/remove_networks", test_remove_networks);
|
g_test_add_func ("/network-monitor/remove_networks", test_remove_networks);
|
||||||
|
|
||||||
return g_test_run ();
|
ret = g_test_run ();
|
||||||
|
|
||||||
|
cleanup_test (&net127);
|
||||||
|
cleanup_test (&net10);
|
||||||
|
cleanup_test (&net192);
|
||||||
|
cleanup_test (&netlocal6);
|
||||||
|
cleanup_test (&netfe80);
|
||||||
|
g_object_unref (ip4_default);
|
||||||
|
g_object_unref (ip6_default);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -475,7 +475,7 @@ proxy_thread (gpointer user_data)
|
|||||||
gssize nread, nwrote;
|
gssize nread, nwrote;
|
||||||
gchar command[2] = { 0, 0 };
|
gchar command[2] = { 0, 0 };
|
||||||
GMainContext *context;
|
GMainContext *context;
|
||||||
GSource *source;
|
GSource *read_source, *write_source;
|
||||||
|
|
||||||
context = g_main_context_new ();
|
context = g_main_context_new ();
|
||||||
proxy->loop = g_main_loop_new (context, FALSE);
|
proxy->loop = g_main_loop_new (context, FALSE);
|
||||||
@@ -486,6 +486,7 @@ proxy_thread (gpointer user_data)
|
|||||||
if (!proxy->client_sock)
|
if (!proxy->client_sock)
|
||||||
{
|
{
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||||
|
g_error_free (error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -516,15 +517,13 @@ proxy_thread (gpointer user_data)
|
|||||||
g_socket_connect (proxy->server_sock, server.server_addr, NULL, &error);
|
g_socket_connect (proxy->server_sock, server.server_addr, NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
source = g_socket_create_source (proxy->client_sock, G_IO_IN, NULL);
|
read_source = g_socket_create_source (proxy->client_sock, G_IO_IN, NULL);
|
||||||
g_source_set_callback (source, (GSourceFunc)proxy_bytes, proxy, NULL);
|
g_source_set_callback (read_source, (GSourceFunc)proxy_bytes, proxy, NULL);
|
||||||
g_source_attach (source, context);
|
g_source_attach (read_source, context);
|
||||||
g_source_unref (source);
|
|
||||||
|
|
||||||
source = g_socket_create_source (proxy->server_sock, G_IO_IN, NULL);
|
write_source = g_socket_create_source (proxy->server_sock, G_IO_IN, NULL);
|
||||||
g_source_set_callback (source, (GSourceFunc)proxy_bytes, proxy, NULL);
|
g_source_set_callback (write_source, (GSourceFunc)proxy_bytes, proxy, NULL);
|
||||||
g_source_attach (source, context);
|
g_source_attach (write_source, context);
|
||||||
g_source_unref (source);
|
|
||||||
|
|
||||||
g_main_loop_run (proxy->loop);
|
g_main_loop_run (proxy->loop);
|
||||||
|
|
||||||
@@ -535,6 +534,11 @@ proxy_thread (gpointer user_data)
|
|||||||
g_socket_close (proxy->server_sock, &error);
|
g_socket_close (proxy->server_sock, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_clear_object (&proxy->server_sock);
|
g_clear_object (&proxy->server_sock);
|
||||||
|
|
||||||
|
g_source_destroy (read_source);
|
||||||
|
g_source_unref (read_source);
|
||||||
|
g_source_destroy (write_source);
|
||||||
|
g_source_unref (write_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_main_loop_unref (proxy->loop);
|
g_main_loop_unref (proxy->loop);
|
||||||
@@ -543,6 +547,10 @@ proxy_thread (gpointer user_data)
|
|||||||
g_object_unref (proxy->server);
|
g_object_unref (proxy->server);
|
||||||
g_object_unref (proxy->cancellable);
|
g_object_unref (proxy->cancellable);
|
||||||
|
|
||||||
|
g_free (proxy->proxy_command);
|
||||||
|
g_free (proxy->supported_protocol);
|
||||||
|
g_free (proxy->uri);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,6 +616,7 @@ echo_server_thread (gpointer user_data)
|
|||||||
if (!sock)
|
if (!sock)
|
||||||
{
|
{
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||||
|
g_error_free (error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -633,6 +642,7 @@ echo_server_thread (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (data->server);
|
g_object_unref (data->server);
|
||||||
|
g_object_unref (data->server_addr);
|
||||||
g_object_unref (data->cancellable);
|
g_object_unref (data->cancellable);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -826,9 +836,11 @@ assert_direct (GSocketConnection *conn)
|
|||||||
addr = g_socket_connection_get_remote_address (conn, &error);
|
addr = g_socket_connection_get_remote_address (conn, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (!G_IS_PROXY_ADDRESS (addr));
|
g_assert (!G_IS_PROXY_ADDRESS (addr));
|
||||||
|
g_object_unref (addr);
|
||||||
|
|
||||||
addr = g_socket_connection_get_local_address (conn, &error);
|
addr = g_socket_connection_get_local_address (conn, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
g_object_unref (addr);
|
||||||
|
|
||||||
g_assert (g_socket_connection_is_connected (conn));
|
g_assert (g_socket_connection_is_connected (conn));
|
||||||
}
|
}
|
||||||
@@ -895,6 +907,8 @@ assert_single (GSocketConnection *conn)
|
|||||||
g_assert_cmpstr (proxy_uri, ==, proxy_a.uri);
|
g_assert_cmpstr (proxy_uri, ==, proxy_a.uri);
|
||||||
proxy_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
|
proxy_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
|
||||||
g_assert_cmpint (proxy_port, ==, proxy_a.port);
|
g_assert_cmpint (proxy_port, ==, proxy_a.port);
|
||||||
|
|
||||||
|
g_object_unref (addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -959,6 +973,8 @@ assert_multiple (GSocketConnection *conn)
|
|||||||
g_assert_cmpstr (proxy_uri, ==, proxy_b.uri);
|
g_assert_cmpstr (proxy_uri, ==, proxy_b.uri);
|
||||||
proxy_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
|
proxy_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
|
||||||
g_assert_cmpint (proxy_port, ==, proxy_b.port);
|
g_assert_cmpint (proxy_port, ==, proxy_b.port);
|
||||||
|
|
||||||
|
g_object_unref (addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1141,6 +1157,8 @@ main (int argc,
|
|||||||
g_thread_join (proxy_b.thread);
|
g_thread_join (proxy_b.thread);
|
||||||
g_thread_join (server.server_thread);
|
g_thread_join (server.server_thread);
|
||||||
|
|
||||||
|
g_object_unref (cancellable);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,6 +65,7 @@ writer_thread (gpointer user_data)
|
|||||||
|
|
||||||
if (g_cancellable_is_cancelled (writer_cancel))
|
if (g_cancellable_is_cancelled (writer_cancel))
|
||||||
{
|
{
|
||||||
|
g_clear_error (&err);
|
||||||
g_cancellable_cancel (main_cancel);
|
g_cancellable_cancel (main_cancel);
|
||||||
g_object_unref (out);
|
g_object_unref (out);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user