]> Cypherpunks repositories - gostls13.git/commitdiff
all: protect alloc count tests by -testing.short
authorRob Pike <r@golang.org>
Wed, 21 Aug 2013 04:00:45 +0000 (14:00 +1000)
committerRob Pike <r@golang.org>
Wed, 21 Aug 2013 04:00:45 +0000 (14:00 +1000)
Update #5000
Should reduce the flakiness a little. Malloc counting is important
to general testing but not to the build dashboard, which uses -short.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12866047

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/net/tcp_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 f589675dd98da051effc6cf500b9c43107a49dea..9fbb0ac6d5a556029d97e1e2100a078a352b49bf 100644 (file)
@@ -6,7 +6,6 @@ package gob
 
 import (
        "bytes"
-       "fmt"
        "io"
        "os"
        "runtime"
@@ -50,6 +49,9 @@ func BenchmarkEndToEndByteBuffer(b *testing.B) {
 }
 
 func TestCountEncodeMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
@@ -66,10 +68,15 @@ func TestCountEncodeMallocs(t *testing.T) {
                        t.Fatal("encode:", err)
                }
        })
-       fmt.Printf("mallocs per encode of type Bench: %v\n", allocs)
+       if allocs != 0 {
+               t.Fatalf("mallocs per encode of type Bench: %v; wanted 0\n", allocs)
+       }
 }
 
 func TestCountDecodeMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
@@ -96,5 +103,7 @@ func TestCountDecodeMallocs(t *testing.T) {
                        t.Fatal("decode:", err)
                }
        })
-       fmt.Printf("mallocs per decode of type Bench: %v\n", allocs)
+       if allocs != 3 {
+               t.Fatalf("mallocs per decode of type Bench: %v; wanted 3\n", allocs)
+       }
 }
index 42c591512026a5bf8cc8329b2f03e9b74f63fe19..199f337ec272183bc41fbf29ee12054d0b8bb3e5 100644 (file)
@@ -663,6 +663,9 @@ var mallocTest = []struct {
 var _ bytes.Buffer
 
 func TestCountMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
index a2b82a701c5587012a3854d3b36d49159bd38cfa..69b41a7953d1c4ada98a5cb8d8c8d3e25a50a407 100644 (file)
@@ -193,6 +193,9 @@ func BenchmarkHeaderWriteSubset(b *testing.B) {
 }
 
 func TestHeaderWriteSubsetMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
index 0631acdf94cdb673b22df87bd49e6c963060d6b4..3b9a88380cfa25f1d032e771c04464d9dcb0cc73 100644 (file)
@@ -503,6 +503,9 @@ func countMallocs(dial func() (*Client, error), t *testing.T) float64 {
 }
 
 func TestCountMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
@@ -510,6 +513,9 @@ func TestCountMallocs(t *testing.T) {
 }
 
 func TestCountMallocsOverHTTP(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
index e3c79b2c841cddc47e510df74c155df2f7eac0b0..15f46a13617d9c2a640dcc3bd36f729c25ee1489 100644 (file)
@@ -453,6 +453,9 @@ func TestTCPConcurrentAccept(t *testing.T) {
 }
 
 func TestTCPReadWriteMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        maxMallocs := 10000
        switch runtime.GOOS {
        // Add other OSes if you know how many mallocs they do.
index b1cdcee4ced80aaab3f710126819693c9cbe5c7d..bbb4e16f2a7901613682a661663d0aba70dd419a 100644 (file)
@@ -107,6 +107,9 @@ func TestClean(t *testing.T) {
                }
        }
 
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
                return
index 69caa80e4f93a22caa62b0de11bc4a88103fdefb..13b585223f834216410fa8d78962421346c944ab 100644 (file)
@@ -72,7 +72,12 @@ func TestClean(t *testing.T) {
                        t.Errorf("Clean(%q) = %q, want %q", test.result, s, test.result)
                }
        }
+}
 
+func TestCleanMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
                return
index fcdf87af817cfcc1e047a4c134f68740685a4fb0..c169c3594d59dc7c5040dc8936185915ecd340b3 100644 (file)
@@ -2287,6 +2287,9 @@ func TestAddr(t *testing.T) {
 }
 
 func noAlloc(t *testing.T, n int, f func(int)) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
@@ -3433,6 +3436,9 @@ func BenchmarkInterfaceBig(b *testing.B) {
 }
 
 func TestAllocsInterfaceBig(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        v := ValueOf(S{})
        if allocs := testing.AllocsPerRun(100, func() { v.Interface() }); allocs > 0 {
                t.Errorf("allocs:", allocs)
@@ -3447,6 +3453,9 @@ func BenchmarkInterfaceSmall(b *testing.B) {
 }
 
 func TestAllocsInterfaceSmall(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        v := ValueOf(int64(0))
        if allocs := testing.AllocsPerRun(100, func() { v.Interface() }); allocs > 0 {
                t.Errorf("allocs:", allocs)
index ee95c663cca22a1f899ee6a09e8da1d975e4e350..29b8d62dfed9dc6b393c79bd1cae828d92c8490e 100644 (file)
@@ -128,6 +128,9 @@ func runSearchWrappers() {
 }
 
 func TestSearchWrappersDontAlloc(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
index 40ab4ce6a4dc871e988cd8f9440c4409e0607b17..9a007dde4aaae643dea00f1a5157c0d219f032c4 100644 (file)
@@ -42,6 +42,9 @@ var (
 )
 
 func TestCountMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }
index 6d6e8ccd8a6f5b6d5617532f3fc686a29f54a62e..0619f88f0993dd5e8079f74dd7cfcce486ce31a0 100644 (file)
@@ -1385,6 +1385,9 @@ var mallocTest = []struct {
 }
 
 func TestCountMallocs(t *testing.T) {
+       if testing.Short() {
+               t.Skip("skipping malloc count in short mode")
+       }
        if runtime.GOMAXPROCS(0) > 1 {
                t.Skip("skipping; GOMAXPROCS>1")
        }