mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: enable test for runtime.PollDesc leak
Update #5219. R=golang-dev, dvyukov, r CC=golang-dev https://golang.org/cl/8602047
This commit is contained in:
parent
10cdb92000
commit
41451dd92b
1 changed files with 8 additions and 8 deletions
|
|
@ -331,14 +331,13 @@ func numFD() int {
|
||||||
panic("numFDs not implemented on " + runtime.GOOS)
|
panic("numFDs not implemented on " + runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var testPoller = flag.Bool("poller", false, "platform supports runtime-integrated poller")
|
||||||
|
|
||||||
// Assert that a failed Dial attempt does not leak
|
// Assert that a failed Dial attempt does not leak
|
||||||
// runtime.PollDesc structures
|
// runtime.PollDesc structures
|
||||||
func TestDialPollDescLeak(t *testing.T) {
|
func TestDialFailPDLeak(t *testing.T) {
|
||||||
// remove once CL 8318044 is submitted
|
if !*testPoller {
|
||||||
t.Skip("Test skipped pending submission of CL 8318044")
|
t.Skip("test disabled; use -poller to enable")
|
||||||
|
|
||||||
if testing.Short() {
|
|
||||||
t.Skip("skipping PollDesc leak test in -short mode")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loops = 10
|
const loops = 10
|
||||||
|
|
@ -352,10 +351,11 @@ func TestDialPollDescLeak(t *testing.T) {
|
||||||
old = new
|
old = new
|
||||||
return delta
|
return delta
|
||||||
}
|
}
|
||||||
|
d := &Dialer{Timeout: time.Nanosecond} // don't bother TCP with handshaking
|
||||||
failcount := 0
|
failcount := 0
|
||||||
for i := 0; i < loops; i++ {
|
for i := 0; i < loops; i++ {
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
conn, err := Dial("tcp", "127.0.0.1:1")
|
conn, err := d.Dial("tcp", "127.0.0.1:1")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("dial should not succeed")
|
t.Error("dial should not succeed")
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
|
@ -367,7 +367,7 @@ func TestDialPollDescLeak(t *testing.T) {
|
||||||
}
|
}
|
||||||
// there are always some allocations on the first loop
|
// there are always some allocations on the first loop
|
||||||
if failcount > 3 {
|
if failcount > 3 {
|
||||||
t.Error("net.Dial leaked memory")
|
t.Error("detected possible memory leak in runtime")
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue