|
From: Tim R. <ti...@pr...> - 2015-04-28 17:11:43
|
Taylor Braun-Jones wrote: > > I would like to do more automated testing of the application without > the actual hardware attached using some sort of mechanism to abstract > the hardware. Reasons being: > > * Automated testing is not possible with the real hardware > * Error cases can be hard to test at all with the real hardware > * The real hardware is scarce/expensive (and in some cases doesn't > exist at all yet) > > I looked into ways of creating a software emulated USB device on > Linux, but then realized that a better approach would be to use a mock > libusb interface. Ideally this mock interface would be owned by the > libusb team so that its interface can be kept in sync with libusb. We > use GoogleMock to for mocking our own C++ classes. Has the libusb team > considered including mocked libusb interfaces? Using something like > cmocka[1] or similar? Such a library is very difficult to create and maintain, and because it is so rarely used, it is never going to be trustworthy. As evidence, I would point out that Microsoft introduced with great fanfare a package to do exactly this, called "Device Simulation Framework". They announced it with the Vista driver kit in 2005 and quietly eliminated it in the Windows 7 driver kit in 2009, essentially because no one used it. One of the nice things about USB is that, for very little money, you can get a general purpose USB experimenter's device and create your own simulation. It won't be exactly like your real device, but you can certainly get close enough to have a driver that is roughly ready to go by the time the real hardware is ready. After all, a USB device can't get terribly exotic. You only have three pipe types to choose from. Everything else is bandwidth management. That solution tends to be much cheaper and much more productive than a software simulation. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |