summaryrefslogtreecommitdiff
path: root/gio/tests
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:23:06 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:23:06 +0900
commit10c317e64ac791189cf7c77b1224a774dad37492 (patch)
tree619099d1c4ef095a242f90436c637a9bee13248c /gio/tests
parent00a8f3da047be5a3af040c6cbf77258e3d561799 (diff)
downloadglib-10c317e64ac791189cf7c77b1224a774dad37492.tar.gz
glib-10c317e64ac791189cf7c77b1224a774dad37492.tar.bz2
glib-10c317e64ac791189cf7c77b1224a774dad37492.zip
Imported Upstream version 2.65.0upstream/2.65.0
Diffstat (limited to 'gio/tests')
-rw-r--r--gio/tests/appinfo-test.c1
-rw-r--r--gio/tests/appinfo.c1
-rw-r--r--gio/tests/async-splice-output-stream.c27
-rw-r--r--gio/tests/cancellable.c101
-rw-r--r--gio/tests/credentials.c17
-rw-r--r--gio/tests/file.c125
-rw-r--r--gio/tests/g-file-info.c65
-rw-r--r--gio/tests/gdbus-addresses.c3
-rw-r--r--gio/tests/gdbus-auth.c1
-rw-r--r--gio/tests/gdbus-connection.c209
-rw-r--r--gio/tests/gdbus-export.c2
-rw-r--r--gio/tests/gdbus-message.c1
-rw-r--r--gio/tests/gdbus-object-manager-example/meson.build2
-rw-r--r--gio/tests/gdbus-peer.c29
-rw-r--r--gio/tests/gdbus-proxy-threads.c2
-rw-r--r--gio/tests/gdbus-proxy.c2
-rw-r--r--gio/tests/gdbus-serialization.c1
-rw-r--r--gio/tests/gdbus-server-auth.c5
-rw-r--r--gio/tests/gdbus-test-codegen.c2
-rw-r--r--gio/tests/gdbus-threading.c2
-rw-r--r--gio/tests/gsocketclient-slow.c2
-rw-r--r--gio/tests/gsubprocess.c4
-rw-r--r--gio/tests/gtlsconsoleinteraction.c2
-rw-r--r--gio/tests/live-g-file.txt2
-rw-r--r--gio/tests/meson.build2
-rw-r--r--gio/tests/pollable.c1
-rw-r--r--gio/tests/proxy-test.c1
-rw-r--r--gio/tests/resourceplugin.c3
-rw-r--r--gio/tests/resources.c2
-rw-r--r--gio/tests/socket-listener.c1
-rw-r--r--gio/tests/socket-service.c2
-rw-r--r--gio/tests/socket.c1
-rw-r--r--gio/tests/test2.gresource.xml2
-rw-r--r--gio/tests/thumbnail-verification.c4
-rw-r--r--gio/tests/tls-certificate.c2
-rw-r--r--gio/tests/trash.c1
-rw-r--r--gio/tests/volumemonitor.c1
-rw-r--r--gio/tests/win32-appinfo.c1
38 files changed, 401 insertions, 231 deletions
diff --git a/gio/tests/appinfo-test.c b/gio/tests/appinfo-test.c
index 3a91a2f9b..1b64a8faf 100644
--- a/gio/tests/appinfo-test.c
+++ b/gio/tests/appinfo-test.c
@@ -26,4 +26,3 @@ main (int argc, char *argv[])
return 0;
}
-
diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c
index 4fec6b379..2f0f43074 100644
--- a/gio/tests/appinfo.c
+++ b/gio/tests/appinfo.c
@@ -600,4 +600,3 @@ main (int argc, char *argv[])
return g_test_run ();
}
-
diff --git a/gio/tests/async-splice-output-stream.c b/gio/tests/async-splice-output-stream.c
index fb317b733..e69c4db5d 100644
--- a/gio/tests/async-splice-output-stream.c
+++ b/gio/tests/async-splice-output-stream.c
@@ -32,7 +32,6 @@ typedef enum
TEST_THREADED_NONE = 0,
TEST_THREADED_ISTREAM = 1,
TEST_THREADED_OSTREAM = 2,
- TEST_CANCEL = 4,
TEST_THREADED_BOTH = TEST_THREADED_ISTREAM | TEST_THREADED_OSTREAM,
} TestThreadedFlags;
@@ -59,14 +58,6 @@ test_copy_chunks_splice_cb (GObject *source,
bytes_spliced = g_output_stream_splice_finish (G_OUTPUT_STREAM (source),
res, &error);
-
- if (data->flags & TEST_CANCEL)
- {
- g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
- g_main_loop_quit (data->main_loop);
- return;
- }
-
g_assert_no_error (error);
g_assert_cmpint (bytes_spliced, ==, strlen (data->data));
@@ -109,18 +100,11 @@ test_copy_chunks_start (TestThreadedFlags flags)
{
TestCopyChunksData data;
GError *error = NULL;
- GCancellable *cancellable = NULL;
data.main_loop = g_main_loop_new (NULL, FALSE);
data.data = "abcdefghijklmnopqrstuvwxyz";
data.flags = flags;
- if (data.flags & TEST_CANCEL)
- {
- cancellable = g_cancellable_new ();
- g_cancellable_cancel (cancellable);
- }
-
if (data.flags & TEST_THREADED_ISTREAM)
{
GFile *file;
@@ -166,7 +150,7 @@ test_copy_chunks_start (TestThreadedFlags flags)
g_output_stream_splice_async (data.ostream, data.istream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT, cancellable,
+ G_PRIORITY_DEFAULT, NULL,
test_copy_chunks_splice_cb, &data);
/* We do not hold a ref in data struct, this is to make sure the operation
@@ -174,7 +158,6 @@ test_copy_chunks_start (TestThreadedFlags flags)
*/
g_object_unref (data.istream);
g_object_unref (data.ostream);
- g_clear_object (&cancellable);
g_main_loop_run (data.main_loop);
g_main_loop_unref (data.main_loop);
@@ -204,12 +187,6 @@ test_copy_chunks_threaded (void)
test_copy_chunks_start (TEST_THREADED_BOTH);
}
-static void
-test_cancelled (void)
-{
- test_copy_chunks_start (TEST_THREADED_NONE | TEST_CANCEL);
-}
-
int
main (int argc,
char *argv[])
@@ -223,8 +200,6 @@ main (int argc,
test_copy_chunks_threaded_output);
g_test_add_func ("/async-splice/copy-chunks-threaded",
test_copy_chunks_threaded);
- g_test_add_func ("/async-splice/cancelled",
- test_cancelled);
return g_test_run();
}
diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c
index cd349a8f3..e53ae6e7e 100644
--- a/gio/tests/cancellable.c
+++ b/gio/tests/cancellable.c
@@ -138,7 +138,7 @@ mock_operation_finish (GAsyncResult *result,
MockOperationData *data;
GTask *task;
- g_assert (g_task_is_valid (result, NULL));
+ g_assert_true (g_task_is_valid (result, NULL));
/* This test expects the return value to be iterations_done even
* when an error is set.
@@ -212,7 +212,7 @@ test_cancel_multiple_concurrent (void)
if (g_test_verbose ())
g_printerr ("CANCEL: %d operations\n", num_async_operations);
g_cancellable_cancel (cancellable);
- g_assert (g_cancellable_is_cancelled (cancellable));
+ g_assert_true (g_cancellable_is_cancelled (cancellable));
/* Wait for all operations to be cancelled */
g_main_loop_run (loop);
@@ -228,6 +228,102 @@ test_cancel_null (void)
g_cancellable_cancel (NULL);
}
+typedef struct
+{
+ GCond cond;
+ GMutex mutex;
+ gboolean thread_ready;
+ GAsyncQueue *cancellable_source_queue; /* (owned) (element-type GCancellableSource) */
+} ThreadedDisposeData;
+
+static gboolean
+cancelled_cb (GCancellable *cancellable,
+ gpointer user_data)
+{
+ /* Nothing needs to be done here. */
+ return G_SOURCE_CONTINUE;
+}
+
+static gpointer
+threaded_dispose_thread_cb (gpointer user_data)
+{
+ ThreadedDisposeData *data = user_data;
+ GSource *cancellable_source;
+
+ g_mutex_lock (&data->mutex);
+ data->thread_ready = TRUE;
+ g_cond_broadcast (&data->cond);
+ g_mutex_unlock (&data->mutex);
+
+ while ((cancellable_source = g_async_queue_pop (data->cancellable_source_queue)) != (gpointer) 1)
+ {
+ /* Race with cancellation of the cancellable. */
+ g_source_unref (cancellable_source);
+ }
+
+ return NULL;
+}
+
+static void
+test_cancellable_source_threaded_dispose (void)
+{
+ ThreadedDisposeData data;
+ GThread *thread = NULL;
+ guint i;
+
+ g_test_summary ("Test a thread race between disposing of a GCancellableSource "
+ "(in one thread) and cancelling the GCancellable it refers "
+ "to (in another thread)");
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1841");
+
+ /* Create a new thread and wait until it’s ready to execute. Each iteration of
+ * the test will pass it a new #GCancellableSource. */
+ g_cond_init (&data.cond);
+ g_mutex_init (&data.mutex);
+ data.cancellable_source_queue = g_async_queue_new_full ((GDestroyNotify) g_source_unref);
+ data.thread_ready = FALSE;
+
+ g_mutex_lock (&data.mutex);
+ thread = g_thread_new ("/cancellable-source/threaded-dispose",
+ threaded_dispose_thread_cb, &data);
+
+ while (!data.thread_ready)
+ g_cond_wait (&data.cond, &data.mutex);
+ g_mutex_unlock (&data.mutex);
+
+ for (i = 0; i < 100000; i++)
+ {
+ GCancellable *cancellable = NULL;
+ GSource *cancellable_source = NULL;
+
+ /* Create a cancellable and a cancellable source for it. For this test,
+ * there’s no need to attach the source to a #GMainContext. */
+ cancellable = g_cancellable_new ();
+ cancellable_source = g_cancellable_source_new (cancellable);
+ g_source_set_callback (cancellable_source, G_SOURCE_FUNC (cancelled_cb), NULL, NULL);
+
+ /* Send it to the thread and wait until it’s ready to execute before
+ * cancelling our cancellable. */
+ g_async_queue_push (data.cancellable_source_queue, g_steal_pointer (&cancellable_source));
+
+ /* Race with disposal of the cancellable source. */
+ g_cancellable_cancel (cancellable);
+
+ g_object_unref (cancellable);
+ }
+
+ /* Indicate that the test has finished. Can’t use %NULL as #GAsyncQueue
+ * doesn’t allow that.*/
+ g_async_queue_push (data.cancellable_source_queue, (gpointer) 1);
+
+ g_thread_join (g_steal_pointer (&thread));
+
+ g_assert (g_async_queue_length (data.cancellable_source_queue) == 0);
+ g_async_queue_unref (data.cancellable_source_queue);
+ g_mutex_clear (&data.mutex);
+ g_cond_clear (&data.cond);
+}
+
int
main (int argc, char *argv[])
{
@@ -235,6 +331,7 @@ main (int argc, char *argv[])
g_test_add_func ("/cancellable/multiple-concurrent", test_cancel_multiple_concurrent);
g_test_add_func ("/cancellable/null", test_cancel_null);
+ g_test_add_func ("/cancellable-source/threaded-dispose", test_cancellable_source_threaded_dispose);
return g_test_run ();
}
diff --git a/gio/tests/credentials.c b/gio/tests/credentials.c
index 6d7609964..2b0f1f787 100644
--- a/gio/tests/credentials.c
+++ b/gio/tests/credentials.c
@@ -54,9 +54,16 @@ test_basic (void)
g_assert_cmpuint (g_credentials_get_unix_user (creds, &error), ==,
geteuid ());
g_assert_no_error (error);
- g_assert_cmpuint (g_credentials_get_unix_pid (creds, &error), ==,
+
+#if G_CREDENTIALS_HAS_PID
+ g_assert_cmpint (g_credentials_get_unix_pid (creds, &error), ==,
getpid ());
g_assert_no_error (error);
+#else
+ g_assert_cmpint (g_credentials_get_unix_pid (creds, &error), ==, -1);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+#endif
set = g_credentials_set_unix_user (other, not_me, &error);
#if G_CREDENTIALS_SPOOFING_SUPPORTED
@@ -92,6 +99,14 @@ test_basic (void)
g_assert_cmpuint (native->uid, ==, geteuid ());
g_assert_cmpuint (native->pid, ==, getpid ());
}
+#elif G_CREDENTIALS_USE_APPLE_XUCRED
+ {
+ struct xucred *native = g_credentials_get_native (creds,
+ G_CREDENTIALS_TYPE_APPLE_XUCRED);
+
+ g_assert_cmpuint (native->cr_version, ==, XUCRED_VERSION);
+ g_assert_cmpuint (native->cr_uid, ==, geteuid ());
+ }
#elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED
{
struct cmsgcred *native = g_credentials_get_native (creds,
diff --git a/gio/tests/file.c b/gio/tests/file.c
index 8d3aafa63..c3877af4b 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -18,11 +18,11 @@ test_basic_for_file (GFile *file,
g_free (s);
s = g_file_get_uri (file);
- g_assert (g_str_has_prefix (s, "file://"));
- g_assert (g_str_has_suffix (s, suffix));
+ g_assert_true (g_str_has_prefix (s, "file://"));
+ g_assert_true (g_str_has_suffix (s, suffix));
g_free (s);
- g_assert (g_file_has_uri_scheme (file, "file"));
+ g_assert_true (g_file_has_uri_scheme (file, "file"));
s = g_file_get_uri_scheme (file);
g_assert_cmpstr (s, ==, "file");
g_free (s);
@@ -64,13 +64,13 @@ test_parent (void)
file2 = g_file_new_for_path ("./some/directory");
root = g_file_new_for_path ("/");
- g_assert (g_file_has_parent (file, file2));
+ g_assert_true (g_file_has_parent (file, file2));
parent = g_file_get_parent (file);
- g_assert (g_file_equal (parent, file2));
+ g_assert_true (g_file_equal (parent, file2));
g_object_unref (parent);
- g_assert (g_file_get_parent (root) == NULL);
+ g_assert_null (g_file_get_parent (root));
g_object_unref (file);
g_object_unref (file2);
@@ -86,10 +86,10 @@ test_child (void)
file = g_file_new_for_path ("./some/directory");
child = g_file_get_child (file, "child");
- g_assert (g_file_has_parent (child, file));
+ g_assert_true (g_file_has_parent (child, file));
child2 = g_file_get_child_for_display_name (file, "child2", NULL);
- g_assert (g_file_has_parent (child2, file));
+ g_assert_true (g_file_has_parent (child2, file));
g_object_unref (child);
g_object_unref (child2);
@@ -137,18 +137,18 @@ test_parse_name (void)
file = g_file_parse_name ("~foo");
name = g_file_get_parse_name (file);
- g_assert (name != NULL);
+ g_assert_nonnull (name);
g_object_unref (file);
g_free (name);
}
typedef struct
{
+ GMainContext *context;
GFile *file;
GFileMonitor *monitor;
GOutputStream *ostream;
GInputStream *istream;
- GMainLoop *loop;
gint buffersize;
gint monitor_created;
gint monitor_deleted;
@@ -158,6 +158,8 @@ typedef struct
const gchar *data;
gchar *buffer;
guint timeout;
+ gboolean file_deleted;
+ gboolean timed_out;
} CreateDeleteData;
static void
@@ -183,18 +185,8 @@ monitor_changed (GFileMonitor *monitor,
data->monitor_deleted++;
if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
data->monitor_changed++;
-}
-
-
-static gboolean
-quit_idle (gpointer user_data)
-{
- CreateDeleteData *data = user_data;
-
- g_source_remove (data->timeout);
- g_main_loop_quit (data->loop);
- return FALSE;
+ g_main_context_wakeup (data->context);
}
static void
@@ -209,19 +201,16 @@ iclosed_cb (GObject *source,
error = NULL;
ret = g_input_stream_close_finish (data->istream, res, &error);
g_assert_no_error (error);
- g_assert (ret);
+ g_assert_true (ret);
- g_assert (g_input_stream_is_closed (data->istream));
+ g_assert_true (g_input_stream_is_closed (data->istream));
ret = g_file_delete (data->file, NULL, &error);
- g_assert (ret);
+ g_assert_true (ret);
g_assert_no_error (error);
- /* work around file monitor bug:
- * inotify events are only processed every 1000 ms, regardless
- * of the rate limit set on the file monitor
- */
- g_timeout_add (2000, quit_idle, data);
+ data->file_deleted = TRUE;
+ g_main_context_wakeup (data->context);
}
static void
@@ -251,7 +240,7 @@ read_cb (GObject *source,
else
{
g_assert_cmpstr (data->buffer, ==, data->data);
- g_assert (!g_input_stream_is_closed (data->istream));
+ g_assert_false (g_input_stream_is_closed (data->istream));
g_input_stream_close_async (data->istream, 0, NULL, iclosed_cb, data);
}
}
@@ -346,8 +335,8 @@ oclosed_cb (GObject *source,
error = NULL;
ret = g_output_stream_close_finish (data->ostream, res, &error);
g_assert_no_error (error);
- g_assert (ret);
- g_assert (g_output_stream_is_closed (data->ostream));
+ g_assert_true (ret);
+ g_assert_true (g_output_stream_is_closed (data->ostream));
g_file_read_async (data->file, 0, NULL, opened_cb, data);
}
@@ -378,7 +367,7 @@ written_cb (GObject *source,
}
else
{
- g_assert (!g_output_stream_is_closed (data->ostream));
+ g_assert_false (g_output_stream_is_closed (data->ostream));
g_output_stream_close_async (data->ostream, 0, NULL, oclosed_cb, data);
}
}
@@ -409,7 +398,7 @@ created_cb (GObject *source,
error = NULL;
base = g_file_create_finish (G_FILE (source), res, &error);
g_assert_no_error (error);
- g_assert (g_file_query_exists (data->file, NULL));
+ g_assert_true (g_file_query_exists (data->file, NULL));
if (data->buffersize == 0)
data->ostream = G_OUTPUT_STREAM (g_object_ref (base));
@@ -435,11 +424,14 @@ created_cb (GObject *source,
}
static gboolean
-stop_timeout (gpointer data)
+stop_timeout (gpointer user_data)
{
- g_assert_not_reached ();
+ CreateDeleteData *data = user_data;
- return FALSE;
+ data->timed_out = TRUE;
+ g_main_context_wakeup (data->context);
+
+ return G_SOURCE_REMOVE;
}
/*
@@ -461,13 +453,13 @@ test_create_delete (gconstpointer d)
data->file = g_file_new_tmp ("g_file_create_delete_XXXXXX",
&iostream, NULL);
- g_assert (data->file != NULL);
+ g_assert_nonnull (data->file);
g_object_unref (iostream);
data->monitor_path = g_file_get_path (data->file);
remove (data->monitor_path);
- g_assert (!g_file_query_exists (data->file, NULL));
+ g_assert_false (g_file_query_exists (data->file, NULL));
error = NULL;
data->monitor = g_file_monitor_file (data->file, 0, NULL, &error);
@@ -495,23 +487,32 @@ test_create_delete (gconstpointer d)
g_signal_connect (data->monitor, "changed", G_CALLBACK (monitor_changed), data);
- data->loop = g_main_loop_new (NULL, FALSE);
-
- data->timeout = g_timeout_add (10000, stop_timeout, NULL);
+ /* Use the global default main context */
+ data->context = NULL;
+ data->timeout = g_timeout_add_seconds (10, stop_timeout, data);
g_file_create_async (data->file, 0, 0, NULL, created_cb, data);
- g_main_loop_run (data->loop);
+ while (!data->timed_out &&
+ (data->monitor_created == 0 ||
+ data->monitor_deleted == 0 ||
+ data->monitor_changed == 0 ||
+ !data->file_deleted))
+ g_main_context_iteration (data->context, TRUE);
+ g_source_remove (data->timeout);
+
+ g_assert_false (data->timed_out);
+ g_assert_true (data->file_deleted);
g_assert_cmpint (data->monitor_created, ==, 1);
g_assert_cmpint (data->monitor_deleted, ==, 1);
g_assert_cmpint (data->monitor_changed, >, 0);
- g_assert (!g_file_monitor_is_cancelled (data->monitor));
+ g_assert_false (g_file_monitor_is_cancelled (data->monitor));
g_file_monitor_cancel (data->monitor);
- g_assert (g_file_monitor_is_cancelled (data->monitor));
+ g_assert_true (g_file_monitor_is_cancelled (data->monitor));
- g_main_loop_unref (data->loop);
+ g_clear_pointer (&data->context, g_main_context_unref);
g_object_unref (data->ostream);
g_object_unref (data->istream);
@@ -582,7 +583,7 @@ loaded_cb (GObject *source,
error = NULL;
ret = g_file_load_contents_finish (data->file, res, &contents, &length, NULL, &error);
- g_assert (ret);
+ g_assert_true (ret);
g_assert_no_error (error);
g_assert_cmpint (length, ==, strlen (data->data));
g_assert_cmpstr (contents, ==, data->data);
@@ -609,8 +610,8 @@ loaded_cb (GObject *source,
error = NULL;
ret = g_file_delete (data->file, NULL, &error);
g_assert_no_error (error);
- g_assert (ret);
- g_assert (!g_file_query_exists (data->file, NULL));
+ g_assert_true (ret);
+ g_assert_false (g_file_query_exists (data->file, NULL));
g_main_loop_quit (data->loop);
}
@@ -644,13 +645,13 @@ test_replace_load (void)
data->file = g_file_new_tmp ("g_file_replace_load_XXXXXX",
&iostream, NULL);
- g_assert (data->file != NULL);
+ g_assert_nonnull (data->file);
g_object_unref (iostream);
path = g_file_peek_path (data->file);
remove (path);
- g_assert (!g_file_query_exists (data->file, NULL));
+ g_assert_false (g_file_query_exists (data->file, NULL));
data->loop = g_main_loop_new (NULL, FALSE);
@@ -717,11 +718,11 @@ test_replace_cancel (void)
info = g_file_enumerator_next_file (fenum, NULL, &error);
g_assert_no_error (error);
- g_assert (info != NULL);
+ g_assert_nonnull (info);
g_object_unref (info);
info = g_file_enumerator_next_file (fenum, NULL, &error);
g_assert_no_error (error);
- g_assert (info != NULL);
+ g_assert_nonnull (info);
g_object_unref (info);
g_file_enumerator_close (fenum, NULL, &error);
@@ -736,7 +737,7 @@ test_replace_cancel (void)
while (TRUE)
{
gboolean ret = g_file_enumerator_iterate (fenum, &info, NULL, NULL, &error);
- g_assert (ret);
+ g_assert_true (ret);
g_assert_no_error (error);
if (!info)
break;
@@ -758,13 +759,13 @@ test_replace_cancel (void)
GFile *child;
gboolean ret = g_file_enumerator_iterate (fenum, NULL, &child, NULL, &error);
- g_assert (ret);
+ g_assert_true (ret);
g_assert_no_error (error);
if (!child)
break;
- g_assert (G_IS_FILE (child));
+ g_assert_true (G_IS_FILE (child));
count++;
}
g_assert_cmpint (count, ==, 2);
@@ -832,7 +833,7 @@ test_async_delete (void)
g_assert_no_error (local_error);
g_object_unref (iostream);
- g_assert (g_file_query_exists (file, NULL));
+ g_assert_true (g_file_query_exists (file, NULL));
loop = g_main_loop_new (NULL, TRUE);
@@ -840,7 +841,7 @@ test_async_delete (void)
g_main_loop_run (loop);
- g_assert (!g_file_query_exists (file, NULL));
+ g_assert_false (g_file_query_exists (file, NULL));
g_main_loop_unref (loop);
g_object_unref (file);
@@ -1034,7 +1035,7 @@ test_measure (void)
&num_dirs,
&num_files,
&error);
- g_assert (ok);
+ g_assert_true (ok);
g_assert_no_error (error);
if (size > 0)
@@ -1087,7 +1088,7 @@ measure_done (GObject *source,
gboolean ok;
ok = g_file_measure_disk_usage_finish (G_FILE (source), res, &num_bytes, &num_dirs, &num_files, &error);
- g_assert (ok);
+ g_assert_true (ok);
g_assert_no_error (error);
if (data->expected_bytes > 0)
@@ -1160,7 +1161,7 @@ test_load_bytes (void)
file = g_file_new_for_path (filename);
bytes = g_file_load_bytes (file, NULL, NULL, &error);
g_assert_no_error (error);
- g_assert (bytes != NULL);
+ g_assert_nonnull (bytes);
g_assert_cmpint (len, ==, g_bytes_get_size (bytes));
g_assert_cmpstr ("test_load_bytes", ==, (gchar *)g_bytes_get_data (bytes, NULL));
@@ -1188,7 +1189,7 @@ test_load_bytes_cb (GObject *object,
data->bytes = g_file_load_bytes_finish (file, result, NULL, &error);
g_assert_no_error (error);
- g_assert (data->bytes != NULL);
+ g_assert_nonnull (data->bytes);
g_main_loop_quit (data->main_loop);
}
diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c
index 1fbdf71fa..c4cfd3702 100644
--- a/gio/tests/g-file-info.c
+++ b/gio/tests/g-file-info.c
@@ -229,6 +229,13 @@ test_internal_enhanced_stdio (void)
{ 0x62AB5D82, 0xFDC1, 0x4DC3, { 0xA9, 0xDD, 0x07, 0x0D, 0x1D, 0x49, 0x5D, 0x97 } };
static const GUID folder_id_users =
{ 0x0762D272, 0xC50A, 0x4BB0, { 0xA3, 0x82, 0x69, 0x7D, 0xCD, 0x72, 0x9B, 0x80 } };
+ GDateTime *dt = NULL, *dt2 = NULL;
+ GTimeSpan ts;
+ /* Just before SYSTEMTIME limit (Jan 1 30827) */
+ const gint64 one_sec_before_systemtime_limit = 910670515199;
+ gboolean retval;
+ GError *local_error = NULL;
+
programdata_dir_w = NULL;
SHGetKnownFolderPath (&folder_id_programdata, 0, NULL, &programdata_dir_w);
@@ -552,7 +559,8 @@ test_internal_enhanced_stdio (void)
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE ","
G_FILE_ATTRIBUTE_ID_FILE ","
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
@@ -560,7 +568,8 @@ test_internal_enhanced_stdio (void)
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE ","
G_FILE_ATTRIBUTE_ID_FILE ","
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
@@ -568,11 +577,13 @@ test_internal_enhanced_stdio (void)
g_assert_true (g_file_info_has_attribute (fi_p0, G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE));
g_assert_true (g_file_info_has_attribute (fi_p0, G_FILE_ATTRIBUTE_ID_FILE));
g_assert_true (g_file_info_has_attribute (fi_p0, G_FILE_ATTRIBUTE_TIME_MODIFIED));
+ g_assert_true (g_file_info_has_attribute (fi_p0, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC));
g_assert_true (g_file_info_has_attribute (fi_p1, G_FILE_ATTRIBUTE_STANDARD_SIZE));
g_assert_true (g_file_info_has_attribute (fi_p1, G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE));
g_assert_true (g_file_info_has_attribute (fi_p1, G_FILE_ATTRIBUTE_ID_FILE));
g_assert_true (g_file_info_has_attribute (fi_p1, G_FILE_ATTRIBUTE_TIME_MODIFIED));
+ g_assert_true (g_file_info_has_attribute (fi_p1, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC));
size_p0 = g_file_info_get_attribute_uint64 (fi_p0, G_FILE_ATTRIBUTE_STANDARD_SIZE);
alsize_p0 = g_file_info_get_attribute_uint64 (fi_p0, G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE);
@@ -604,6 +615,56 @@ test_internal_enhanced_stdio (void)
*/
g_assert_cmpuint (time_p0, >, G_GUINT64_CONSTANT (0xFFFFFFFF));
+ dt = g_file_info_get_modification_date_time (fi_p0);
+ g_assert_nonnull (dt);
+ dt2 = g_date_time_add (dt, G_USEC_PER_SEC / 100 * 200);
+ g_object_unref (fi_p0);
+ fi_p0 = g_file_info_new ();
+ g_file_info_set_modification_date_time (fi_p0, dt2);
+
+ g_assert_true (g_file_set_attributes_from_info (gf_p0,
+ fi_p0,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL));
+ g_date_time_unref (dt2);
+ g_object_unref (fi_p0);
+ fi_p0 = g_file_query_info (gf_p0,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+ dt2 = g_file_info_get_modification_date_time (fi_p0);
+ ts = g_date_time_difference (dt2, dt);
+ g_assert_cmpint (ts, >, 0);
+ g_assert_cmpint (ts, <, G_USEC_PER_SEC / 100 * 300);
+
+ g_date_time_unref (dt);
+ g_date_time_unref (dt2);
+
+ g_file_info_set_attribute_uint64 (fi_p0,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ one_sec_before_systemtime_limit);
+ g_file_info_set_attribute_uint32 (fi_p0, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC, 0);
+ g_assert_true (g_file_set_attributes_from_info (gf_p0,
+ fi_p0,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL));
+
+ g_file_info_set_attribute_uint64 (fi_p0,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ one_sec_before_systemtime_limit + G_USEC_PER_SEC * 2);
+ g_file_info_set_attribute_uint32 (fi_p0, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC, 0);
+ retval = g_file_set_attributes_from_info (gf_p0,
+ fi_p0,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &local_error);
+ g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA);
+ g_assert_false (retval);
+ g_clear_error (&local_error);
+
g_object_unref (fi_p0);
g_object_unref (fi_p1);
g_object_unref (gf_p0);
diff --git a/gio/tests/gdbus-addresses.c b/gio/tests/gdbus-addresses.c
index 26c21ee24..dbff79c3e 100644
--- a/gio/tests/gdbus-addresses.c
+++ b/gio/tests/gdbus-addresses.c
@@ -39,7 +39,7 @@ test_empty_address (void)
g_error_free (error);
}
-/* Test that g_dbus_is_supported_address() returns FALSE for an unparseable
+/* Test that g_dbus_is_supported_address() returns FALSE for an unparsable
* address. */
static void
test_unsupported_address (void)
@@ -221,4 +221,3 @@ main (int argc,
return g_test_run();
}
-
diff --git a/gio/tests/gdbus-auth.c b/gio/tests/gdbus-auth.c
index f44e932e2..8be4473c7 100644
--- a/gio/tests/gdbus-auth.c
+++ b/gio/tests/gdbus-auth.c
@@ -310,4 +310,3 @@ main (int argc,
return ret;
}
-
diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c
index 469018577..7bd7a02f4 100644
--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -89,6 +89,7 @@ static const GDBusInterfaceVTable boo_vtable =
NULL /* _set_property */
};
+/* Runs in a worker thread. */
static GDBusMessage *
some_filter_func (GDBusConnection *connection,
GDBusMessage *message,
@@ -129,9 +130,9 @@ test_connection_bus_failure (void)
*
*/
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
- g_assert (error != NULL);
- g_assert (!g_dbus_error_is_remote_error (error));
- g_assert (c == NULL);
+ g_assert_nonnull (error);
+ g_assert_false (g_dbus_error_is_remote_error (error));
+ g_assert_null (c);
g_error_free (error);
}
@@ -159,8 +160,8 @@ test_connection_life_cycle (void)
error = NULL;
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c != NULL);
- g_assert (!g_dbus_connection_is_closed (c));
+ g_assert_nonnull (c);
+ g_assert_false (g_dbus_connection_is_closed (c));
/*
* Check that singleton handling work
@@ -168,8 +169,8 @@ test_connection_life_cycle (void)
error = NULL;
c2 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c2 != NULL);
- g_assert (c == c2);
+ g_assert_nonnull (c2);
+ g_assert_true (c == c2);
g_object_unref (c2);
/*
@@ -177,23 +178,23 @@ test_connection_life_cycle (void)
*/
c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c2 != NULL);
- g_assert (c != c2);
+ g_assert_nonnull (c2);
+ g_assert_true (c != c2);
g_object_unref (c2);
c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c2 != NULL);
- g_assert (!g_dbus_connection_is_closed (c2));
+ g_assert_nonnull (c2);
+ g_assert_false (g_dbus_connection_is_closed (c2));
ret = g_dbus_connection_close_sync (c2, NULL, &error);
g_assert_no_error (error);
- g_assert (ret);
+ g_assert_true (ret);
_g_assert_signal_received (c2, "closed");
- g_assert (g_dbus_connection_is_closed (c2));
+ g_assert_true (g_dbus_connection_is_closed (c2));
ret = g_dbus_connection_close_sync (c2, NULL, &error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
g_error_free (error);
- g_assert (!ret);
+ g_assert_false (ret);
g_object_unref (c2);
/*
@@ -205,7 +206,7 @@ test_connection_life_cycle (void)
error = NULL;
c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c2 != NULL);
+ g_assert_nonnull (c2);
/* signal registration */
on_signal_registration_freed_called = FALSE;
g_dbus_connection_signal_subscribe (c2,
@@ -235,7 +236,7 @@ test_connection_life_cycle (void)
a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop,
&error);
g_assert_no_error (error);
- g_assert (registration_id > 0);
+ g_assert_cmpuint (registration_id, >, 0);
/* ok, finalize the connection and check that all the GDestroyNotify functions are invoked as expected */
g_object_unref (c2);
quit_mainloop_fired = FALSE;
@@ -260,20 +261,20 @@ test_connection_life_cycle (void)
_log ("exiting loop");
}
g_source_remove (quit_mainloop_id);
- g_assert (on_signal_registration_freed_called);
- g_assert (on_filter_freed_called);
- g_assert (on_register_object_freed_called);
- g_assert (!quit_mainloop_fired);
+ g_assert_true (on_signal_registration_freed_called);
+ g_assert_true (on_filter_freed_called);
+ g_assert_true (on_register_object_freed_called);
+ g_assert_false (quit_mainloop_fired);
/*
* Check for correct behavior when the bus goes away
*
*/
- g_assert (!g_dbus_connection_is_closed (c));
+ g_assert_false (g_dbus_connection_is_closed (c));
g_dbus_connection_set_exit_on_close (c, FALSE);
session_bus_stop ();
_g_assert_signal_received (c, "closed");
- g_assert (g_dbus_connection_is_closed (c));
+ g_assert_true (g_dbus_connection_is_closed (c));
g_object_unref (c);
session_bus_down ();
@@ -299,9 +300,9 @@ msg_cb_expect_error_disconnected (GDBusConnection *connection,
res,
&error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
- g_assert (!g_dbus_error_is_remote_error (error));
+ g_assert_false (g_dbus_error_is_remote_error (error));
g_error_free (error);
- g_assert (result == NULL);
+ g_assert_null (result);
g_main_loop_quit (loop);
}
@@ -322,9 +323,9 @@ msg_cb_expect_error_unknown_method (GDBusConnection *connection,
res,
&error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
- g_assert (g_dbus_error_is_remote_error (error));
+ g_assert_true (g_dbus_error_is_remote_error (error));
g_error_free (error);
- g_assert (result == NULL);
+ g_assert_null (result);
g_main_loop_quit (loop);
}
@@ -345,7 +346,7 @@ msg_cb_expect_success (GDBusConnection *connection,
res,
&error);
g_assert_no_error (error);
- g_assert (result != NULL);
+ g_assert_nonnull (result);
g_variant_unref (result);
g_main_loop_quit (loop);
@@ -367,9 +368,9 @@ msg_cb_expect_error_cancelled (GDBusConnection *connection,
res,
&error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
- g_assert (!g_dbus_error_is_remote_error (error));
+ g_assert_false (g_dbus_error_is_remote_error (error));
g_error_free (error);
- g_assert (result == NULL);
+ g_assert_null (result);
g_main_loop_quit (loop);
}
@@ -390,9 +391,9 @@ msg_cb_expect_error_cancelled_2 (GDBusConnection *connection,
res,
&error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
- g_assert (!g_dbus_error_is_remote_error (error));
+ g_assert_false (g_dbus_error_is_remote_error (error));
g_error_free (error);
- g_assert (result == NULL);
+ g_assert_null (result);
g_main_loop_quit (loop);
}
@@ -409,8 +410,8 @@ test_connection_send (void)
/* First, get an unopened connection */
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
- g_assert (c != NULL);
- g_assert (!g_dbus_connection_is_closed (c));
+ g_assert_nonnull (c);
+ g_assert_false (g_dbus_connection_is_closed (c));
/*
* Check that we never actually send a message if the GCancellable
@@ -490,7 +491,7 @@ test_connection_send (void)
g_dbus_connection_set_exit_on_close (c, FALSE);
session_bus_stop ();
_g_assert_signal_received (c, "closed");
- g_assert (g_dbus_connection_is_closed (c));
+ g_assert_true (g_dbus_connection_is_closed (c));
g_dbus_connection_call (c,
"org.freedesktop.DBus", /* bus_name */
@@ -567,13 +568,13 @@ test_connection_signals (void)
if (g_getenv ("G_DBUS_MONITOR") == NULL)
{
c1 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, NULL);
- g_assert (c1 != NULL);
- g_assert (!g_dbus_connection_is_closed (c1));
+ g_assert_nonnull (c1);
+ g_assert_false (g_dbus_connection_is_closed (c1));
g_object_unref (c1);
}
c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
- g_assert (c1 != NULL);
- g_assert (!g_dbus_connection_is_closed (c1));
+ g_assert_nonnull (c1);
+ g_assert_false (g_dbus_connection_is_closed (c1));
g_assert_cmpstr (g_dbus_connection_get_unique_name (c1), ==, ":1.1");
/*
@@ -628,10 +629,10 @@ test_connection_signals (void)
test_connection_signal_handler,
&count_s1b,
NULL);
- g_assert (s1 != 0);
- g_assert (s1b != 0);
- g_assert (s2 != 0);
- g_assert (s3 != 0);
+ g_assert_cmpuint (s1, !=, 0);
+ g_assert_cmpuint (s1b, !=, 0);
+ g_assert_cmpuint (s2, !=, 0);
+ g_assert_cmpuint (s3, !=, 0);
count_s1 = 0;
count_s1b = 0;
@@ -661,19 +662,19 @@ test_connection_signals (void)
NULL,
&error);
g_assert_no_error (error);
- g_assert (result != NULL);
+ g_assert_nonnull (result);
g_variant_unref (result);
/*
* Bring up two other connections
*/
c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, NULL);
- g_assert (c2 != NULL);
- g_assert (!g_dbus_connection_is_closed (c2));
+ g_assert_nonnull (c2);
+ g_assert_false (g_dbus_connection_is_closed (c2));
g_assert_cmpstr (g_dbus_connection_get_unique_name (c2), ==, ":1.2");
c3 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, NULL);
- g_assert (c3 != NULL);
- g_assert (!g_dbus_connection_is_closed (c3));
+ g_assert_nonnull (c3);
+ g_assert_false (g_dbus_connection_is_closed (c3));
g_assert_cmpstr (g_dbus_connection_get_unique_name (c3), ==, ":1.3");
/* now, emit the signal on c2 */
@@ -685,7 +686,7 @@ test_connection_signals (void)
NULL,
&error);
g_assert_no_error (error);
- g_assert (ret);
+ g_assert_true (ret);
while (!(count_s1 >= 1 && count_s2 >= 1))
g_main_loop_run (loop);
g_assert_cmpint (count_s1, ==, 1);
@@ -702,7 +703,7 @@ test_connection_signals (void)
NULL,
&error);
g_assert_no_error (error);
- g_assert (ret);
+ g_assert_true (ret);
while (!(count_s1 == 1 && count_s2 == 2))
g_main_loop_run (loop);
g_assert_cmpint (count_s1, ==, 1);
@@ -812,13 +813,15 @@ test_connection_signal_match_rules (void)
/* ---------------------------------------------------------------------------------------------------- */
+/* Accessed both from the test code and the filter function (in a worker thread)
+ * so all accesses must be atomic. */
typedef struct
{
- guint num_handled;
- guint num_outgoing;
- guint32 serial;
+ GAsyncQueue *incoming_queue; /* (element-type GDBusMessage) */
+ guint num_outgoing; /* (atomic) */
} FilterData;
+/* Runs in a worker thread. */
static GDBusMessage *
filter_func (GDBusConnection *connection,
GDBusMessage *message,
@@ -826,22 +829,31 @@ filter_func (GDBusConnection *connection,
gpointer user_data)
{
FilterData *data = user_data;
- guint32 reply_serial;
if (incoming)
- {
- reply_serial = g_dbus_message_get_reply_serial (message);
- if (reply_serial == data->serial)
- data->num_handled += 1;
- }
+ g_async_queue_push (data->incoming_queue, g_object_ref (message));
else
- {
- data->num_outgoing += 1;
- }
+ g_atomic_int_inc (&data->num_outgoing);
return message;
}
+static void
+wait_for_filtered_reply (GAsyncQueue *incoming_queue,
+ guint32 expected_serial)
+{
+ GDBusMessage *popped_message = NULL;
+
+ while ((popped_message = g_async_queue_pop (incoming_queue)) != NULL)
+ {
+ guint32 reply_serial = g_dbus_message_get_reply_serial (popped_message);
+ g_object_unref (popped_message);
+ if (reply_serial == expected_serial)
+ return;
+ }
+
+ g_assert_not_reached ();
+}
typedef struct
{
@@ -849,13 +861,14 @@ typedef struct
gboolean alter_outgoing;
} FilterEffects;
+/* Runs in a worker thread. */
static GDBusMessage *
other_filter_func (GDBusConnection *connection,
GDBusMessage *message,
gboolean incoming,
gpointer user_data)
{
- FilterEffects *effects = user_data;
+ const FilterEffects *effects = user_data;
GDBusMessage *ret;
gboolean alter;
@@ -928,7 +941,7 @@ static void
test_connection_filter (void)
{
GDBusConnection *c;
- FilterData data;
+ FilterData data = { NULL, 0 };
GDBusMessage *m;
GDBusMessage *m2;
GDBusMessage *r;
@@ -939,16 +952,17 @@ test_connection_filter (void)
FilterEffects effects;
GVariant *result;
const gchar *s;
-
- memset (&data, '\0', sizeof (FilterData));
+ guint32 serial_temp;
session_bus_up ();
error = NULL;
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c != NULL);
+ g_assert_nonnull (c);
+ data.incoming_queue = g_async_queue_new_full (g_object_unref);
+ data.num_outgoing = 0;
filter_id = g_dbus_connection_add_filter (c,
filter_func,
&data,
@@ -960,32 +974,29 @@ test_connection_filter (void)
"GetNameOwner");
g_dbus_message_set_body (m, g_variant_new ("(s)", "org.freedesktop.DBus"));
error = NULL;
- g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &data.serial, &error);
+ g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &serial_temp, &error);
g_assert_no_error (error);
- while (data.num_handled == 0)
- g_thread_yield ();
+ wait_for_filtered_reply (data.incoming_queue, serial_temp);
m2 = g_dbus_message_copy (m, &error);
g_assert_no_error (error);
- g_dbus_connection_send_message (c, m2, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &data.serial, &error);
+ g_dbus_connection_send_message (c, m2, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &serial_temp, &error);
g_object_unref (m2);
g_assert_no_error (error);
- while (data.num_handled == 1)
- g_thread_yield ();
+ wait_for_filtered_reply (data.incoming_queue, serial_temp);
m2 = g_dbus_message_copy (m, &error);
g_assert_no_error (error);
- g_dbus_message_set_serial (m2, data.serial);
+ g_dbus_message_set_serial (m2, serial_temp);
/* lock the message to test PRESERVE_SERIAL flag. */
g_dbus_message_lock (m2);
- g_dbus_connection_send_message (c, m2, G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL, &data.serial, &error);
+ g_dbus_connection_send_message (c, m2, G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL, &serial_temp, &error);
g_object_unref (m2);
g_assert_no_error (error);
- while (data.num_handled == 2)
- g_thread_yield ();
+ wait_for_filtered_reply (data.incoming_queue, serial_temp);
m2 = g_dbus_message_copy (m, &error);
g_assert_no_error (error);
@@ -993,14 +1004,16 @@ test_connection_filter (void)
m2,
G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-1,
- &data.serial,
+ &serial_temp,
NULL, /* GCancellable */
&error);
g_object_unref (m2);
g_assert_no_error (error);
- g_assert (r != NULL);
+ g_assert_nonnull (r);
g_object_unref (r);
- g_assert_cmpint (data.num_handled, ==, 4);
+
+ wait_for_filtered_reply (data.incoming_queue, serial_temp);
+ g_assert_cmpint (g_async_queue_length (data.incoming_queue), ==, 0);
g_dbus_connection_remove_filter (c, filter_id);
@@ -1010,15 +1023,15 @@ test_connection_filter (void)
m2,
G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-1,
- &data.serial,
+ &serial_temp,
NULL, /* GCancellable */
&error);
g_object_unref (m2);
g_assert_no_error (error);
- g_assert (r != NULL);
+ g_assert_nonnull (r);
g_object_unref (r);
- g_assert_cmpint (data.num_handled, ==, 4);
- g_assert_cmpint (data.num_outgoing, ==, 4);
+ g_assert_cmpint (g_async_queue_length (data.incoming_queue), ==, 0);
+ g_assert_cmpint (g_atomic_int_get (&data.num_outgoing), ==, 4);
/* wait for service to be available */
signal_handler_id = g_dbus_connection_signal_subscribe (c,
@@ -1034,7 +1047,7 @@ test_connection_filter (void)
g_assert_cmpint (signal_handler_id, !=, 0);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
+ g_assert_true (g_spawn_command_line_async (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
timeout_mainloop_id = g_timeout_add (30000, test_connection_filter_on_timeout, NULL);
g_main_loop_run (loop);
@@ -1090,6 +1103,7 @@ test_connection_filter (void)
g_object_unref (c);
g_object_unref (m);
+ g_async_queue_unref (data.incoming_queue);
session_bus_down ();
}
@@ -1159,7 +1173,7 @@ test_connection_serials (void)
error = NULL;
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (c != NULL);
+ g_assert_nonnull (c);
/* Status after initialization */
g_assert_cmpint (g_dbus_connection_get_last_serial (c), ==, 1);
@@ -1210,11 +1224,11 @@ test_connection_basic (void)
error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
- g_assert (connection != NULL);
+ g_assert_nonnull (connection);
flags = g_dbus_connection_get_capabilities (connection);
- g_assert (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
- flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
+ g_assert_true (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
+ flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
connection_flags = g_dbus_connection_get_flags (connection);
g_assert_cmpint (connection_flags, ==,
@@ -1222,7 +1236,7 @@ test_connection_basic (void)
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION);
credentials = g_dbus_connection_get_peer_credentials (connection);
- g_assert (credentials == NULL);
+ g_assert_null (credentials);
g_object_get (connection,
"stream", &stream,
@@ -1233,13 +1247,13 @@ test_connection_basic (void)
"capabilities", &flags,
NULL);
- g_assert (G_IS_IO_STREAM (stream));
- g_assert (g_dbus_is_guid (guid));
- g_assert (g_dbus_is_unique_name (name));
- g_assert (!closed);
- g_assert (exit_on_close);
- g_assert (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
- flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
+ g_assert_true (G_IS_IO_STREAM (stream));
+ g_assert_true (g_dbus_is_guid (guid));
+ g_assert_true (g_dbus_is_unique_name (name));
+ g_assert_false (closed);
+ g_assert_true (exit_on_close);
+ g_assert_true (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
+ flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
g_object_unref (stream);
g_free (name);
g_free (guid);
@@ -1257,9 +1271,6 @@ main (int argc,
{
int ret;
- /* FIXME: Add debug for https://gitlab.gnome.org/GNOME/glib/issues/1957 */
- g_setenv ("G_DBUS_DEBUG", "all", TRUE);
-
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c
index fda654c44..ba5388600 100644
--- a/gio/tests/gdbus-export.c
+++ b/gio/tests/gdbus-export.c
@@ -1279,7 +1279,7 @@ test_object_registration (void)
g_strfreev (nodes);
g_assert_cmpint (count_interfaces (c, "/foo/dyna/dynamicallycreated"), ==, 4);
- /* now check that the object hierarachy is properly generated... yes, it's a bit
+ /* now check that the object hierarchy is properly generated... yes, it's a bit
* perverse that we round-trip to the bus to introspect ourselves ;-)
*/
nodes = get_nodes_at (c, "/");
diff --git a/gio/tests/gdbus-message.c b/gio/tests/gdbus-message.c
index 5cb141d94..93235749a 100644
--- a/gio/tests/gdbus-message.c
+++ b/gio/tests/gdbus-message.c
@@ -223,4 +223,3 @@ main (int argc,
return g_test_run ();
}
-
diff --git a/gio/tests/gdbus-object-manager-example/meson.build b/gio/tests/gdbus-object-manager-example/meson.build
index 4cfb848d3..f9c3bce26 100644
--- a/gio/tests/gdbus-object-manager-example/meson.build
+++ b/gio/tests/gdbus-object-manager-example/meson.build
@@ -13,6 +13,8 @@ gdbus_example_objectmanager_generated = custom_target('objectmanager-gen',
'--output-directory', '@OUTDIR@',
'--generate-c-code', 'objectmanager-gen',
'--generate-docbook', 'objectmanager-gen',
+ '--symbol-decorator', '_GLIB_EXTERN',
+ '--symbol-decorator-define', 'HAVE_CONFIG_H',
'@INPUT@'])
libgdbus_example_objectmanager = library('gdbus-example-objectmanager',
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index d01bc9a7a..617d7561a 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -344,7 +344,7 @@ on_new_connection (GDBusServer *server,
gpointer user_data)
{
PeerData *data = user_data;
- GError *error;
+ GError *error = NULL;
guint reg_id;
//g_printerr ("Client connected.\n"
@@ -362,13 +362,19 @@ on_new_connection (GDBusServer *server,
g_assert (credentials != NULL);
g_assert_cmpuint (g_credentials_get_unix_user (credentials, NULL), ==,
getuid ());
- g_assert_cmpuint (g_credentials_get_unix_pid (credentials, NULL), ==,
- getpid ());
+#if G_CREDENTIALS_HAS_PID
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==,
+ getpid ());
+ g_assert_no_error (error);
+#else
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==, -1);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+#endif
}
#endif
/* export object on the newly established connection */
- error = NULL;
reg_id = g_dbus_connection_register_object (connection,
"/org/gtk/GDBus/PeerTestObject",
test_interface_introspection_data,
@@ -922,8 +928,15 @@ do_test_peer (void)
g_assert_cmpuint (g_credentials_get_unix_user (credentials, NULL), ==,
getuid ());
- g_assert_cmpuint (g_credentials_get_unix_pid (credentials, NULL), ==,
- getpid ());
+#if G_CREDENTIALS_HAS_PID
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==,
+ getpid ());
+ g_assert_no_error (error);
+#else
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==, -1);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+#endif
g_object_unref (credentials);
#else
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
@@ -1849,7 +1862,7 @@ codegen_test_peer (void)
g_assert (value != NULL);
g_variant_unref (value);
- /* Give the proxies a chance to refresh in the defaul main loop */
+ /* Give the proxies a chance to refresh in the default main loop */
g_timeout_add (100, codegen_quit_mainloop_timeout, NULL);
g_main_loop_run (loop);
@@ -1884,7 +1897,7 @@ codegen_test_peer (void)
g_assert (value != NULL);
g_variant_unref (value);
- /* Give the proxies a chance to refresh in the defaul main loop */
+ /* Give the proxies a chance to refresh in the default main loop */
g_timeout_add (1000, codegen_quit_mainloop_timeout, NULL);
g_main_loop_run (loop);
diff --git a/gio/tests/gdbus-proxy-threads.c b/gio/tests/gdbus-proxy-threads.c
index 75ed21d51..690a9cc0e 100644
--- a/gio/tests/gdbus-proxy-threads.c
+++ b/gio/tests/gdbus-proxy-threads.c
@@ -230,7 +230,7 @@ test_proxy (void)
g_main_loop_unref (loop);
/* TODO: should call session_bus_down() but that requires waiting
- * for all the oustanding method calls to complete...
+ * for all the outstanding method calls to complete...
*/
if (g_test_verbose ())
g_printerr ("\n");
diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c
index 05b22ea1c..a2160dcca 100644
--- a/gio/tests/gdbus-proxy.c
+++ b/gio/tests/gdbus-proxy.c
@@ -388,7 +388,7 @@ test_proxy_signals_on_emit_signal_cb (GDBusProxy *proxy,
g_assert_cmpstr (g_variant_get_type_string (result), ==, "()");
g_variant_unref (result);
- /* check that the signal was recieved before we got the method result */
+ /* check that the signal was received before we got the method result */
g_assert_cmpuint (strlen (data->s->str), >, 0);
/* break out of the loop */
diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c
index 2ca28d99b..7bc53c6a1 100644
--- a/gio/tests/gdbus-serialization.c
+++ b/gio/tests/gdbus-serialization.c
@@ -1451,4 +1451,3 @@ main (int argc,
return g_test_run();
}
-
diff --git a/gio/tests/gdbus-server-auth.c b/gio/tests/gdbus-server-auth.c
index 2554ad6ab..b3ee8aab2 100644
--- a/gio/tests/gdbus-server-auth.c
+++ b/gio/tests/gdbus-server-auth.c
@@ -244,6 +244,11 @@ assert_expected_uid_pid (InteropFlags flags,
* on Linux. */
g_assert_cmpint (uid, ==, getuid ());
g_assert_cmpint (pid, ==, getpid ());
+#elif defined(__APPLE__)
+ /* We know (or at least suspect) that both GDBus and libdbus support
+ * passing the uid only on macOS. */
+ g_assert_cmpint (uid, ==, getuid ());
+ /* No pid here */
#else
g_test_message ("Please open a merge request to add appropriate "
"assertions for your platform");
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index 691506f0f..bb1d059ca 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -2434,7 +2434,7 @@ test_interface_stability (void)
*
* - check that a property with name "Type" is mapped into g-name "type"
* with C accessors get_type_ (to avoid clashing with the GType accessor)
- * and set_type_ (for symmetri)
+ * and set_type_ (for symmetry)
* (see https://bugzilla.gnome.org/show_bug.cgi?id=679473 for details)
*
* - (could add more tests here)
diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c
index 2b89fb079..4519fda91 100644
--- a/gio/tests/gdbus-threading.c
+++ b/gio/tests/gdbus-threading.c
@@ -409,7 +409,7 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
guint n, divisor;
/*
- * Check that multiple threads can do calls without interferring with
+ * Check that multiple threads can do calls without interfering with
* each other. We do this by creating three threads that call the
* Sleep() method on the server (which handles it asynchronously, e.g.
* it won't block other requests) with different sleep durations and
diff --git a/gio/tests/gsocketclient-slow.c b/gio/tests/gsocketclient-slow.c
index 4143bc3d8..34410f4cf 100644
--- a/gio/tests/gsocketclient-slow.c
+++ b/gio/tests/gsocketclient-slow.c
@@ -181,4 +181,4 @@ main (int argc, char *argv[])
return g_test_run ();
-} \ No newline at end of file
+}
diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c
index 400fa00a1..bccf6a308 100644
--- a/gio/tests/gsubprocess.c
+++ b/gio/tests/gsubprocess.c
@@ -1046,7 +1046,7 @@ test_communicate_utf8_async (gconstpointer test_data)
g_object_unref (proc);
}
-/* Test g_subprocess_communicate_utf8_async() can be cancelled correclty. */
+/* Test g_subprocess_communicate_utf8_async() can be cancelled correctly. */
static void
test_communicate_utf8_cancelled_async (gconstpointer test_data)
{
@@ -1721,7 +1721,7 @@ test_launcher_environment (void)
/* unset a variable */
g_subprocess_launcher_unsetenv (launcher, "A");
- /* and set a diffferent one */
+ /* and set a different one */
g_subprocess_launcher_setenv (launcher, "E", "F", TRUE);
args = get_test_subprocess_args ("printenv", "A", "C", "E", NULL);
diff --git a/gio/tests/gtlsconsoleinteraction.c b/gio/tests/gtlsconsoleinteraction.c
index ae734ba60..4a12ea860 100644
--- a/gio/tests/gtlsconsoleinteraction.c
+++ b/gio/tests/gtlsconsoleinteraction.c
@@ -32,7 +32,7 @@
/*
* WARNING: This is not the example you're looking for [slow hand wave]. This
- * is not industrial strength, it's just for testing. It uses embarassing
+ * is not industrial strength, it's just for testing. It uses embarrassing
* functions like getpass() and does lazy things with threads.
*/
diff --git a/gio/tests/live-g-file.txt b/gio/tests/live-g-file.txt
index 95da0e0ad..1873a0531 100644
--- a/gio/tests/live-g-file.txt
+++ b/gio/tests/live-g-file.txt
@@ -3,7 +3,7 @@ Before you start testing it would be good to explain how it works.
The script works in three modes:
1. read-only (no special arguments) - suitable for read-only backends. Just
create the sample structure using the second mode, pack it (tar -p is
- preffered to preserve unix modes) and put it on a reachable place.
+ preferred to preserve unix modes) and put it on a reachable place.
2. create-structure - only creates reference structure for later testing
in read-only mode
3. write mode - full test suite, creates testing structure and performs all
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 48891b06b..c7c3e3035 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -105,7 +105,7 @@ if not dbus1_dep.found()
# MSVC: Search for the DBus library by the configuration, which corresponds
# to the output of CMake builds of DBus. Note that debugoptimized
# is really a Release build with .PDB files.
- if buildtype == 'debug'
+ if vs_crt == 'debug'
dbus1_dep = cc.find_library('dbus-1d', required : false)
else
dbus1_dep = cc.find_library('dbus-1', required : false)
diff --git a/gio/tests/pollable.c b/gio/tests/pollable.c
index b8c8710bb..6b9d990f6 100644
--- a/gio/tests/pollable.c
+++ b/gio/tests/pollable.c
@@ -292,4 +292,3 @@ main (int argc,
return g_test_run();
}
-
diff --git a/gio/tests/proxy-test.c b/gio/tests/proxy-test.c
index 8f6dccf59..e3c0d09c7 100644
--- a/gio/tests/proxy-test.c
+++ b/gio/tests/proxy-test.c
@@ -1387,4 +1387,3 @@ main (int argc,
return result;
}
-
diff --git a/gio/tests/resourceplugin.c b/gio/tests/resourceplugin.c
index fc8d8d2f1..1f218f26f 100644
--- a/gio/tests/resourceplugin.c
+++ b/gio/tests/resourceplugin.c
@@ -4,7 +4,7 @@
* This must be done before including any GLib headers,
* since GLIB_AVAILABLE_IN_ALL, which is used to mark the
* g_io_module*() symbols, is defined to be _GLIB_EXTERN,
- * which must be overriden to export the symbols.
+ * which must be overridden to export the symbols.
*/
#include "modules/symbol-visibility.h"
#define _GLIB_EXTERN GLIB_TEST_EXPORT_SYMBOL
@@ -26,4 +26,3 @@ g_io_module_query (void)
{
return NULL;
}
-
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index c44d21485..0749b7d01 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -605,7 +605,7 @@ test_resource_binary_linked (void)
/* Test resource whose xml file starts with more than one digit
* and where no explicit c-name is given
- * Checks if resources are sucessfully registered and
+ * Checks if resources are successfully registered and
* data can be found and read. */
static void
test_resource_digits (void)
diff --git a/gio/tests/socket-listener.c b/gio/tests/socket-listener.c
index 31f94460e..71e70b28f 100644
--- a/gio/tests/socket-listener.c
+++ b/gio/tests/socket-listener.c
@@ -92,4 +92,3 @@ main (int argc,
return g_test_run();
}
-
diff --git a/gio/tests/socket-service.c b/gio/tests/socket-service.c
index dc8bdec23..f1dd783d1 100644
--- a/gio/tests/socket-service.c
+++ b/gio/tests/socket-service.c
@@ -63,7 +63,7 @@ test_start_stop (void)
saddr = g_inet_socket_address_new (iaddr, 0);
g_object_unref (iaddr);
- /* instanciate with g_object_new so we can pass active = false */
+ /* instantiate with g_object_new so we can pass active = false */
service = g_object_new (G_TYPE_SOCKET_SERVICE, "active", FALSE, NULL);
g_assert_false (g_socket_service_is_active (service));
diff --git a/gio/tests/socket.c b/gio/tests/socket.c
index e095d0195..d6eecdc38 100644
--- a/gio/tests/socket.c
+++ b/gio/tests/socket.c
@@ -1957,4 +1957,3 @@ main (int argc,
return g_test_run();
}
-
diff --git a/gio/tests/test2.gresource.xml b/gio/tests/test2.gresource.xml
index 0323b47ec..b6dca2b81 100644
--- a/gio/tests/test2.gresource.xml
+++ b/gio/tests/test2.gresource.xml
@@ -4,7 +4,7 @@
<file>test1.txt</file>
</gresource>
<!-- Test compiling the generated GResource C-code
- that has a resouce entry size over 65536 bytes -->
+ that has a resource entry size over 65536 bytes -->
<gresource prefix="/big_prefix">
<file>gresource-big-test.txt</file>
</gresource>
diff --git a/gio/tests/thumbnail-verification.c b/gio/tests/thumbnail-verification.c
index ef2ca70d7..d50638fe7 100644
--- a/gio/tests/thumbnail-verification.c
+++ b/gio/tests/thumbnail-verification.c
@@ -99,7 +99,11 @@ test_validity (void)
thumbnail_path = g_test_get_filename (G_TEST_DIST, "thumbnails",
tests[i].filename, NULL);
file_uri = g_strconcat ("file:///tmp/", tests[i].filename, NULL);
+#ifdef G_OS_WIN32
+ stat_buf.st_mtim.tv_sec = tests[i].mtime;
+#else
stat_buf.st_mtime = tests[i].mtime;
+#endif
stat_buf.st_size = tests[i].size;
result = thumbnail_verify (thumbnail_path, file_uri, &stat_buf);
diff --git a/gio/tests/tls-certificate.c b/gio/tests/tls-certificate.c
index e1ba23737..89e3d1421 100644
--- a/gio/tests/tls-certificate.c
+++ b/gio/tests/tls-certificate.c
@@ -285,7 +285,7 @@ from_files (const Reference *ref)
g_assert_null (cert);
/* 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
+ * certificate as a way to enforce private key presence is a fair use
*/
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DIST, "cert-tests", "key-cert.pem", NULL),
g_test_get_filename (G_TEST_DIST, "cert-tests", "key-cert.pem", NULL),
diff --git a/gio/tests/trash.c b/gio/tests/trash.c
index 4bf8fd0ef..adf729be2 100644
--- a/gio/tests/trash.c
+++ b/gio/tests/trash.c
@@ -211,4 +211,3 @@ main (int argc, char *argv[])
return g_test_run ();
}
-
diff --git a/gio/tests/volumemonitor.c b/gio/tests/volumemonitor.c
index 6b61c3070..e902eabf6 100644
--- a/gio/tests/volumemonitor.c
+++ b/gio/tests/volumemonitor.c
@@ -178,4 +178,3 @@ main (int argc, char *argv[])
return ret;
}
-
diff --git a/gio/tests/win32-appinfo.c b/gio/tests/win32-appinfo.c
index 78052c348..fa8aa2aaf 100644
--- a/gio/tests/win32-appinfo.c
+++ b/gio/tests/win32-appinfo.c
@@ -467,4 +467,3 @@ main (int argc,
return g_test_run ();
}
-