test: fix two race conditions waiting for proximity events
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2024 05:10:11 +0000 (15:10 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2024 05:58:31 +0000 (15:58 +1000)
This test does a prox in/out and immediately drains events.
Where we are slow enough we may drain only one (or none) of the
proximity events which causes a failure later in the test.

Similar issue with the second test where we may get a delayed tip event.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1074>

test/test-tablet.c

index d5696c8ec2cea6a89854d1ee2323ef4b85d3e8de..07a14dc46c1fcb9911e5172c8e3a0181efead40b 100644 (file)
@@ -3775,6 +3775,7 @@ START_TEST(tablet_calibration_set_matrix_delta)
        dy = libinput_event_tablet_tool_get_y(tablet_event) - y;
        libinput_event_destroy(event);
        litest_tablet_proximity_out(dev);
+       litest_wait_for_event_of_type(li, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
        litest_drain_events(li);
 
        status = libinput_device_config_calibration_set_matrix(d,
@@ -3857,6 +3858,8 @@ START_TEST(tablet_calibration_set_matrix)
        litest_dispatch(li);
        litest_tablet_proximity_in(dev, 50, 50, axes);
        litest_tablet_proximity_out(dev);
+       litest_wait_for_event_of_type(li, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+       litest_wait_for_event_of_type(li, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
        litest_drain_events(li);
 
        calibration[0] = 1;