[mutter] tests/test-client: Add 'stop_after_next' and 'continue' commands
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/test-client: Add 'stop_after_next' and 'continue' commands
- Date: Wed, 17 Nov 2021 10:13:37 +0000 (UTC)
commit 028ed0685d5686ad906146da1a09dfadccbbab49
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Oct 29 21:18:56 2021 +0200
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>
src/tests/test-client.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/tests/test-runner.c | 13 +++++++++++++
2 files changed, 58 insertions(+)
---
diff --git a/src/tests/test-client.c b/src/tests/test-client.c
index 73931375e9..ac2431a50d 100644
--- a/src/tests/test-client.c
+++ b/src/tests/test-client.c
@@ -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);
}
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 34cae67e43..edaf84f81b 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -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]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]