tests/wayland-test-utils: Add helper to start a client with args
Add a helper function similar to meta_wayland_test_client_new() that allows to pass command line arguments to the test clients. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
This commit is contained in:
parent
bc8a376b81
commit
b4aba293b0
@ -62,8 +62,9 @@ wayland_test_client_finished (GObject *source_object,
|
||||
}
|
||||
|
||||
MetaWaylandTestClient *
|
||||
meta_wayland_test_client_new (MetaContext *context,
|
||||
const char *test_client_name)
|
||||
meta_wayland_test_client_new_with_args (MetaContext *context,
|
||||
const char *test_client_name,
|
||||
...)
|
||||
{
|
||||
MetaWaylandCompositor *compositor;
|
||||
const char *wayland_display_name;
|
||||
@ -72,6 +73,9 @@ meta_wayland_test_client_new (MetaContext *context,
|
||||
GSubprocess *subprocess;
|
||||
GError *error = NULL;
|
||||
MetaWaylandTestClient *wayland_test_client;
|
||||
g_autoptr (GPtrArray) args = NULL;
|
||||
const gchar *arg;
|
||||
va_list ap;
|
||||
|
||||
compositor = meta_context_get_wayland_compositor (context);
|
||||
wayland_display_name = meta_wayland_get_wayland_display_name (compositor);
|
||||
@ -85,10 +89,19 @@ meta_wayland_test_client_new (MetaContext *context,
|
||||
"G_MESSAGES_DEBUG", "all",
|
||||
TRUE);
|
||||
|
||||
subprocess = g_subprocess_launcher_spawn (launcher,
|
||||
&error,
|
||||
test_client_path,
|
||||
NULL);
|
||||
va_start (ap, test_client_name);
|
||||
args = g_ptr_array_new ();
|
||||
g_ptr_array_add (args, (char *) test_client_path);
|
||||
|
||||
while ((arg = va_arg (ap, const gchar *)))
|
||||
g_ptr_array_add (args, (gchar *) arg);
|
||||
|
||||
g_ptr_array_add (args, NULL);
|
||||
va_end (ap);
|
||||
|
||||
subprocess = g_subprocess_launcher_spawnv (launcher,
|
||||
(const gchar * const *) args->pdata,
|
||||
&error);
|
||||
if (!subprocess)
|
||||
{
|
||||
g_error ("Failed to launch Wayland test client '%s': %s",
|
||||
@ -106,6 +119,15 @@ meta_wayland_test_client_new (MetaContext *context,
|
||||
return wayland_test_client;
|
||||
}
|
||||
|
||||
MetaWaylandTestClient *
|
||||
meta_wayland_test_client_new (MetaContext *context,
|
||||
const char *test_client_name)
|
||||
{
|
||||
return meta_wayland_test_client_new_with_args (context,
|
||||
test_client_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_test_client_destroy (MetaWaylandTestClient *wayland_test_client)
|
||||
{
|
||||
|
@ -24,6 +24,10 @@ typedef struct _MetaWaylandTestClient MetaWaylandTestClient;
|
||||
MetaWaylandTestClient * meta_wayland_test_client_new (MetaContext *context,
|
||||
const char *test_client_name);
|
||||
|
||||
MetaWaylandTestClient * meta_wayland_test_client_new_with_args (MetaContext *context,
|
||||
const char *test_client_name,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void meta_wayland_test_client_finish (MetaWaylandTestClient *wayland_test_client);
|
||||
|
||||
MetaWindow * meta_find_client_window (MetaContext *context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user