diff --git a/src/fmt/fmt_test.go b/src/fmt/fmt_test.go index ba99cb0f6a662..f15a0ba8e807a 100644 --- a/src/fmt/fmt_test.go +++ b/src/fmt/fmt_test.go @@ -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 index 0000000000000..1267cc34ee332 --- /dev/null +++ b/src/fmt/norace_test.go @@ -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 index 0000000000000..ae3147a5b000c --- /dev/null +++ b/src/fmt/race_test.go @@ -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