mirror of
https://github.com/golang/go
synced 2024-11-17 23:04:56 -07:00
net: ensure that Read/Write on all platforms do 0 mallocs
R=golang-dev, r CC=golang-dev https://golang.org/cl/12780045
This commit is contained in:
parent
06e686def6
commit
2f2d4c6bc3
@ -456,12 +456,6 @@ func TestTCPReadWriteMallocs(t *testing.T) {
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping malloc count in short mode")
|
t.Skip("skipping malloc count in short mode")
|
||||||
}
|
}
|
||||||
maxMallocs := 10000
|
|
||||||
switch runtime.GOOS {
|
|
||||||
// Add other OSes if you know how many mallocs they do.
|
|
||||||
case "windows":
|
|
||||||
maxMallocs = 0
|
|
||||||
}
|
|
||||||
ln, err := Listen("tcp", "127.0.0.1:0")
|
ln, err := Listen("tcp", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Listen failed: %v", err)
|
t.Fatalf("Listen failed: %v", err)
|
||||||
@ -493,8 +487,8 @@ func TestTCPReadWriteMallocs(t *testing.T) {
|
|||||||
t.Fatalf("Read failed: %v", err)
|
t.Fatalf("Read failed: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if int(mallocs) > maxMallocs {
|
if mallocs > 0 {
|
||||||
t.Fatalf("Got %v allocs, want %v", mallocs, maxMallocs)
|
t.Fatalf("Got %v allocs, want 0", mallocs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user