Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
77a0b96f
Commit
77a0b96f
authored
Apr 09, 2013
by
Dave Cheney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: add test for runtime.PollDesc leak
See 8318044 R=bradfitz CC=golang-dev
https://golang.org/cl/8547043
parent
afb49aad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
src/pkg/net/dial_test.go
src/pkg/net/dial_test.go
+42
-0
No files found.
src/pkg/net/dial_test.go
View file @
77a0b96f
...
...
@@ -330,3 +330,45 @@ func numFD() int {
// All tests using this should be skipped anyway, but:
panic
(
"numFDs not implemented on "
+
runtime
.
GOOS
)
}
// Assert that a failed Dial attempt does not leak
// runtime.PollDesc structures
func
TestDialPollDescLeak
(
t
*
testing
.
T
)
{
// remove once CL 8318044 is submitted
t
.
Skip
(
"Test skipped pending submission of CL 8318044"
)
if
testing
.
Short
()
{
t
.
Skip
(
"skipping PollDesc leak test in -short mode"
)
}
const
loops
=
10
const
count
=
20000
var
old
runtime
.
MemStats
// used by sysdelta
runtime
.
ReadMemStats
(
&
old
)
sysdelta
:=
func
()
uint64
{
var
new
runtime
.
MemStats
runtime
.
ReadMemStats
(
&
new
)
delta
:=
old
.
Sys
-
new
.
Sys
old
=
new
return
delta
}
failcount
:=
0
for
i
:=
0
;
i
<
loops
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
conn
,
err
:=
Dial
(
"tcp"
,
"127.0.0.1:1"
)
if
err
==
nil
{
t
.
Error
(
"dial should not succeed"
)
conn
.
Close
()
t
.
FailNow
()
}
}
if
delta
:=
sysdelta
();
delta
>
0
{
failcount
++
}
// there are always some allocations on the first loop
if
failcount
>
3
{
t
.
Error
(
"net.Dial leaked memory"
)
t
.
FailNow
()
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment