mirror of
https://gitlab.com/NebulousLabs/go-upnp.git
synced 2025-10-05 23:16:49 +08:00
add TestConcurrentUPNP
This commit is contained in:
20
upnp_test.go
20
upnp_test.go
@@ -4,6 +4,26 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestConcurrentUPNP tests that several threads calling Discover() concurrently
|
||||
// succeed.
|
||||
func TestConcurrentUPNP(t *testing.T) {
|
||||
// verify that a router exists
|
||||
_, err := Discover()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// now try to concurrently Discover() using 10 threads
|
||||
for i := 0; i < 10; i++ {
|
||||
go func() {
|
||||
_, err := Discover()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIGD(t *testing.T) {
|
||||
// connect to router
|
||||
d, err := Discover()
|
||||
|
Reference in New Issue
Block a user