Merge branch 'fix-context-close-race' of https://github.com/krasin/gousb
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
package usb_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
. "github.com/kylelemons/gousb/usb"
|
||||
@@ -77,3 +80,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())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user