diff options
author | Rob Pike <r@golang.org> | 2011-05-17 11:15:14 -0400 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2011-05-17 11:15:14 -0400 |
commit | f27c07a72d47b03d9b2129e6ead72bb742b5b1a0 (patch) | |
tree | d7e6b7de9f0abd23d39ffd85af3b28705c22ae1d /src/pkg/reflect | |
parent | a100f47cc3aa1e17be7f760013edff438a34802c (diff) | |
download | go-f27c07a72d47b03d9b2129e6ead72bb742b5b1a0.tar.gz |
reflect: make allocation test less fragile.
When GOMAXPROCS>1, the testing framework runs in parallel with the
test itself and may do a small number of allocations, so allow the
"noAllocs" condition to admit just a few.
Fixes issue 1782.
R=rsc
CC=golang-dev, rsc
http://codereview.appspot.com/4533041
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/reflect')
-rw-r--r-- | src/pkg/reflect/all_test.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go index 991d5ca8b..c83a9b75f 100644 --- a/src/pkg/reflect/all_test.go +++ b/src/pkg/reflect/all_test.go @@ -1451,7 +1451,9 @@ func noAlloc(t *testing.T, n int, f func(int)) { for j := 0; j < n; j++ { f(j) } - if runtime.MemStats.Mallocs != 0 { + // A few allocs may happen in the testing package when GOMAXPROCS > 1, so don't + // require zero mallocs. + if runtime.MemStats.Mallocs > 5 { t.Fatalf("%d mallocs after %d iterations", runtime.MemStats.Mallocs, n) } } |