]> Cypherpunks repositories - gostls13.git/commitdiff
testing: unflake TestBRun
authorMarcel van Lohuizen <mpvl@golang.org>
Mon, 4 Apr 2016 17:05:48 +0000 (19:05 +0200)
committerMarcel van Lohuizen <mpvl@golang.org>
Mon, 4 Apr 2016 17:37:58 +0000 (17:37 +0000)
by only testing the lower bound of memalloc

Fixes #15063

Change-Id: Iab2fdd75e9ce98c641bfbce57f142fa47176772d
Reviewed-on: https://go-review.googlesource.com/21507
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>

src/testing/sub_test.go

index 2d7edd3450d2d2955b502478b2cf37d26a36eb26..264d77c2cf800d0b51bee62b5be07df5e926a6cf 100644 (file)
@@ -384,10 +384,14 @@ func TestBRun(t *T) {
                        }
                        b.Run("", func(b *B) { alloc(b) })
                        b.Run("", func(b *B) { alloc(b) })
-                       if got := b.result.MemAllocs; got != 2 {
+                       // runtime.MemStats sometimes reports more allocations than the
+                       // benchmark is responsible for. Luckily the point of this test is
+                       // to ensure that the results are not underreported, so we can
+                       // simply verify the lower bound.
+                       if got := b.result.MemAllocs; got < 2 {
                                t.Errorf("MemAllocs was %v; want 2", got)
                        }
-                       if got := b.result.MemBytes; got != 2*bufSize {
+                       if got := b.result.MemBytes; got < 2*bufSize {
                                t.Errorf("MemBytes was %v; want %v", got, 2*bufSize)
                        }
                },