Closed hughsie closed 2 years ago
Heh, I guess this is the easy way compared to me going through umockdev and emulating ioctl's :-)
@benzea it also allows us to load entire contexts of devices easily, e.g. when you do a firmware update the device disconnects and reconnects as a different VID/PID.
True, doing that is quite painful in umockdev as you need to add/remove the device manually.
@benzea I'd appreciate some high level review of the event collection API if that's okay?
I'll merge as fwupd now depends on this functionality, but I'm 100% open to modifying the JSON output or the API before we do the 0.4.0 release.
Heh, now I am wondering if a usbmon recording includes enough information to add/remove a device in umockdev dynamically ... that could be a fun hack, but I don't think I'll get around to play with that.
I have to admit, g_usb_context_load makes me a bit nervous as you seem to have the whole libusb hotplug machinery running underneath still.
Ya, I know what you mean. The reason I did this is that in fwupd I do actually want to use the physical devices alongside the emulated ones.
but but, it is a cute dragon! :-)
One thing I realised, You are setting enumeration_done = TRUE
, which means that the behaviour is different whether you load before or after enumerate. If you run it before loading, you will see existing devices. If not, you'll only see newly plugged host devices.
This allows us to simulate an entire context of devices, simulating responses as if the hardware is connected. This allows building rich device-specific unit tests in programs like fwupd, without having to have the hardware attached.