started adding fakelibusb functions for testing device.go
This commit is contained in:
@@ -82,46 +82,6 @@ func TestEnum(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenDeviceWithVidPid(t *testing.T) {
|
||||
c := NewContext()
|
||||
defer c.Close()
|
||||
c.Debug(0)
|
||||
|
||||
// Accept for all device
|
||||
devs, err := c.ListDevices(func(desc *Descriptor) bool {
|
||||
return true
|
||||
})
|
||||
defer func() {
|
||||
for _, d := range devs {
|
||||
d.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("list: %s", err)
|
||||
}
|
||||
|
||||
for i := range devs {
|
||||
vid := devs[i].Vendor
|
||||
pid := devs[i].Product
|
||||
device, err := c.OpenDeviceWithVidPid((int)(vid), (int)(pid))
|
||||
|
||||
// if the context failed to open device
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// if opened device was not valid
|
||||
if device.Descriptor.Bus != devs[i].Bus ||
|
||||
device.Descriptor.Address != devs[i].Address ||
|
||||
device.Vendor != devs[i].Vendor ||
|
||||
device.Product != devs[i].Product {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultipleContexts(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
log.SetOutput(&buf)
|
||||
|
Reference in New Issue
Block a user