Skip to content

Commit

Permalink
Add strestest
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed Aug 22, 2013
1 parent a232087 commit 154181f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions unbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package unbound
import (
"fmt"
"github.com/miekg/dns"
"runtime"
"sync"
"testing"
)

Expand Down Expand Up @@ -93,3 +95,33 @@ func TestUnicodeResolve(t *testing.T) {
t.Fail()
}
}

func testStress(t *testing.T) {
max := 8
procs := runtime.GOMAXPROCS(max)
wg := new(sync.WaitGroup)
wg.Add(max)
u := New()
defer u.Destroy()
if err := u.ResolvConf("/etc/resolv.conf"); err != nil {
return
}
for i := 0; i < max; i++ {
go func() {
for i := 0; i < 1000; i++ {
r, err := u.Resolve("www.google.com", dns.TypeA, dns.ClassINET)
if err != nil {
t.Log("failure to resolve google")
continue
}
if !r.HaveData {
t.Log("no data when resolving google")
continue
}
}
wg.Done()
}()
}
wg.Wait()
runtime.GOMAXPROCS(procs)
}

0 comments on commit 154181f

Please sign in to comment.