Add a test case that triggers 'handle_events: error: libusb: unknown error [code -99]'

This commit is contained in:
Ivan Krasin
2013-08-14 00:25:49 -07:00
parent f0081d8ff9
commit e5e703175c

View File

@@ -1,6 +1,9 @@
package usb_test package usb_test
import ( import (
"bytes"
"log"
"os"
"testing" "testing"
. "github.com/kylelemons/gousb/usb" . "github.com/kylelemons/gousb/usb"
@@ -63,3 +66,22 @@ func TestEnum(t *testing.T) {
} }
} }
} }
func TestMultipleContexts(t *testing.T) {
var buf bytes.Buffer
log.SetOutput(&buf)
for i := 0; i < 10; i++ {
ctx := NewContext()
_, err := ctx.ListDevices(func(desc *Descriptor) bool {
return false
})
if err != nil {
t.Fatal(err)
}
ctx.Close()
}
log.SetOutput(os.Stderr)
if buf.Len() > 0 {
t.Errorf("Non zero output to log, while testing: %s", buf.String())
}
}