mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 11:42:10 +01:00
GTest: interpret child processes' wait status if we log their stdout/stderr
WCOREDUMP is not a separate "mode" as suggested by the previous code to interpret wait status: instead, it is an extra bit of information if the "mode" is WIFSIGNALED. (Modified by Philip Withnall to fix a nitpick missing space.) https://bugzilla.gnome.org/show_bug.cgi?id=748534
This commit is contained in:
parent
fa8b76ab98
commit
9c8c6094fd
@ -3141,6 +3141,49 @@ log_child_output (const gchar *process_id)
|
||||
{
|
||||
gchar *escaped;
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
if (WIFEXITED (test_trap_last_status)) /* normal exit */
|
||||
{
|
||||
if (WEXITSTATUS (test_trap_last_status) == 0)
|
||||
g_test_message ("child process (%s) exit status: 0 (success)",
|
||||
process_id);
|
||||
else
|
||||
g_test_message ("child process (%s) exit status: %d (error)",
|
||||
process_id, WEXITSTATUS (test_trap_last_status));
|
||||
}
|
||||
else if (WIFSIGNALED (test_trap_last_status) &&
|
||||
WTERMSIG (test_trap_last_status) == SIGALRM)
|
||||
{
|
||||
g_test_message ("child process (%s) timed out", process_id);
|
||||
}
|
||||
else if (WIFSIGNALED (test_trap_last_status))
|
||||
{
|
||||
const gchar *maybe_dumped_core = "";
|
||||
|
||||
#ifdef WCOREDUMP
|
||||
if (WCOREDUMP (test_trap_last_status))
|
||||
maybe_dumped_core = ", core dumped";
|
||||
#endif
|
||||
|
||||
g_test_message ("child process (%s) killed by signal %d (%s)%s",
|
||||
process_id, WTERMSIG (test_trap_last_status),
|
||||
g_strsignal (WTERMSIG (test_trap_last_status)),
|
||||
maybe_dumped_core);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_test_message ("child process (%s) unknown wait status %d",
|
||||
process_id, test_trap_last_status);
|
||||
}
|
||||
#else
|
||||
if (test_trap_last_status == 0)
|
||||
g_test_message ("child process (%s) exit status: 0 (success)",
|
||||
process_id);
|
||||
else
|
||||
g_test_message ("child process (%s) exit status: %d (error)",
|
||||
process_id, test_trap_last_status);
|
||||
#endif
|
||||
|
||||
escaped = g_strescape (test_trap_last_stdout, NULL);
|
||||
g_test_message ("child process (%s) stdout: \"%s\"", process_id, escaped);
|
||||
g_free (escaped);
|
||||
|
Loading…
x
Reference in New Issue
Block a user