test: make sure we search for event node, not the parent input device
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 31 May 2017 02:01:16 +0000 (12:01 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 31 May 2017 23:34:33 +0000 (09:34 +1000)
commit89ac7fd24be25191df6eb5d356a89701d1b5fc86
tree6438e7db14039dd49e1ad854f21dfacad2db8836
parentf139d8fbc3041655518d55a4ff150264313bea06
test: make sure we search for event node, not the parent input device

This explains the heisenbugs when running the test suite. libevdev gives us
the syspath to the /sys/.../input123 node, not the one for the event node.
The device node path is created based on the sysfs tree, so there's a
window where the device node may not exist yet but we already returned the
device node path.

In litest, we're using a udev monitor to wait until the device is ready for
us, but the path interface only takes a device node path. So what happens is:
* libevdev gives us a syspath for the input node and a device path
* the monitor receives the input node udev device and matches the syspath
* we pass that up to the caller litest_add_device_with_overrides()
  which opens the device node and adds it to libinput
* the path interface creates a udev device from the device node, which still
  points to the old device node. Things fail because we don't have the device
  we expect or it doesn't send events and eventually times out [1].

The errors triggered by this are either odd udev property mismatches or
timeouts because events are never processed.

This race is fixed by simply constructing the actual device node path we
expect from the udev device and waiting for the right device.

[1] We rely on the caller to notify us when to remove the device and thus
silently ignore ENODEV.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/litest.c