mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
tests: Fix small race in GSubprocess tests
This was introduced in commit 7846d6154a
: g_subprocess_get_identifier()
will return NULL after the subprocess has exited, and the subprocess in
the `noop` test will exit as soon as it has started spawning. So if the
scheduler scheduled the testprog subprocess quickly, descheduled the
parent test process until the testprog exited, then the return value
from g_subprocess_get_identifier() would be NULL.
Move the g_subprocess_get_identifier() test to one which calls testprog
in `sleep-forever` mode, since that is guaranteed not to exit until
killed (which we do later in the test).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
e6a55def7d
commit
7f256e63d0
@ -66,14 +66,11 @@ test_noop (void)
|
||||
GError **error = &local_error;
|
||||
GPtrArray *args;
|
||||
GSubprocess *proc;
|
||||
const gchar *id;
|
||||
|
||||
args = get_test_subprocess_args ("noop", NULL);
|
||||
proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error);
|
||||
g_ptr_array_free (args, TRUE);
|
||||
g_assert_no_error (local_error);
|
||||
id = g_subprocess_get_identifier (proc);
|
||||
g_assert_nonnull (id);
|
||||
|
||||
g_subprocess_wait_check (proc, NULL, error);
|
||||
g_assert_no_error (local_error);
|
||||
@ -1297,12 +1294,16 @@ test_terminate (void)
|
||||
GSubprocess *proc;
|
||||
GPtrArray *args;
|
||||
GMainLoop *loop;
|
||||
const gchar *id;
|
||||
|
||||
args = get_test_subprocess_args ("sleep-forever", NULL);
|
||||
proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error);
|
||||
g_ptr_array_free (args, TRUE);
|
||||
g_assert_no_error (local_error);
|
||||
|
||||
id = g_subprocess_get_identifier (proc);
|
||||
g_assert_nonnull (id);
|
||||
|
||||
loop = g_main_loop_new (NULL, TRUE);
|
||||
|
||||
g_subprocess_wait_async (proc, NULL, on_request_quit_exited, loop);
|
||||
|
Loading…
Reference in New Issue
Block a user