mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 18:26:19 +01:00
g_test_subprocess: record raw wait status and interpret it later
This avoids losing information that might be useful for later debugging. (Modified by Philip Withnall to add comments to child_status and test_trap_last_status.) https://bugzilla.gnome.org/show_bug.cgi?id=748534
This commit is contained in:
parent
0c0b1bdd0a
commit
fa8b76ab98
@ -759,7 +759,7 @@ static double test_user_stamp = 0;
|
|||||||
static GSList *test_paths = NULL;
|
static GSList *test_paths = NULL;
|
||||||
static GSList *test_paths_skipped = NULL;
|
static GSList *test_paths_skipped = NULL;
|
||||||
static GTestSuite *test_suite_root = NULL;
|
static GTestSuite *test_suite_root = NULL;
|
||||||
static int test_trap_last_status = 0;
|
static int test_trap_last_status = 0; /* unmodified platform-specific status */
|
||||||
static GPid test_trap_last_pid = 0;
|
static GPid test_trap_last_pid = 0;
|
||||||
static char *test_trap_last_subprocess = NULL;
|
static char *test_trap_last_subprocess = NULL;
|
||||||
static char *test_trap_last_stdout = NULL;
|
static char *test_trap_last_stdout = NULL;
|
||||||
@ -2673,7 +2673,7 @@ sane_dup2 (int fd1,
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
GPid pid;
|
GPid pid;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
int child_status;
|
int child_status; /* unmodified platform-specific status */
|
||||||
|
|
||||||
GIOChannel *stdout_io;
|
GIOChannel *stdout_io;
|
||||||
gboolean echo_stdout;
|
gboolean echo_stdout;
|
||||||
@ -2698,18 +2698,8 @@ child_exited (GPid pid,
|
|||||||
{
|
{
|
||||||
WaitForChildData *data = user_data;
|
WaitForChildData *data = user_data;
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
g_assert (status != -1);
|
||||||
if (WIFEXITED (status)) /* normal exit */
|
|
||||||
data->child_status = WEXITSTATUS (status); /* 0..255 */
|
|
||||||
else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGALRM)
|
|
||||||
data->child_status = G_TEST_STATUS_TIMED_OUT;
|
|
||||||
else if (WIFSIGNALED (status))
|
|
||||||
data->child_status = (WTERMSIG (status) << 12); /* signalled */
|
|
||||||
else /* WCOREDUMP (status) */
|
|
||||||
data->child_status = 512; /* coredump */
|
|
||||||
#else
|
|
||||||
data->child_status = status;
|
data->child_status = status;
|
||||||
#endif
|
|
||||||
|
|
||||||
check_complete (data);
|
check_complete (data);
|
||||||
}
|
}
|
||||||
@ -3118,7 +3108,12 @@ g_test_subprocess (void)
|
|||||||
gboolean
|
gboolean
|
||||||
g_test_trap_has_passed (void)
|
g_test_trap_has_passed (void)
|
||||||
{
|
{
|
||||||
return test_trap_last_status == 0; /* exit_status == 0 && !signal && !coredump */
|
#ifdef G_OS_UNIX
|
||||||
|
return (WIFEXITED (test_trap_last_status) &&
|
||||||
|
WEXITSTATUS (test_trap_last_status) == 0);
|
||||||
|
#else
|
||||||
|
return test_trap_last_status == 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3133,7 +3128,12 @@ g_test_trap_has_passed (void)
|
|||||||
gboolean
|
gboolean
|
||||||
g_test_trap_reached_timeout (void)
|
g_test_trap_reached_timeout (void)
|
||||||
{
|
{
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
return (WIFSIGNALED (test_trap_last_status) &&
|
||||||
|
WTERMSIG (test_trap_last_status) == SIGALRM);
|
||||||
|
#else
|
||||||
return test_trap_last_status == G_TEST_STATUS_TIMED_OUT;
|
return test_trap_last_status == G_TEST_STATUS_TIMED_OUT;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user