1
0
mirror of https://github.com/golang/go synced 2024-11-20 10:04:45 -07:00

reflect: set GOMAXPROCS=1 in the malloc test

Occasionally I see:
--- FAIL: TestAllocations-15 (0.00 seconds)
        all_test.go:1575: 6 mallocs after 100 iterations
Tested:
$ go test -cpu=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 reflect

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/6354063
This commit is contained in:
Dmitriy Vyukov 2012-07-02 20:55:08 +04:00
parent 804e562a62
commit 21de1ab359

View File

@ -1569,9 +1569,10 @@ func noAlloc(t *testing.T, n int, f func(int)) {
}
// 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 > 5 {
if mallocs > 10 {
t.Fatalf("%d mallocs after %d iterations", mallocs, n)
}
}