libx52/libusbx52
nirenjan 627c1fb004 Use libusb hotplug API to automatically detect disconnection
Prior to this commit, the libx52_is_connected API was simply checking if
the device handle was non-NULL. However, this was insufficient, since
the device disconnection would not reset the handle, and was relying on
the daemon to manually disconnect.

The libusb hotplug API provides functionality to register a callback on
device insertion/removal. libx52 only registers for removal, and will
automatically disconnect the device on receiving the callback. This also
modifies libx52_is_connected to fallback to checking if the kernel
driver is active if the linked libusb does not support hotplug (unlikely).

Finally, this commit adds support for the new hotplug related functions
to the libusbx52 preload library. While the preload library doesn't
actually support hotplug, it is sufficient to pretend that it does.
2021-09-14 09:03:23 -07:00
..
util Move libusbx52 to top level 2021-07-29 21:57:19 -07:00
Makefile.am Use non-recursive Automake 2021-07-29 23:53:21 -07:00
README.md Move libusbx52 to top level 2021-07-29 21:57:19 -07:00
fopen_env.c Move libusbx52 to top level 2021-07-29 21:57:19 -07:00
libusbx52.h Move libusbx52 to top level 2021-07-29 21:57:19 -07:00
usb_x52_stub.c Use libusb hotplug API to automatically detect disconnection 2021-09-14 09:03:23 -07:00

README.md

LibUSB mocker library

This folder contains a convenience library to mock the API of libusb. This is intended to be used as an LD_PRELOAD library when used by automated tests to verify the library without needing actual hardware to verify the tests.

While a manual test using real hardware is valuable, running some automated tests in an environment where the hardware is not available is equally valuable, especially if the source code is changing frequently.

Note that the API exported by the mocker is limited to the API used by libx52, as writing a complete USB simulator stack in software is not an easy job, nor is it necessary for the purposes of this project.