Browse Source

Add test to find data races

Ask Bjørn Hansen 10 years ago
parent
commit
a1bea35dea
1 changed files with 13 additions and 0 deletions
  1. 13 0
      serve_test.go

+ 13 - 0
serve_test.go

@@ -3,6 +3,7 @@ package main
 import (
 import (
 	"net"
 	"net"
 	"strings"
 	"strings"
+	"sync"
 	"time"
 	"time"
 
 
 	"github.com/abh/geodns/Godeps/_workspace/src/github.com/miekg/dns"
 	"github.com/abh/geodns/Godeps/_workspace/src/github.com/miekg/dns"
@@ -208,6 +209,18 @@ func (s *ServeSuite) TestServingEDNS(c *C) {
 
 
 }
 }
 
 
+func (s *ServeSuite) TestServeRace(c *C) {
+	wg := sync.WaitGroup{}
+	for i := 0; i < 5; i++ {
+		wg.Add(1)
+		go func() {
+			s.TestServing(c)
+			wg.Done()
+		}()
+	}
+	wg.Wait()
+}
+
 func (s *ServeSuite) BenchmarkServing(c *C) {
 func (s *ServeSuite) BenchmarkServing(c *C) {
 	for i := 0; i < c.N; i++ {
 	for i := 0; i < c.N; i++ {
 		exchange(c, "_country.foo.pgeodns.", dns.TypeTXT)
 		exchange(c, "_country.foo.pgeodns.", dns.TypeTXT)