1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-03-15 20:25:12 +01:00

Merge branch 'gsubprocess-test-fix' into 'master'

tests: Fix small race in GSubprocess tests

See merge request 
This commit is contained in:
Sebastian Dröge 2019-06-03 10:39:26 +00:00
commit 645dcc232c
2 changed files with 9 additions and 3 deletions

@ -749,6 +749,11 @@ g_subprocess_newv (const gchar * const *argv,
* *
* On UNIX, returns the process ID as a decimal string. * On UNIX, returns the process ID as a decimal string.
* On Windows, returns the result of GetProcessId() also as a string. * On Windows, returns the result of GetProcessId() also as a string.
* If the subprocess has terminated, this will return %NULL.
*
* Returns: (nullable): the subprocess identifier, or %NULL if the subprocess
* has terminated
* Since: 2.40
*/ */
const gchar * const gchar *
g_subprocess_get_identifier (GSubprocess *subprocess) g_subprocess_get_identifier (GSubprocess *subprocess)

@ -66,14 +66,11 @@ test_noop (void)
GError **error = &local_error; GError **error = &local_error;
GPtrArray *args; GPtrArray *args;
GSubprocess *proc; GSubprocess *proc;
const gchar *id;
args = get_test_subprocess_args ("noop", NULL); args = get_test_subprocess_args ("noop", NULL);
proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error); proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error);
g_ptr_array_free (args, TRUE); g_ptr_array_free (args, TRUE);
g_assert_no_error (local_error); g_assert_no_error (local_error);
id = g_subprocess_get_identifier (proc);
g_assert_nonnull (id);
g_subprocess_wait_check (proc, NULL, error); g_subprocess_wait_check (proc, NULL, error);
g_assert_no_error (local_error); g_assert_no_error (local_error);
@ -1297,12 +1294,16 @@ test_terminate (void)
GSubprocess *proc; GSubprocess *proc;
GPtrArray *args; GPtrArray *args;
GMainLoop *loop; GMainLoop *loop;
const gchar *id;
args = get_test_subprocess_args ("sleep-forever", NULL); args = get_test_subprocess_args ("sleep-forever", NULL);
proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error); proc = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error);
g_ptr_array_free (args, TRUE); g_ptr_array_free (args, TRUE);
g_assert_no_error (local_error); g_assert_no_error (local_error);
id = g_subprocess_get_identifier (proc);
g_assert_nonnull (id);
loop = g_main_loop_new (NULL, TRUE); loop = g_main_loop_new (NULL, TRUE);
g_subprocess_wait_async (proc, NULL, on_request_quit_exited, loop); g_subprocess_wait_async (proc, NULL, on_request_quit_exited, loop);