martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
312 stars 58 forks source link

Implement pcap based USB replay #124

Closed benzea closed 3 years ago

benzea commented 3 years ago

The ioctl-tree based replay is mostly useful for protocols that are fundamentally state-less. With state-full protocols, the ioctl-tree may randomly jump around, cause confusing situations and gets the order wrong during recording.

The pcap based replay is also able to play-back control transfers adding this feature to umockdev, even if outside of the original ioctl-tree implementation.

Note that umockdev does not support creating a recording. Recordings should be done using a separate tool such as wireshark.

Closes: #82, #117

benzea commented 3 years ago

OK, I added a test. I just recorded plugging in a keyboard and hit some keys. Then did the minimal ioctls to grab two packets.

Not ideal, but should exercise a large chunk of the relevant code, even if many corner cases re not covered.

benzea commented 3 years ago

Hmm, sec, I am getting errors from libusb. I think I need to change an error code somewhere.

benzea commented 3 years ago

OK, good now. I was returning ENOENT rather than EAGAIN if there was no reapable URB.