[libgdata] tests: Add one more test for GDataBuffer
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] tests: Add one more test for GDataBuffer
- Date: Tue, 23 Aug 2016 06:37:49 +0000 (UTC)
commit 4b29a94a71317ffa9df282fef7f7be126687343a
Author: Ondrej Holy <oholy redhat com>
Date: Mon Aug 22 12:02:44 2016 +0200
tests: Add one more test for GDataBuffer
This test reproduces bug 769727.
https://bugzilla.gnome.org/show_bug.cgi?id=769727
gdata/tests/buffer.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gdata/tests/buffer.c b/gdata/tests/buffer.c
index 02012d6..c4e9d13 100644
--- a/gdata/tests/buffer.c
+++ b/gdata/tests/buffer.c
@@ -74,6 +74,41 @@ test_buffer_instant_eof (Fixture *f, gconstpointer user_data)
gdata_buffer_free (buffer);
}
+static gpointer
+test_buffer_thread_eof_func (gpointer user_data)
+{
+ GDataBuffer *buffer = user_data;
+
+ /* HACK: Wait for a while to be sure that gdata_buffer_pop_data() has
+ * been already called. */
+ g_usleep (G_USEC_PER_SEC / 2);
+
+ g_assert_false (gdata_buffer_push_data (buffer, NULL, 0));
+
+ return NULL;
+}
+
+/* The test needs to call gdata_buffer_push_data() from another thread only
+ * once gdata_buffer_pop_data() has reached its blocking loop. */
+static void
+test_buffer_thread_eof (Fixture *f, gconstpointer user_data)
+{
+ GDataBuffer *buffer = NULL; /* owned */
+ gboolean reached_eof = FALSE;
+ guint8 buf[1];
+
+ g_test_bug ("769727");
+
+ buffer = gdata_buffer_new ();
+
+ g_thread_new (NULL, test_buffer_thread_eof_func, buffer);
+ g_assert_cmpuint (gdata_buffer_pop_data (buffer, buf, sizeof (buf),
+ &reached_eof, NULL), ==, 0);
+ g_assert_true (reached_eof);
+
+ gdata_buffer_free (buffer);
+}
+
static void
test_buffer_basic (Fixture *f, gconstpointer user_data)
{
@@ -121,6 +156,8 @@ main (int argc, char *argv[])
set_up, test_buffer_construction, tear_down);
g_test_add ("/buffer/instant-eof", Fixture, NULL,
set_up, test_buffer_instant_eof, tear_down);
+ g_test_add ("/buffer/thread-eof", Fixture, NULL,
+ set_up, test_buffer_thread_eof, tear_down);
g_test_add ("/buffer/basic", Fixture, NULL,
set_up, test_buffer_basic, tear_down);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]