}
func TestCountEncodeMallocs(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
var buf bytes.Buffer
enc := NewEncoder(&buf)
bench := &Bench{7, 3.2, "now is the time", []byte("for all good men")}
}
func TestCountDecodeMallocs(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
var buf bytes.Buffer
enc := NewEncoder(&buf)
bench := &Bench{7, 3.2, "now is the time", []byte("for all good men")}
var _ bytes.Buffer
func TestCountMallocs(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
for _, mt := range mallocTest {
const N = 100
memstats := new(runtime.MemStats)
// does not cause deep recursion and in turn allocate too much memory.
// Test case for issue 3807.
func TestMulUnbalanced(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
x := rndNat(50000)
y := rndNat(40)
allocSize := allocBytes(func() {
}
func doHeaderWriteSubset(n int, t errorfer) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
h := Header(map[string][]string{
"Content-Length": {"123"},
"Content-Type": {"text/plain"},
var m1 runtime.MemStats
runtime.ReadMemStats(&m1)
if mallocs := m1.Mallocs - m0.Mallocs; n >= 100 && mallocs >= uint64(n) {
- // TODO(bradfitz,rsc): once we can sort with allocating,
+ // TODO(bradfitz,rsc): once we can sort without allocating,
// make this an error. See http://golang.org/issue/3761
// t.Errorf("did %d mallocs (>= %d iterations); should have avoided mallocs", mallocs, n)
}
}
func countMallocs(dial func() (*Client, error), t *testing.T) uint64 {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
once.Do(startServer)
client, err := dial()
if err != nil {
}
func TestClean(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
tests := cleantests
if runtime.GOOS == "windows" {
for i := range tests {
}
func TestBug3486(t *testing.T) { // http://code.google.com/p/go/issues/detail?id=3486
- root, err := filepath.EvalSymlinks(os.Getenv("GOROOT"))
+ root, err := filepath.EvalSymlinks(runtime.GOROOT())
if err != nil {
t.Fatal(err)
}
}
func TestClean(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
for _, test := range cleantests {
if s := Clean(test.path); s != test.result {
t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.result)
}
func noAlloc(t *testing.T, n int, f func(int)) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
// once to prime everything
f(-1)
memstats := new(runtime.MemStats)
for j := 0; j < n; j++ {
f(j)
}
- // A few allocs may happen in the testing package when GOMAXPROCS > 1, so don't
- // require zero mallocs.
- // A new thread, one of which will be created if GOMAXPROCS>1, does 6 allocations.
runtime.ReadMemStats(memstats)
mallocs := memstats.Mallocs - oldmallocs
- if mallocs > 10 {
+ if mallocs > 0 {
t.Fatalf("%d mallocs after %d iterations", mallocs, n)
}
}
)
func TestGcSys(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
memstats := new(runtime.MemStats)
runtime.GC()
runtime.ReadMemStats(memstats)
}
func AllocAndFree(size, count int) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
if *chatty {
fmt.Printf("size=%d count=%d ...\n", size, count)
}
)
func TestCountMallocs(t *testing.T) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
for _, mt := range mallocTest {
const N = 100
memstats := new(runtime.MemStats)