Commit graph

36 commits

Author SHA1 Message Date
Axel Karjalainen
e3e143ea42 test: fix false fail by actually looking for unbound capability mask
The previous implementation of
`test_seat_bind_invalid_caps_expect_disconnection`
didn't follow the protocol specification and assumed that `0x1` was
invalid.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/354>
2025-08-05 02:02:38 +03:00
Ian Douglas Scott
500ad0510f test: Advertise scroll/button interfaces in test_connect_receive_seat
This test was checking for the capabilities for `EI_SCROLL` and
`EI_BUTTON`, but not advertising those interfaces initially. Presumably
this was unintentional, given there's no comment that it's intentionally
advertising some protocols but not others.

Also, should the test have failed to find the capabilities when it
didn't advertise the protocol to to start with? This change just fixes
the test, anyway.

This was causing the test to fail for `reis` CI in a proposed change in
https://github.com/ids1024/reis/pull/11.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/352>
2025-07-31 19:33:26 -07:00
Eric Long
e147d4311f test: increase protocol-test-valgrind timeout
Currently libei's valgrind test setup has 100x timeout (3000s), but the
standalone protocol-test-valgrind still has 30s timeout, which is not enough
for RISC-V hardware. On Milk-V Pioneer (SG2042) it takes ~70s to complete. In
addition, `kill_gently` sends SIGKILL before the process terminates and fails
the test.

Bump protocol-test-valgrind timeout to 300s and increase timeout between kill
signals to 3s to solve the issue.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/329>
2025-04-11 15:32:20 +08:00
Peter Hutterer
76845ecdfe Reformat for ruff 0.9
New formatting rules, apparently.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/325>
2025-02-03 13:17:34 +10:00
Peter Hutterer
b1c1c5d579 Add the ei_touchscreen.cancel event and ei_touch_cancel()
In the protocol it's a new request/event that is sent instead of the
touch up event.

In the library this is implemented as ei_touch_cancel() which
transparently sends cancel() or up depending on the EIS implementation
support. This is mirrored for the EIS implementation.

Where touch cancel is received as an event it is presented
as EI_EVENT_TOUCH_UP with an ei_event_touch_is_cancel() flag to
check if it was a cancel. This is required for backwards compatbility,
we cannot replace the TOUCH_UP event with a TOUCH_CANCEL event without
breaking existing callers. To add a new event type we would need clients
announcing support for those event types but that's an effort that's
better postponed until we have a stronger need for it (see #68).

Closes #60

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/308>
2024-12-17 15:12:56 +10:00
Peter Hutterer
504afdea4a test: drop the use of attr
All our uses can be done with dataclasses so we don't need an external
package.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/319>
2024-12-10 05:06:49 +00:00
Peter Hutterer
9ee33b019f test: fix a spuriously failing timeout
When running repeated tests in parallel, this one eventually fails
because the ei.send() doesn't trigger the expected BrokenPipeError.
Use ei.dispatch() instaed and check whether the connection still exists.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
60bc264e75 test: ignore a failure to send a pong
Our automatic pong handler unconditionally sends a Pong back to the EIS
implementation. For some tests and depending on timing we may have
been disconnected already, resulting in a BrokenPipeError that fails
us the test. Ignore that error.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
96f20ae333 test: ignore a ConnectionResetError during our dispatch
If our server disconnects us with data still in the pipe we never picked
up on that data causing heisenbugs depending on whether we read things
(esp. the "disconnected" event) fast enough or not.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
7619bfa9ad test: switch a bool([...]) to any()
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
c169ac63b8 test: keep the announced interface as local variable
This will be more prominent as we add new interface versions and hooking
it up via the right signals is better than analyzing the calllog.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
0770fec433 Drop black, switch to ruff format 2024-10-17 16:18:51 +10:00
Peter Hutterer
39e6c93c8b test: ensure all returned interface versions are 1
Even where our client pretends to have higher interface versions, we
always send back version 1 from the EIS implementation.

This test probably won't really trigger anything useful until we switch to
version 2 somewhere, so let's hope the code works...
2023-06-07 23:08:16 +00:00
Peter Hutterer
7d0536f344 test: use the callback's version instead of hardcoding it a second time
Fixes f081e8e79f
2023-06-02 10:29:17 +10:00
Peter Hutterer
1aedabe7c7 libeis: check incoming objects' version for correctness
If the server sends a protocol version higher than we support, fail.
2023-05-26 19:16:15 +10:00
Peter Hutterer
f081e8e79f proto: add a version argument to ei_connection.sync
This is the only request that creates a new object but doesn't specify
the version for that object, courtesy of copy/paste from the wayland
protocol. In libei/libeis this a bit was hidden away so it didn't get
noticed - but it was already buggy: libei would always hardcode to
version 1 but libeis would take whichever ei_callback version was agreed
upon during handshake. This version could be higher than 1.

This is a protocol break but we're still pre-1.0, there are very few
people that will be affected by this and it's better than having to
carry this bug around for years.

Fixes #35
2023-05-26 07:01:19 +00:00
Peter Hutterer
a902d5dbd8 protocol: replace the capabilities enum with an interface list
Previously we had ei_seat.capabilities and ei_device.capabilities,
both referring to the same enum. The seat caps were used to bind,
the device caps were used to announce capabilities.

The device caps were already mostly superfluous as the information
they carried was implicitly available by the set of interfaces
the device announced - if the device has a keyboard interface
it must also have the keyboard capability.

So let's drop the separate enum and make the capabilities
the set of supported interfaces. In the device we can drop the
event directly and just send the interface list. In the seat
we have a capability event that sends each *possible* interface
with a custom-assigned mask. The client can then use that mask
to bind to the capability as before.

For example:
   <- ei_seat.capability(0x1, "ei_pointer")
   <- ei_seat.capability(0x4, "ei_keyboard")
   <- ei_seat.capability(0x8, "ei_touchscreen")
   <- ei_seat.done()
   -> ei_seat.bind(0x4 | 0x8)  # bind to keyboard and touchscreen
   <- ei_seat.device()
   -> ei_device.interface("ei_keyboard")
   -> ei_device.interface("ei_touchscreen")
   <- ei_device.done()

In the generated bindings we simply use the interface index
to generate the masks, but the protocol at least states that
the mask may not be constant.

Because the button/scroll interfaces are not exposed by the C API, some
of the handling is a bit awkward since we need to use both depending
whether we have pointer/pointer_absolute selected.

Fixes #28

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-02 05:53:25 +00:00
Peter Hutterer
bf88b34918 Split the ei_pointer interface up into its components
Split the ei_pointer protocol interface into ei_pointer,
ei_pointer_absolute, ei_scroll and ei_button.

This gets rid of the slightly awkward pointer vs pointer absolute
handling. Those were two different capabilities but tied to the same
interface.

Plus it paves the way for devices that are keyboards with scroll
buttons, etc.
2023-05-02 05:53:25 +00:00
Peter Hutterer
24680aef2e test: use an enum iterator to loop through the interface names 2023-04-06 13:57:20 +10:00
Peter Hutterer
5aad9fd777 scanner: add the protocol name so we can compile some #defines
The protocol name on an interface is a fixed string that is part of
the ABI since it's used in a few messages (e.g.
ei_handshake.interface_version). To avoid typos, let's expose that
string in the scanner and #define it in the generated sources.
2023-04-06 13:57:20 +10:00
Peter Hutterer
99b36ba652 test: add a test for pointer vs abs pointer receiving 2023-04-06 13:57:20 +10:00
Peter Hutterer
7f7880d953 test: add test for receiving the device interfaces 2023-04-06 13:57:20 +10:00
Peter Hutterer
6179c91580 test: fix the exception check for the missing eiproto module
When running pytest from the source directory we get a
ModuleNotFoundError, not an ImportError.
2023-04-06 12:04:35 +10:00
Peter Hutterer
0aa8bab9c0 test: drop the default timeouts to 2
There's no need to wait any longer.
2023-04-05 14:22:31 +10:00
Peter Hutterer
a806968ec5 test: up the timeout for dispatch
10ms isn't enough, esp. when running under valgrind
2023-03-03 11:27:01 +10:00
Peter Hutterer
037e092b62 test: throw an exception if sock.connect fails
We don't want to drop the error here, we need to see why something
failed.
2023-03-03 11:27:01 +10:00
Peter Hutterer
9b390f5703 eis: don't send a disconnected event when the client requests disconnect
As the protocol spec says, EIS should treat this as already disconnected
and not touch the connection.

