Merge 0b0d373afa0cf6761cc377b14c27e7eee53317ab into 318e2d8f6cdaf0ffe532e301c7687aab321afc34
2 files · +15 -7
M internal/adapters/wayland/syncobj_test.go +3 -1
| @@ -443,7 +443,9 @@ func TestSyncobjProtocolErrors(t *testing.T) { | |||
| 443 | 443 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorUnsupportedBuffer)}, | |
| 444 | 444 | {"surface destroyed", func(h *syncHarness) { | |
| 445 | 445 | requestProtocol(t, h.c, h.surf, wayland.SurfaceRequestDestroy) | |
| 446 | - | h.setPoints(1, 2) | |
| 446 | + | // The first request already raises the error and the server | |
| 447 | + | // then closes the connection: a second write could hit EPIPE. | |
| 448 | + | requestProtocol(t, h.c, h.syncSurf, linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1RequestSetAcquirePoint, h.timeline, uint32(0), uint32(1)) | |
| 447 | 449 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorNoSurface)}, | |
| 448 | 450 | {"surface exists", func(h *syncHarness) { | |
| 449 | 451 | mgr := bindProtocol(t, h.c, "wp_linux_drm_syncobj_manager_v1") | |
| @@ -443,7 +443,9 @@ func TestSyncobjProtocolErrors(t *testing.T) { | |||||
| 443 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorUnsupportedBuffer)}, | 443 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorUnsupportedBuffer)}, | ||
| 444 | {"surface destroyed", func(h *syncHarness) { | 444 | {"surface destroyed", func(h *syncHarness) { | ||
| 445 | requestProtocol(t, h.c, h.surf, wayland.SurfaceRequestDestroy) | 445 | requestProtocol(t, h.c, h.surf, wayland.SurfaceRequestDestroy) | ||
| 446 | - | h.setPoints(1, 2) | 446 | + | // The first request already raises the error and the server |
| 447 | + | // then closes the connection: a second write could hit EPIPE. | |||
| 448 | + | requestProtocol(t, h.c, h.syncSurf, linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1RequestSetAcquirePoint, h.timeline, uint32(0), uint32(1)) | |||
| 447 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorNoSurface)}, | 449 | }, func(h *syncHarness) uint32 { return h.syncSurf }, uint32(linuxdrmsyncobj.WpLinuxDrmSyncobjSurfaceV1ErrorNoSurface)}, | ||
| 448 | {"surface exists", func(h *syncHarness) { | 450 | {"surface exists", func(h *syncHarness) { | ||
| 449 | mgr := bindProtocol(t, h.c, "wp_linux_drm_syncobj_manager_v1") | 451 | mgr := bindProtocol(t, h.c, "wp_linux_drm_syncobj_manager_v1") | ||
M internal/core/capture_test.go +12 -6
| @@ -68,6 +68,16 @@ func (r *captureRig) layer(id ports.WindowID, layer ports.Layer, keyboard uint32 | |||
| 68 | 68 | return ports.LayerSurface{ID: id, Layer: layer, Anchor: ports.AnchorTop | ports.AnchorLeft, Width: 10, Height: 10, Output: "OUT-1", Keyboard: keyboard} | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | + | // drainCommands drops the commands already queued. Call it only once the | |
| 72 | + | // core is quiet (after receiving a scene, which is published after its | |
| 73 | + | // commands) and before sending the event under test: draining after the | |
| 74 | + | // send races with the core emitting the commands the test waits for. | |
| 75 | + | func (r *captureRig) drainCommands() { | |
| 76 | + | for len(r.commands) > 0 { | |
| 77 | + | <-r.commands | |
| 78 | + | } | |
| 79 | + | } | |
| 80 | + | ||
| 71 | 81 | // excludedScene waits for a scene whose exclusion list has n entries. | |
| 72 | 82 | func (r *captureRig) excludedScene(t *testing.T, n int) ports.Scene { | |
| 73 | 83 | t.Helper() | |
| @@ -372,10 +382,8 @@ func TestCaptureExclusionKeyboardClamp(t *testing.T) { | |||
| 372 | 382 | r.client <- ports.CaptureExclusionBegin{Session: 1} | |
| 373 | 383 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | |
| 374 | 384 | r.excludedScene(t, 1) | |
| 385 | + | r.drainCommands() | |
| 375 | 386 | r.client <- ports.LayerChanged{Layers: []ports.LayerSurface{r.layer(10, ports.LayerOverlay, 1), r.layer(11, ports.LayerOverlay, 1)}} | |
| 376 | - | for len(r.commands) > 0 { | |
| 377 | - | <-r.commands | |
| 378 | - | } | |
| 379 | 387 | scene(t, r.scenes) | |
| 380 | 388 | for { | |
| 381 | 389 | if f, ok := receive(t, r.commands).(ports.FocusWindow); ok { | |
| @@ -396,9 +404,7 @@ func TestCaptureExclusionKeyboardNone(t *testing.T) { | |||
| 396 | 404 | r.client <- ports.CaptureExclusionBegin{Session: 1} | |
| 397 | 405 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | |
| 398 | 406 | r.excludedScene(t, 1) | |
| 399 | - | for len(r.commands) > 0 { | |
| 400 | - | <-r.commands | |
| 401 | - | } | |
| 407 | + | r.drainCommands() | |
| 402 | 408 | r.client <- ports.WindowMapped{ID: 1} | |
| 403 | 409 | scene(t, r.scenes) | |
| 404 | 410 | for len(r.commands) > 0 { | |
| @@ -68,6 +68,16 @@ func (r *captureRig) layer(id ports.WindowID, layer ports.Layer, keyboard uint32 | |||||
| 68 | return ports.LayerSurface{ID: id, Layer: layer, Anchor: ports.AnchorTop | ports.AnchorLeft, Width: 10, Height: 10, Output: "OUT-1", Keyboard: keyboard} | 68 | return ports.LayerSurface{ID: id, Layer: layer, Anchor: ports.AnchorTop | ports.AnchorLeft, Width: 10, Height: 10, Output: "OUT-1", Keyboard: keyboard} | ||
| 69 | } | 69 | } | ||
| 70 | 70 | ||||
| 71 | + | // drainCommands drops the commands already queued. Call it only once the | |||
| 72 | + | // core is quiet (after receiving a scene, which is published after its | |||
| 73 | + | // commands) and before sending the event under test: draining after the | |||
| 74 | + | // send races with the core emitting the commands the test waits for. | |||
| 75 | + | func (r *captureRig) drainCommands() { | |||
| 76 | + | for len(r.commands) > 0 { | |||
| 77 | + | <-r.commands | |||
| 78 | + | } | |||
| 79 | + | } | |||
| 80 | + | ||||
| 71 | // excludedScene waits for a scene whose exclusion list has n entries. | 81 | // excludedScene waits for a scene whose exclusion list has n entries. | ||
| 72 | func (r *captureRig) excludedScene(t *testing.T, n int) ports.Scene { | 82 | func (r *captureRig) excludedScene(t *testing.T, n int) ports.Scene { | ||
| 73 | t.Helper() | 83 | t.Helper() | ||
| @@ -372,10 +382,8 @@ func TestCaptureExclusionKeyboardClamp(t *testing.T) { | |||||
| 372 | r.client <- ports.CaptureExclusionBegin{Session: 1} | 382 | r.client <- ports.CaptureExclusionBegin{Session: 1} | ||
| 373 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | 383 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | ||
| 374 | r.excludedScene(t, 1) | 384 | r.excludedScene(t, 1) | ||
| 385 | + | r.drainCommands() | |||
| 375 | r.client <- ports.LayerChanged{Layers: []ports.LayerSurface{r.layer(10, ports.LayerOverlay, 1), r.layer(11, ports.LayerOverlay, 1)}} | 386 | r.client <- ports.LayerChanged{Layers: []ports.LayerSurface{r.layer(10, ports.LayerOverlay, 1), r.layer(11, ports.LayerOverlay, 1)}} | ||
| 376 | - | for len(r.commands) > 0 { | |||
| 377 | - | <-r.commands | |||
| 378 | - | } | |||
| 379 | scene(t, r.scenes) | 387 | scene(t, r.scenes) | ||
| 380 | for { | 388 | for { | ||
| 381 | if f, ok := receive(t, r.commands).(ports.FocusWindow); ok { | 389 | if f, ok := receive(t, r.commands).(ports.FocusWindow); ok { | ||
| @@ -396,9 +404,7 @@ func TestCaptureExclusionKeyboardNone(t *testing.T) { | |||||
| 396 | r.client <- ports.CaptureExclusionBegin{Session: 1} | 404 | r.client <- ports.CaptureExclusionBegin{Session: 1} | ||
| 397 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | 405 | r.client <- ports.CaptureExclusionLayer{Session: 1, Layer: 10, Attached: true} | ||
| 398 | r.excludedScene(t, 1) | 406 | r.excludedScene(t, 1) | ||
| 399 | - | for len(r.commands) > 0 { | 407 | + | r.drainCommands() |
| 400 | - | <-r.commands | |||
| 401 | - | } | |||
| 402 | r.client <- ports.WindowMapped{ID: 1} | 408 | r.client <- ports.WindowMapped{ID: 1} | ||
| 403 | scene(t, r.scenes) | 409 | scene(t, r.scenes) | ||
| 404 | for len(r.commands) > 0 { | 410 | for len(r.commands) > 0 { | ||