]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: skip malloc test under race detector
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 11 May 2015 17:38:24 +0000 (10:38 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 11 May 2015 17:45:26 +0000 (17:45 +0000)
Fixes #10778.

Change-Id: I09aab55dec429ec4a023e5ad591b929563cef0d9
Reviewed-on: https://go-review.googlesource.com/9855
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/fmt/fmt_test.go
src/fmt/norace_test.go [new file with mode: 0644]
src/fmt/race_test.go [new file with mode: 0644]

index ba99cb0f6a662fe1e2acfb938defc3c6e89a20ee..f15a0ba8e807a881e561f6ba126218d287b1502a 100644 (file)
@@ -949,11 +949,13 @@ var mallocTest = []struct {
 var _ bytes.Buffer
 
 func TestCountMallocs(t *testing.T) {
-       if testing.Short() {
+       switch {
+       case testing.Short():
                t.Skip("skipping malloc count in short mode")
-       }
-       if runtime.GOMAXPROCS(0) > 1 {
+       case runtime.GOMAXPROCS(0) > 1:
                t.Skip("skipping; GOMAXPROCS>1")
+       case raceenabled:
+               t.Skip("skipping malloc count under race detector")
        }
        for _, mt := range mallocTest {
                mallocs := testing.AllocsPerRun(100, mt.fn)
diff --git a/src/fmt/norace_test.go b/src/fmt/norace_test.go
new file mode 100644 (file)
index 0000000..1267cc3
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2015 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 fmt_test
+
+const raceenabled = false
diff --git a/src/fmt/race_test.go b/src/fmt/race_test.go
new file mode 100644 (file)
index 0000000..ae3147a
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2015 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 fmt_test
+
+const raceenabled = true