On Fri, Apr 10, 2020 at 2:29 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > > On Thu, 9 Apr 2020, Andrey Konovalov wrote: > > > Hi Alan and Greg, > > > > I've been thinking about what kind of features raw-gadget might be > > missing, that would allow more flexibility in emulating USB devices. > > One of the things that is currently missing is halting endpoints. > > Adding this functionality seems to be fairly easy, but it's unclear to > > me how to test it. Any suggestions? > > You should use the usbtest driver along with the testusb program in > tools/usb. Of course, to do it you will need a userspace driver for > raw-gadget. usbtest works best with gadget-zero, but it can be used > (in degraded form) with any USB device. Hi Alan, I've started working on a test suite for raw-gadget based on the usbtest module as you suggested and have a few questions: 1. (Re test #10:) Currently there's no way to stall USB (control) requests with raw-gadget (which is what happens when you return -EPIPE from gadget's setup() callback AFAIU). Is stalling an important part of the protocol? Should we somehow support it? AFAIU gadgetfs also has no ability to stall requests that are passed to userspace. 2. Re test #4: the test fails with length that is not divisible by endpoint's max packet value when using dummy_hcd (assuming that gadget keeps queueing URBs with max packet length), as dummy_hcd's transfer() function sets status to -EOVERFLOW when this happens. Is this expected? 3. Re test #7: the test fails when e.g. vary parameter is set to some odd value when using dummy_hcd. AFAIU this happens since dummy_hcd doesn't have no_sg_constraint flag set and therefore the sanity check in usb_submit_urb() fails. Is this expected? Thanks!