From 239a901bbfb7f348b69355101435debac1ea9e97 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 18 Feb 2024 23:46:26 +0000 Subject: [PATCH] tests: add a repro for #1091 Signed-off-by: Yuxuan Shui --- tests/configs/pull1091.conf | 1 + tests/run_tests.sh | 1 + tests/testcases/common.py | 8 ++++++-- tests/testcases/issue314.py | 2 +- tests/testcases/pull1091.py | 41 +++++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 tests/configs/pull1091.conf create mode 100755 tests/testcases/pull1091.py diff --git a/tests/configs/pull1091.conf b/tests/configs/pull1091.conf new file mode 100644 index 00000000..37141aba --- /dev/null +++ b/tests/configs/pull1091.conf @@ -0,0 +1 @@ +unredir-if-possible = true; diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 6a5a6b3f..e74fcdd4 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -20,3 +20,4 @@ eval `dbus-launch --sh-syntax` ./run_one_test.sh $exe configs/clear_shadow_unredirected.conf testcases/redirect_when_unmapped_window_has_shadow.py ./run_one_test.sh $exe configs/issue394.conf testcases/issue394.py ./run_one_test.sh $exe configs/issue239.conf testcases/issue525.py +./run_one_test.sh $exe configs/pull1091.conf testcases/pull1091.py diff --git a/tests/testcases/common.py b/tests/testcases/common.py index 8214aff0..f4d5076a 100644 --- a/tests/testcases/common.py +++ b/tests/testcases/common.py @@ -33,6 +33,10 @@ def set_window_size_async(conn, wid, width, height): value_list = [width, height] return conn.core.ConfigureWindowChecked(wid, value_mask, value_list) +def set_window_bypass_compositor(conn, wid, value = 1): + prop_name = to_atom(conn, "_NET_WM_BYPASS_COMPOSITOR") + return conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, xproto.Atom.CARDINAL, 32, 1, [value]) + def find_picom_window(conn): prop_name = to_atom(conn, "WM_NAME") setup = conn.get_setup() @@ -45,13 +49,13 @@ def find_picom_window(conn): if name.value.buf() == b"picom": return w -def prepare_root_configure(conn): +def prepare_root_configure(conn, size = 1000): setup = conn.get_setup() root = setup.roots[0].root # Xorg sends root ConfigureNotify when we add a new mode to an output rr = conn(randr.key) name = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(0, 32)]) - mode_info = randr.ModeInfo.synthetic(id = 0, width = 1000, height = 1000, dot_clock = 0, + mode_info = randr.ModeInfo.synthetic(id = 0, width = size, height = size, dot_clock = 0, hsync_start = 0, hsync_end = 0, htotal = 0, hskew = 0, vsync_start = 0, vsync_end = 0, vtotal = 0, name_len = len(name), mode_flags = 0) diff --git a/tests/testcases/issue314.py b/tests/testcases/issue314.py index d10b9533..acc9142d 100755 --- a/tests/testcases/issue314.py +++ b/tests/testcases/issue314.py @@ -3,7 +3,7 @@ import xcffib.xproto as xproto import xcffib import time -from common import set_window_name, trigger_root_configure +from common import set_window_name conn = xcffib.connect() setup = conn.get_setup() diff --git a/tests/testcases/pull1091.py b/tests/testcases/pull1091.py new file mode 100755 index 00000000..880c7250 --- /dev/null +++ b/tests/testcases/pull1091.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import xcffib.xproto as xproto +import xcffib +from common import * + +conn = xcffib.connect() +setup = conn.get_setup() +root = setup.roots[0].root +visual = setup.roots[0].root_visual +depth = setup.roots[0].root_depth + +# assertion failure mentioned in 1091 happens when a root change happens right after we +# redirected the screen, before we have even rendered a single frame +wid = conn.generate_id() +print("Window id is ", hex(wid)) + +# Create a window +conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check() + +# Map the window +print("mapping") +conn.core.MapWindowChecked(wid).check() + +time.sleep(0.5) + +for i in range(0, 8): + modes = [] + for s in range(0, 10): + reply, mode, output = prepare_root_configure(conn, i * 100 + 100 + s) + modes.append((reply, mode, output)) + + set_window_bypass_compositor(conn, wid).check() + time.sleep(0.1) + + set_window_bypass_compositor(conn, wid, 0) + conn.flush() + for reply, mode, output in modes: + trigger_root_configure(conn, reply, mode, output).reply() + + time.sleep(0.1)