Commit 9bbf1e1b authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

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
parent 48c0d8b6
...@@ -710,6 +710,10 @@ func TestDeadlineRace(t *testing.T) { ...@@ -710,6 +710,10 @@ func TestDeadlineRace(t *testing.T) {
t.Skipf("skipping test on %q", runtime.GOOS) t.Skipf("skipping test on %q", runtime.GOOS)
} }
N := 1000
if testing.Short() {
N = 50
}
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
ln := newLocalListener(t) ln := newLocalListener(t)
defer ln.Close() defer ln.Close()
...@@ -721,7 +725,7 @@ func TestDeadlineRace(t *testing.T) { ...@@ -721,7 +725,7 @@ func TestDeadlineRace(t *testing.T) {
done := make(chan bool) done := make(chan bool)
go func() { go func() {
t := time.NewTicker(2 * time.Microsecond).C 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 { if err := c.SetDeadline(time.Now().Add(2 * time.Microsecond)); err != nil {
break break
} }
...@@ -730,7 +734,7 @@ func TestDeadlineRace(t *testing.T) { ...@@ -730,7 +734,7 @@ func TestDeadlineRace(t *testing.T) {
done <- true done <- true
}() }()
var buf [1]byte var buf [1]byte
for i := 0; i < 1024; i++ { for i := 0; i < N; i++ {
c.Read(buf[:]) // ignore possible timeout errors c.Read(buf[:]) // ignore possible timeout errors
} }
c.Close() c.Close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment