net/http: disable an alloc test under the race detector

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/70200052
This commit is contained in:
Brad Fitzpatrick 2014-03-04 08:56:52 -08:00
parent dd89fb1876
commit 5f1e0fa538
3 changed files with 19 additions and 3 deletions

View File

@ -13,6 +13,8 @@ import (
"time"
)
var raceEnabled = false // set by race.go
// A Header represents the key-value pairs in an HTTP header.
type Header map[string][]string

View File

@ -192,9 +192,12 @@ func BenchmarkHeaderWriteSubset(b *testing.B) {
}
}
func TestHeaderWriteSubsetMallocs(t *testing.T) {
func TestHeaderWriteSubsetAllocs(t *testing.T) {
if testing.Short() {
t.Skip("skipping malloc count in short mode")
t.Skip("skipping alloc test in short mode")
}
if raceEnabled {
t.Skip("skipping test under race detector")
}
if runtime.GOMAXPROCS(0) > 1 {
t.Skip("skipping; GOMAXPROCS>1")
@ -204,6 +207,6 @@ func TestHeaderWriteSubsetMallocs(t *testing.T) {
testHeader.WriteSubset(&buf, nil)
})
if n > 0 {
t.Errorf("mallocs = %g; want 0", n)
t.Errorf("allocs = %g; want 0", n)
}
}

11
src/pkg/net/http/race.go Normal file
View File

@ -0,0 +1,11 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build race
package http
func init() {
raceEnabled = true
}