Skip to content
Snippets Groups Projects
Commit d75e8d25 authored by Simon McVittie's avatar Simon McVittie
Browse files

utils: Tolerate G_SPAWN_ERROR_FAILED from pv_capture_output()


If we don't use a child setup function, then GLib can go into a more
optimized code path involving posix_spawn(), where we don't get
detailed error reporting.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 8af71a32
No related branches found
No related tags found
1 merge request!204pressure-vessel: Let short-term subprocesses inherit non-CLOEXEC fds
...@@ -105,7 +105,25 @@ test_capture_output (Fixture *f, ...@@ -105,7 +105,25 @@ test_capture_output (Fixture *f,
argv[0] = "/nonexistent/doesnotexist"; argv[0] = "/nonexistent/doesnotexist";
output = pv_capture_output (argv, &error); output = pv_capture_output (argv, &error);
g_assert_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT); g_assert_nonnull (error);
if (error->domain == G_SPAWN_ERROR
&& error->code == G_SPAWN_ERROR_NOENT)
{
/* OK: specific failure could be reported */
}
else if (error->domain == G_SPAWN_ERROR
&& error->code == G_SPAWN_ERROR_FAILED)
{
/* less specific, but also OK */
}
else
{
g_error ("Expected pv_capture_output() with nonexistent executable "
"to fail, got %s #%d",
g_quark_to_string (error->domain), error->code);
}
g_assert_cmpstr (output, ==, NULL); g_assert_cmpstr (output, ==, NULL);
g_clear_error (&error); g_clear_error (&error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment