[glib: 1/3] tests: Fix small race in GSubprocess tests
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/3] tests: Fix small race in GSubprocess tests
- Date: Mon, 3 Jun 2019 10:39:43 +0000 (UTC)
commit 7f256e63d0d120f967cb8a15332c85920dba1be7
Author: Philip Withnall <withnall endlessm com>
Date: Fri May 31 23:35:27 2019 +0100
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>
gio/tests/gsubprocess.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c
index 52b06a2e6..400fa00a1 100644
--- a/gio/tests/gsubprocess.c
+++ b/gio/tests/gsubprocess.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]