aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/karalabe/hid/hid_test.go
blob: 470e6b99e120be065fb95a0345f7314b6cb7af7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// hid - Gopher Interface Devices (USB HID)
// Copyright (c) 2017 Péter Szilágyi. All rights reserved.
//
// This file is released under the 3-clause BSD license. Note however that Linux
// support depends on libusb, released under GNU LGPL 2.1 or later.

package hid

import (
	"sync"
	"testing"
)

// Tests that device enumeration can be called concurrently from multiple threads.
func TestThreadedEnumerate(t *testing.T) {
	var pend sync.WaitGroup
	for i := 0; i < 8; i++ {
		pend.Add(1)

		go func(index int) {
			defer pend.Done()
			for j := 0; j < 512; j++ {
				Enumerate(uint16(index), 0)
			}
		}(i)
	}
	pend.Wait()
}