Config and interface description (#16)

* Add APIs for config and interface descriptors. Split out the common
parts of selecting a config descriptor from device desc and
selecting a setting descriptor from a config desc.

* Parallelize the few tests that actually can be parallelized safely.
Add comments where they can't. Note to self: it would be beneficial
to restructure the fakelibusb to index all properties of the lib
with the used context. That way a libusb implementation wouldn't need
to be referred via a shared variable.
This commit is contained in:
zagrodzki
2017-09-04 14:17:34 +02:00
committed by GitHub
parent cf19eb7001
commit f9aba6fab5
12 changed files with 175 additions and 53 deletions

View File

@@ -20,6 +20,7 @@ import (
)
func TestEndpoint(t *testing.T) {
// Can't be parallelized, newFakeLibusb modifies a shared global state.
lib, done := newFakeLibusb()
defer done()
@@ -116,6 +117,7 @@ func TestEndpoint(t *testing.T) {
}
func TestEndpointInfo(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
ep EndpointDesc
want string
@@ -161,8 +163,7 @@ func TestEndpointInfo(t *testing.T) {
}
func TestEndpointInOut(t *testing.T) {
defer func(i libusbIntf) { libusb = i }(libusb)
// Can't be parallelized, newFakeLibusb modifies a shared global state.
lib, done := newFakeLibusb()
defer done()
@@ -242,8 +243,7 @@ func TestEndpointInOut(t *testing.T) {
}
func TestSameEndpointNumberInOut(t *testing.T) {
defer func(i libusbIntf) { libusb = i }(libusb)
// Can't be parallelized, newFakeLibusb modifies a shared global state.
_, done := newFakeLibusb()
defer done()