mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 07:30:42 -05:00
tests/test-client: Add 'stop_after_next' and 'continue' commands
The 'stop_after_next' will execeute one command, then not return to the main loop until a 'continue' command is passed. Commands will still be processed between 'stop_after_next' and 'continue'. This is intended to be used to induce race conditions. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
This commit is contained in:
parent
2eda6d0a7c
commit
028ed0685d
@ -34,6 +34,7 @@ GHashTable *windows;
|
||||
GQuark event_source_quark;
|
||||
GQuark event_handlers_quark;
|
||||
GQuark can_take_focus_quark;
|
||||
gboolean sync_after_lines = -1;
|
||||
|
||||
typedef void (*XEventHandler) (GtkWidget *window, XEvent *event);
|
||||
|
||||
@ -824,6 +825,26 @@ process_line (const char *line)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (strcmp (argv[0], "stop_after_next") == 0)
|
||||
{
|
||||
if (sync_after_lines != -1)
|
||||
{
|
||||
g_print ("Can't invoke 'stop_after_next' while already stopped");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sync_after_lines = 1;
|
||||
}
|
||||
else if (strcmp (argv[0], "continue") == 0)
|
||||
{
|
||||
if (sync_after_lines != 0)
|
||||
{
|
||||
g_print ("Can only invoke 'continue' while stopped");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sync_after_lines = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("Unknown command %s\n", argv[0]);
|
||||
@ -862,6 +883,30 @@ on_line_received (GObject *source,
|
||||
static void
|
||||
read_next_line (GDataInputStream *in)
|
||||
{
|
||||
while (sync_after_lines == 0)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autofree char *line = NULL;
|
||||
size_t length;
|
||||
|
||||
gdk_display_flush (display);
|
||||
|
||||
line = g_data_input_stream_read_line (in, &length, NULL, &error);
|
||||
if (!line)
|
||||
{
|
||||
if (error)
|
||||
g_printerr ("Error reading from stdin: %s\n", error->message);
|
||||
gtk_main_quit ();
|
||||
return;
|
||||
}
|
||||
|
||||
process_line (line);
|
||||
}
|
||||
|
||||
if (sync_after_lines >= 0)
|
||||
sync_after_lines--;
|
||||
|
||||
g_data_input_stream_read_line_async (in, G_PRIORITY_DEFAULT, NULL,
|
||||
on_line_received, NULL);
|
||||
}
|
||||
|
@ -960,6 +960,19 @@ test_case_do (TestCase *test,
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (strcmp (argv[0], "stop_after_next") == 0 ||
|
||||
strcmp (argv[0], "continue") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <client-id>", argv[0]);
|
||||
|
||||
MetaTestClient *client = test_case_lookup_client (test, argv[1], error);
|
||||
if (!client)
|
||||
return FALSE;
|
||||
|
||||
if (!meta_test_client_do (client, error, argv[0], NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user