aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/export_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2015-04-30 15:00:51 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2015-05-01 21:41:03 +0000
commitc723230e4a1ddb30b4822de8f795c16fd9aa90ff (patch)
treed52c769b3cffaaaa7f94a6f180f37794959a5890 /src/net/http/export_test.go
parent80cedf3e8f912d7d7defd8e0495c6fd67d229555 (diff)
downloadgo-c723230e4a1ddb30b4822de8f795c16fd9aa90ff.tar.xz
net/http: fix scheduling race resulting in flaky test
The test was measuring something, assuming other goroutines had already scheduled. Fixes #10427 Change-Id: I2a4d3906f9d4b5ea44b57d972e303bbe2b0b1cde Reviewed-on: https://go-review.googlesource.com/9561 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/export_test.go')
-rw-r--r--src/net/http/export_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go
index b656aa9731..0457be50da 100644
--- a/src/net/http/export_test.go
+++ b/src/net/http/export_test.go
@@ -10,9 +10,17 @@ package http
import (
"net"
"net/url"
+ "sync"
"time"
)
+func init() {
+ // We only want to pay for this cost during testing.
+ // When not under test, these values are always nil
+ // and never assigned to.
+ testHookMu = new(sync.Mutex)
+}
+
func NewLoggingConn(baseName string, c net.Conn) net.Conn {
return newLoggingConn(baseName, c)
}
@@ -86,6 +94,12 @@ func SetEnterRoundTripHook(f func()) {
testHookEnterRoundTrip = f
}
+func SetReadLoopBeforeNextReadHook(f func()) {
+ testHookMu.Lock()
+ defer testHookMu.Unlock()
+ testHookReadLoopBeforeNextRead = f
+}
+
func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler {
f := func() <-chan time.Time {
return ch