[glib] gsubprocess: test empty splices



commit 9da88a12c52f122e1e2b8faaed6c95ec1bcef104
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Mar 3 21:25:16 2014 -0500

    gsubprocess: test empty splices
    
    Make sure we handle the case that our splice returns no data properly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724916

 gio/tests/gsubprocess.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c
index 15bef59..199404f 100644
--- a/gio/tests/gsubprocess.c
+++ b/gio/tests/gsubprocess.c
@@ -754,6 +754,34 @@ test_communicate_utf8 (void)
 }
 
 static void
+test_communicate_nothing (void)
+{
+  GError *error = NULL;
+  GPtrArray *args;
+  GSubprocess *proc;
+  GCancellable *cancellable = NULL;
+  gchar *stdout_buf;
+
+  args = get_test_subprocess_args ("cat", NULL);
+  proc = g_subprocess_newv ((const gchar* const*)args->pdata,
+                            G_SUBPROCESS_FLAGS_STDIN_PIPE
+                            | G_SUBPROCESS_FLAGS_STDOUT_PIPE
+                            | G_SUBPROCESS_FLAGS_STDERR_MERGE,
+                            &error);
+  g_assert_no_error (error);
+  g_ptr_array_free (args, TRUE);
+
+  g_subprocess_communicate_utf8 (proc, "", cancellable, &stdout_buf, NULL, &error);
+  g_assert_no_error (error);
+
+  g_assert_cmpstr (stdout_buf, ==, "");
+
+  g_free (stdout_buf);
+
+  g_object_unref (proc);
+}
+
+static void
 test_communicate_utf8_invalid (void)
 {
   GError *error = NULL;
@@ -1201,6 +1229,7 @@ main (int argc, char **argv)
   g_test_add_func ("/gsubprocess/communicate-utf8", test_communicate_utf8);
   g_test_add_func ("/gsubprocess/communicate-utf8-async", test_communicate_utf8_async);
   g_test_add_func ("/gsubprocess/communicate-utf8-invalid", test_communicate_utf8_invalid);
+  g_test_add_func ("/gsubprocess/communicate-nothing", test_communicate_nothing);
   g_test_add_func ("/gsubprocess/terminate", test_terminate);
   g_test_add_func ("/gsubprocess/env", test_env);
   g_test_add_func ("/gsubprocess/cwd", test_cwd);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]