Commit graph

210 commits

Author SHA1 Message Date
Peter Hutterer
befab06ea2 tests: add tests for button events
Those were missing, luckily the code works
2023-06-07 23:08:16 +00:00
Peter Hutterer
6caf69a73c test: check that the width/height are set for physical devices 2023-06-07 23:08:16 +00:00
Peter Hutterer
987997dc2c test: add tests for the eis region getters 2023-06-06 19:41:54 +10:00
Peter Hutterer
f0894aac67 test: drop ifdef'd out test
It's been ifdef'd out for long enough that clearly this test doesn't
matter anymore.
2023-06-06 10:56:53 +10: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
552f6dcbd0 ei-scanner: expose version_arg and version_arg_for
Points to the correspoding "version" argument, or points back to the
argument this version argument is for.
2023-05-26 16:56:13 +10:00
Ian Douglas Scott
1d8cd84c56 ei-scanner: Expose interface_arg, and also provide interface_arg_for
To make this practical to use in a template, we want relations in both
directions. And at least for consistency with other things, these fields
should contain the `Argument` instead of just its name string.

So we need to do this after are the arguments in the message have been
initially parsed. Adding these fields when parsing the request/event
close tag seems to work well enough.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-26 16:55:47 +10:00
Peter Hutterer
00226da59e scanner: add tests for the extra data arguments
Fixed in !218, let's test this so we don't break it again.
2023-05-25 10:09:28 +10:00
Peter Hutterer
ca06927371 test: add some tests for the ei-scanner itself
This is a bit convoluted because ei-scanner is named like that, so it
cannot be imported as python module. The solution for that is to
copy/rename it with meson to the builddir and run pytest in that. This
also allows us to set the path to the protocol XML file while we're at
it so we can use it as a fixture.

Actual tests are minimal for now, can be extended over time.
2023-05-22 10:54:28 +10:00
Jan Beich
708d0f57e8 util: silence warnings when memfd_create is missing
src/util-memfile.c:55:1: warning: unused function 'memfile_create' [-Wunused-function]
OBJECT_IMPLEMENT_CREATE(memfile);
^
src/util-object.h:164:16: note: expanded from macro 'OBJECT_IMPLEMENT_CREATE'
struct type_ * type_##_create(struct object *parent) { \
               ^
<scratch space>:133:1: note: expanded from here
memfile_create
^

test/test-ei-device.c:37:1: warning: unused function 'memfile_unrefp' [-Wunused-function]
DEFINE_TRIVIAL_CLEANUP_FUNC(struct memfile *, memfile_unref);
^
src/util-mem.h:56:21: note: expanded from macro 'DEFINE_TRIVIAL_CLEANUP_FUNC'
        static inline void _func##p(_type *_p) {                \
                           ^
<scratch space>:159:1: note: expanded from here
memfile_unrefp
^
2023-05-21 09:04:16 +00:00
Jan Beich
35e7ad9717 meson: depend on epoll-shim for BSDs
src/util-sources.c:29:10: fatal error: 'sys/epoll.h' file not found
 #include <sys/epoll.h>
          ^~~~~~~~~~~~~

ld: error: undefined symbol: epoll_ctl
>>> referenced by util-sources.c:76 (src/util-sources.c:76)
>>>               libutil.a.p/util-sources.c.o:(source_remove) in archive src/libutil.a
>>> referenced by util-sources.c:200 (src/util-sources.c:200)
>>>               libutil.a.p/util-sources.c.o:(sink_add_source) in archive src/libutil.a

ld: error: undefined symbol: epoll_create1
>>> referenced by util-sources.c:152 (src/util-sources.c:152)
>>>               libutil.a.p/util-sources.c.o:(sink_new) in archive src/libutil.a

ld: error: undefined symbol: epoll_wait
>>> referenced by util-sources.c:169 (src/util-sources.c:169)
>>>               libutil.a.p/util-sources.c.o:(sink_dispatch) in archive src/libutil.a
2023-05-18 04:15:36 +00:00
Jan Beich
53482faa57 meson: depend on math library for BSDs
ld: error: undefined symbol: __isnormal
>>> referenced by util-strings.h:243 (src/util-strings.h:243)
>>>               test/unit-tests-utils.p/.._src_util-strings.c.o:(xatod)
2023-05-18 04:15:36 +00:00
Peter Hutterer
44de97d649 test: switch to use ei_seat_bind_capabilities()
Better than one-by-one where we bind multiple capabilities. And
ei_seat_bind_capability() is about to be removed so let's switch all
of them.
2023-05-10 12:21:40 +10:00
Peter Hutterer
4adf483195 test: add the new caps to the bind-all-caps test
And bind them all at once, might as well
2023-05-10 12:21:04 +10:00
Peter Hutterer
fafc30d4cc meson.build: change the test builds to be a feature
This way we get to use 'auto' feature which will enable the tests
as dependencies are available. Right now, the basic tests don't have any
dependencies beyond what libei needs, only the pytests have extra
requirements that are handled in the 'auto' processing.
2023-05-10 12:10:40 +10:00
Peter Hutterer
bd1dd67892 test: fix the oeffis pytest
Since the soname was added, the liboeffis.so file no longer exists in
the build directory - it is created on install.

Not sure how this passed the CI pytest run but it certainly fails
locally.
2023-05-10 12:10:40 +10:00
Peter Hutterer
408a3a9462 eis: drop the vestiges of client restrictions
Leftover from 479bda259a (and possibly
others). This dates back to when a client could have restrictions
configured on the same fd. This is now all out-of-band (portals!) so the
compositor knows what the client is allowed to set up anyway.

