]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: disable an alloc test under the race detector
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 4 Mar 2014 16:56:52 +0000 (08:56 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 4 Mar 2014 16:56:52 +0000 (08:56 -0800)
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/70200052

src/pkg/net/http/header.go
src/pkg/net/http/header_test.go
src/pkg/net/http/race.go [new file with mode: 0644]

index de62bef55254c554b1cb417c5b228d01ff7d9606..153b94370f856fd8ce23b8c626468b2b89590ead 100644 (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
 
index 9fd9837a5b6be88a9713dd2822617b8d5568e7f5..9dcd591fa0301639e04240ba213b41e3183101bf 100644 (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)
        }
 }
diff --git a/src/pkg/net/http/race.go b/src/pkg/net/http/race.go
new file mode 100644 (file)
index 0000000..7665039
--- /dev/null
@@ -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
+}