[glib] GTest: interpret child processes' wait status if we log their stdout/stderr
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GTest: interpret child processes' wait status if we log their stdout/stderr
- Date: Wed, 13 Dec 2017 17:42:24 +0000 (UTC)
commit 9c8c6094fdb3b7bff35c0f36a68e1da3fd2e8ff7
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Wed Apr 29 12:54:40 2015 +0100
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
glib/gtestutils.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index bde733b..131c7c6 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]