net: make TestDeadlineRace shorter
1. Do less iterations in short mode
2. Bound number of times SetDeadline is executed
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12937043
diff --git a/src/pkg/net/timeout_test.go b/src/pkg/net/timeout_test.go
index 76f51b3..7ea81fe 100644
--- a/src/pkg/net/timeout_test.go
+++ b/src/pkg/net/timeout_test.go
@@ -710,6 +710,10 @@
t.Skipf("skipping test on %q", runtime.GOOS)
}
+ N := 1000
+ if testing.Short() {
+ N = 50
+ }
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
ln := newLocalListener(t)
defer ln.Close()
@@ -721,7 +725,7 @@
done := make(chan bool)
go func() {
t := time.NewTicker(2 * time.Microsecond).C
- for {
+ for i := 0; i < N; i++ {
if err := c.SetDeadline(time.Now().Add(2 * time.Microsecond)); err != nil {
break
}
@@ -730,7 +734,7 @@
done <- true
}()
var buf [1]byte
- for i := 0; i < 1024; i++ {
+ for i := 0; i < N; i++ {
c.Read(buf[:]) // ignore possible timeout errors
}
c.Close()