test: Add a test for "activate" hammering

This is what "terminator" (the terminal emulator) does, it basically
calls gdk_window_focus() in a loop thousands of times at startup.

This in turn fills up the Wayland connection between Xwayland and
mutter, and eventually the session dies.

See-also: https://github.com/gnome-terminator/terminator/issues/714
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
This commit is contained in:
Olivier Fourdan 2023-02-20 10:50:05 +01:00 committed by Marge Bot
parent 3be189192a
commit 4005fda902

View File

@ -214,6 +214,39 @@ meta_test_xwayland_crash_only_x11 (void)
meta_test_client_destroy (test_client2);
}
static void
meta_test_hammer_activate (void)
{
MetaTestClient *x11_client;
MetaTestClient *wayland_client;
g_autoptr (GError) error = NULL;
int i;
x11_client = meta_test_client_new (test_context, "x11-client",
META_WINDOW_CLIENT_TYPE_X11,
&error);
g_assert_nonnull (x11_client);
wayland_client = meta_test_client_new (test_context, "wayland-client",
META_WINDOW_CLIENT_TYPE_WAYLAND,
&error);
g_assert_nonnull (wayland_client);
meta_test_client_run (x11_client,
"create 1\n"
"show 1\n");
meta_test_client_run (wayland_client,
"create 2\n"
"show 2\n");
meta_test_client_run (x11_client, "activate 1");
for (i = 0; i < 10000; i++)
meta_test_client_run (wayland_client, "activate 2");
meta_test_client_destroy (x11_client);
meta_test_client_destroy (wayland_client);
}
static void
init_tests (void)
{
@ -221,6 +254,8 @@ init_tests (void)
meta_test_xwayland_restart_selection);
g_test_add_func ("/backends/xwayland/crash/only-x11",
meta_test_xwayland_crash_only_x11);
g_test_add_func ("/backends/xwayland/crash/hammer-activate",
meta_test_hammer_activate);
}
int