typedef struct {
gboolean is_utf8;
- gboolean is_invalid_utf8;
gboolean running;
GError *error;
} TestAsyncCommunicateData;
else
(void) g_subprocess_communicate_finish ((GSubprocess*)proc, result,
&stdout, NULL, &data->error);
- if (data->is_invalid_utf8)
- {
- g_assert_error (data->error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ if (data->error)
return;
- }
-
- g_assert_no_error (data->error);
if (!data->is_utf8)
{
static void
test_communicate (void)
{
- GError *local_error = NULL;
- GError **error = &local_error;
+ GError *error = NULL;
GPtrArray *args;
TestAsyncCommunicateData data = { 0, };
GSubprocess *proc;
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,
- error);
- g_assert_no_error (local_error);
+ &error);
+ g_assert_no_error (error);
g_ptr_array_free (args, TRUE);
hellostring = "hello world";
input = g_bytes_new_static (hellostring, strlen (hellostring));
- data.error = local_error;
g_subprocess_communicate_async (proc, input,
cancellable,
on_communicate_complete,
while (data.running)
g_main_context_iteration (NULL, TRUE);
- g_assert_no_error (local_error);
+ g_assert_no_error (data.error);
g_object_unref (proc);
}
static void
test_communicate_utf8 (void)
{
- GError *local_error = NULL;
- GError **error = &local_error;
+ GError *error = NULL;
GPtrArray *args;
TestAsyncCommunicateData data = { 0, };
GSubprocess *proc;
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,
- error);
- g_assert_no_error (local_error);
+ &error);
+ g_assert_no_error (error);
g_ptr_array_free (args, TRUE);
- data.error = local_error;
data.is_utf8 = TRUE;
g_subprocess_communicate_utf8_async (proc, "hello world",
cancellable,
while (data.running)
g_main_context_iteration (NULL, TRUE);
- g_assert_no_error (local_error);
+ g_assert_no_error (data.error);
g_object_unref (proc);
}
static void
test_communicate_utf8_invalid (void)
{
- GError *local_error = NULL;
- GError **error = &local_error;
+ GError *error = NULL;
GPtrArray *args;
TestAsyncCommunicateData data = { 0, };
GSubprocess *proc;
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,
- error);
- g_assert_no_error (local_error);
+ &error);
+ g_assert_no_error (error);
g_ptr_array_free (args, TRUE);
- data.error = local_error;
data.is_utf8 = TRUE;
- data.is_invalid_utf8 = TRUE;
g_subprocess_communicate_utf8_async (proc, "\xFF\xFF",
cancellable,
on_communicate_complete,
while (data.running)
g_main_context_iteration (NULL, TRUE);
- g_assert_no_error (local_error);
+ g_assert_error (data.error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ g_error_free (data.error);
g_object_unref (proc);
}