Commit 9da88a12 authored by Allison Karlitskaya's avatar Allison Karlitskaya

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
parent 9f71965b
......@@ -753,6 +753,34 @@ test_communicate_utf8 (void)
g_object_unref (proc);
}
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)
{
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment