]> Cypherpunks repositories - gostls13.git/commitdiff
all: Skip AllocsPerRun tests if GOMAXPROCS>1.
authorAlbert Strasheim <fullung@gmail.com>
Wed, 6 Mar 2013 23:52:32 +0000 (15:52 -0800)
committerRob Pike <r@golang.org>
Wed, 6 Mar 2013 23:52:32 +0000 (15:52 -0800)
Fixes #4974.

R=rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/7545043

src/pkg/encoding/gob/timing_test.go
src/pkg/fmt/fmt_test.go
src/pkg/net/http/header_test.go
src/pkg/net/rpc/server_test.go
src/pkg/path/filepath/path_test.go
src/pkg/path/path_test.go
src/pkg/reflect/all_test.go
src/pkg/sort/search_test.go
src/pkg/strconv/strconv_test.go
src/pkg/time/time_test.go

index 13eb11925352894f427ab76d886f6ef12461767d..f589675dd98da051effc6cf500b9c43107a49dea 100644 (file)
@@ -9,6 +9,7 @@ import (
        "fmt"
        "io"
        "os"
+       "runtime"
        "testing"
 )
 
@@ -49,6 +50,10 @@ func BenchmarkEndToEndByteBuffer(b *testing.B) {
 }
 
 func TestCountEncodeMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
+
        const N = 1000
 
        var buf bytes.Buffer
@@ -65,6 +70,10 @@ func TestCountEncodeMallocs(t *testing.T) {
 }
 
 func TestCountDecodeMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
+
        const N = 1000
 
        var buf bytes.Buffer
index af4b5c8f8ef83638c56963e02c024c4afdc23a3b..552f76931b8e07114daa45ea9f6c3280078b199f 100644 (file)
@@ -9,6 +9,7 @@ import (
        . "fmt"
        "io"
        "math"
+       "runtime"
        "strings"
        "testing"
        "time"
@@ -601,6 +602,9 @@ var mallocTest = []struct {
 var _ bytes.Buffer
 
 func TestCountMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        for _, mt := range mallocTest {
                mallocs := testing.AllocsPerRun(100, mt.fn)
                if got, max := mallocs, float64(mt.count); got > max {
index 88c420a44a4c00076f5fd2dc51e27858f6ed9a5a..a2b82a701c5587012a3854d3b36d49159bd38cfa 100644 (file)
@@ -6,6 +6,7 @@ package http
 
 import (
        "bytes"
+       "runtime"
        "testing"
        "time"
 )
@@ -192,6 +193,9 @@ func BenchmarkHeaderWriteSubset(b *testing.B) {
 }
 
 func TestHeaderWriteSubsetMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        n := testing.AllocsPerRun(100, func() {
                buf.Reset()
                testHeader.WriteSubset(&buf, nil)
index 8a153062356e44882c506e56509a47692a82c030..5b2f9f2ded82db42fbd8205dcd04077a2bbe8601 100644 (file)
@@ -465,10 +465,16 @@ func countMallocs(dial func() (*Client, error), t *testing.T) float64 {
 }
 
 func TestCountMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        fmt.Printf("mallocs per rpc round trip: %v\n", countMallocs(dialDirect, t))
 }
 
 func TestCountMallocsOverHTTP(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        fmt.Printf("mallocs per HTTP rpc round trip: %v\n", countMallocs(dialHTTP, t))
 }
 
index e768ad32f0dad49b2c5eec57ac7f0a20015180b8..c4d73602ff823bef726a791bfbe8d40434a76a43 100644 (file)
@@ -107,6 +107,11 @@ func TestClean(t *testing.T) {
                }
        }
 
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
+               return
+       }
+
        for _, test := range tests {
                allocs := testing.AllocsPerRun(100, func() { filepath.Clean(test.result) })
                if allocs > 0 {
index 220ec1a0bb0651967a512cd70c9cbe7bdcaad311..69caa80e4f93a22caa62b0de11bc4a88103fdefb 100644 (file)
@@ -5,6 +5,7 @@
 package path
 
 import (
+       "runtime"
        "testing"
 )
 
@@ -72,6 +73,11 @@ func TestClean(t *testing.T) {
                }
        }
 
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
+               return
+       }
+
        for _, test := range cleantests {
                allocs := testing.AllocsPerRun(100, func() { Clean(test.result) })
                if allocs > 0 {
index 6f006db1866485c10578daa88a1f15a02b264e4e..97b3a9f2e5efba912014c7fbb573ba8fa22ee4e2 100644 (file)
@@ -13,6 +13,7 @@ import (
        "math/rand"
        "os"
        . "reflect"
+       "runtime"
        "sync"
        "testing"
        "time"
@@ -2011,6 +2012,9 @@ func TestAddr(t *testing.T) {
 }
 
 func noAlloc(t *testing.T, n int, f func(int)) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        i := -1
        allocs := testing.AllocsPerRun(n, func() {
                f(i)
index 4d8d6d930b2a92952d65bf595dbb28299e061e84..ee95c663cca22a1f899ee6a09e8da1d975e4e350 100644 (file)
@@ -5,6 +5,7 @@
 package sort_test
 
 import (
+       "runtime"
        . "sort"
        "testing"
 )
@@ -127,6 +128,9 @@ func runSearchWrappers() {
 }
 
 func TestSearchWrappersDontAlloc(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        allocs := testing.AllocsPerRun(100, runSearchWrappers)
        if allocs != 0 {
                t.Errorf("expected no allocs for runSearchWrappers, got %v", allocs)
index c3c5389267e35a0c55e967d79e3723d7ac3971ce..3cd7835cccb30ed511100fe357993796f7369bda 100644 (file)
@@ -5,6 +5,7 @@
 package strconv_test
 
 import (
+       "runtime"
        . "strconv"
        "strings"
        "testing"
@@ -43,6 +44,9 @@ var (
 )
 
 func TestCountMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        for _, mt := range mallocTest {
                allocs := testing.AllocsPerRun(100, mt.fn)
                if max := float64(mt.count); allocs > max {
index 4b268f73d9c5bd3fd1990e772fced61fa600cb52..a0ee37ae3b44b34e506bfc3c8557a3b098304b60 100644 (file)
@@ -11,6 +11,7 @@ import (
        "fmt"
        "math/big"
        "math/rand"
+       "runtime"
        "strconv"
        "strings"
        "testing"
@@ -1299,6 +1300,9 @@ var mallocTest = []struct {
 }
 
 func TestCountMallocs(t *testing.T) {
+       if runtime.GOMAXPROCS(0) > 1 {
+               t.Skip("skipping; GOMAXPROCS>1")
+       }
        for _, mt := range mallocTest {
                allocs := int(testing.AllocsPerRun(100, mt.fn))
                if allocs > mt.count {