No need for this (read-only) API here.
2023-05-08 13:38:40 +10:00
Peter Hutterer
e6954b76d3 eis: change the API to match the protocol interfaces closer
Same as the corresponding ei change a few commits ago, this one does all
the EIS renaming in the same manner.

As with the libei changes, an EIS implementation must now handle the
EIS_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities. In
virtually all cases, clients will likely expect that a device with the
pointer or absolute pointer capabilities will also have button and
scroll capabilities.
2023-05-05 14:04:17 +10:00
Peter Hutterer
da37da1308 ei: change the API to match the protocol interfaces closer
Now that the protocol interfaces are more fine-grained, let's match this
with the C API too.

This is just a rename of things so that in general
ei_pointer_*foo now becomes ei_foo*.

A few notable renames for better readability here:
- ei_device_scroll_delta (because scroll_scroll is awkward)
- ei_event_scroll_get_dx/dy and
  ei_event_scroll_get_discrete_dx/dy to indicate the delta-ness

Beyond that, clients must ensure to check/bind to the new
EI_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities to be able
to send button or scroll events.

Note that this API now allows for an EIS implementation to send a device
that only has a button or a scroll cap. Or a pointer cap without
buttons, etc. It's up to the clients how to handle such devices
(probably: ignore them).
2023-05-05 14:02:33 +10: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
6215eecfbd test: fix a debug log typo 2023-04-27 15:22:07 +10: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
5b1b5aec1a proto: replace pointer/keyboard/touchscreen with a generic "interface" event
Since these events are merely notifications of a single object, we can make
this more generic. This allows us to introduce future capabilities without
having to bump the seat.
2023-04-06 13:57:18 +10:00
Peter Hutterer
4b77664dc1 test: if we fail to load liboeffis.so, skip the rest of the pytests
This gives us a nicer behavior when (semi-intentionally) running pytest
in the source directory.
2023-04-06 12:04:51 +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
Salman Malik
a438e46e18 config: Make memfd_create optional
`memfd_create` doesn't seem to be supported on
all platforms (e.g. ubuntu 18 has trouble with it).
Even though, I was able to substitute `memfd_create`
with a direct system call, I was not able to get
the `MFD_CLOXEC` flag (from fcntl.h) working cleanly
(there were redefinitions/conflicts for other
structures when trying to use <linux/*> headers).
Making it optional for time being till we have
figured out how to make it work broadly.
2023-03-28 11:24:06 +00:00
Peter Hutterer
74ed569fe0 test: skip the oeffis tests if we don't have dbusmock 0.28.5 2023-03-19 07:56:09 +00:00
Peter Hutterer
a95c9e1799 meson: drop version requirement to 0.56 so we can build on Bullseye
Looks like the only more recent meson feature we use is for
'exclude_suites' in the valgrind test setup. We can just skip that.
2023-03-19 07:56:09 +00:00
Peter Hutterer
8954d96227 Remove empty trailing newlines from all files 2023-03-13 08:52:08 +10:00
Peter Hutterer
30aab5179e Merge branch 'main' into wip/drop-protobuf 2023-03-07 12:55:18 +10:00
Peter Hutterer
367fa6384f test: fix the LD_LIBRARY_PATH to liboeffis
Make this dependent on liboeffis directly instead of hardcoding where it
should be.
2023-03-07 11:54:10 +10:00
Peter Hutterer
25e36eb24e meson: move the "build this?" checks into the subdirs
Let's decide on what to build in the doc/ and test/ directory rather
than in the main file.
2023-03-07 11:10:06 +10:00
Peter Hutterer
3c589f1b20 test: log all function calls to interfaces
Makes debugging easier to see exactly who's being called.
2023-03-03 11:27:01 +10:00
Peter Hutterer
59542a1ba0 test: group 4 bytes at a time in our hexlify function
Our protocol is groups of 4s, so make it easier to find individual items
in the hexdump.
2023-03-03 11:27:01 +10:00
Peter Hutterer
9700a47473 test: run pytest with xdist where available
A lot of the protocol tests have enforced timeouts because we need to
wait for the server to do something (or not). Running the protocol tests
with xdist means we can run those in parallel, which on my local box
roughly halves the time required to run all protocol tests.

Of course, this is all terrible. The only way to tell pytest to use
xdist is with `pytest -n <jobcount>`. But -n is only available if xdist
is installed. Dynamically adding commandline options is supposed to
be possible with `pytest_load_initial_conftests` in conftest.py, but
that doesn't actually work unless we're configuring a setuptool plugin.
Which we don't. What would work is `pytest_cmdline_preparse` but that
has been deprecated.

So we work around this by having meson check if xdist is available and
append `-n auto` for us.

In the CI let's be nice and only use the FDI_CI_CONCURRENT number of
jobs rather than hogging everything available. And, continuation from
"all is terrible": pytest complains if you have a hook that's unknown.
So if xdist is not available, you must not have the hook in conftest.py.
Which means we have to do it within an import + ImportError clause.

But yay, now we're saving literally seconds!
2023-03-03 11:27:01 +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
086f96a702 proto: split up message length and opcode again
Now that we have 64 bit integers on the wire and 64 bit object IDs,
we're already different to the Wayland protocol. So we might as well get
the full length and split message length and opcode again to make header
parsing and composing simpler.

This effectively reverts commit bf45a7182cb2f4c13f11e141fc846244d3ac6212.
2023-03-03 11:27:01 +10:00
Peter Hutterer
ba51f434a6 proto: switch object ids to 64 bits 2023-03-03 11:27:01 +10:00
Peter Hutterer
2e1babbb84 test: simplify results handling in the python tests
No point appending the message header components to the results when we
just ignore them later anyway.
2023-03-03 11:27:01 +10:00