Merge branch 'fix-context-close-race' of https://github.com/krasin/gousb
This commit is contained in:
Kyle Lemons
2013-08-14 19:23:18 -07:00
2 changed files with 27 additions and 3 deletions

View File

@@ -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())
}
}