This fixes a memleak if a client connects and immediately disconnects -
when EIS processes the EIS_EVENT_CLIENT_CONNECT it may set up a bunch of
things like seats (the eis-demo-server does this). Then, later, when
the EIS_EVENTE_CLIENT_DISCONNECT is processed, it calls
eis_client_disconnect() but we were already in the disconnected state
and the seats would not get released.
2023-03-03 11:27:01 +10:00
Peter Hutterer
1b34bc6f7c test: distinguish better between stderr/stdout of the subprocess 2023-03-03 11:27:01 +10:00
Peter Hutterer
1a64b4963d Check incoming ids for validity
In libei we just check the range is correct.
In libeis we also check that the client is monotonically increasing the
id.
2023-03-03 11:27:01 +10:00
Peter Hutterer
c832ce3ddc protocol: split the handshake version negotiation from the other interfaces
Previously, we'd send one interface_version event for "ei_handshake"
immediately but all others after the client requests handshake.finish.
This was too confusing to document and not clear how it would work, so
let's make this simpler by splitting it up.

There is now a handshake_version event from the server, sent immediately
on connection that denotes the maximum version number for the interface.
And a handshake_version request from the client which must be the first
one by the client.
2023-03-03 11:27:01 +10:00
Peter Hutterer
35f5fa102c proto: rename ei_connection_setup to ei_handshake
This is a better name for the initial handshake and easier to
distinguish from the ei_connection this way too.

Suggested by Jonas Ådahl.
2023-03-03 11:27:01 +10:00
Peter Hutterer
2aaf7acdfc test: fix a ruff warning - f-string without placeholder 2023-03-03 11:27:01 +10:00
Peter Hutterer
705c5d79ac test: remove unused python import 2023-03-03 11:27:01 +10:00
Peter Hutterer
47467bfe0e proto: rename connection_setup.done to .finish
Avoids ambiguity with the .done events from e.g. the seat or the device.
2023-03-03 11:27:01 +10:00
Peter Hutterer
0897722493 proto: drop the seat caps and cross-reference device caps instead 2023-03-03 11:27:01 +10:00
Peter Hutterer
3fa396c012 test: add a framework for doing protocol tests directly
This tests the protocol layer which is hard to test using libei/libeis.
Similar to the generated C bindings we compile a eiproto.py file that is
then used in the test to talk protocol directly to the eis-demo-server
that we start up.

By sending the specific messages and checking things happen as we expect
on the socket we can verify that the EIS implementation is correct (and
robust enough).

In theory this could also be used to test some other binary with an EIS
implementation and the scaffolding is there to set LIBEI_TEST_SERVER to
that binary. Wether this works is untested though...
2023-03-03 11:27:01 +10:00