Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
runtime: only run TestMemStats sanity tests once
Fixes #22696

Change-Id: Ibe4628f71d64a2b36b655ea69710a925924b12a3
Reviewed-on: https://go-review.googlesource.com/122586
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
  • Loading branch information
ianlancetaylor committed Jul 9, 2018
1 parent a41d216 commit 9b7a8aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/runtime/malloc_test.go
Expand Up @@ -19,7 +19,11 @@ import (
"unsafe"
)

var testMemStatsCount int

func TestMemStats(t *testing.T) {
testMemStatsCount++

// Make sure there's at least one forced GC.
GC()

Expand All @@ -35,6 +39,13 @@ func TestMemStats(t *testing.T) {
}
le := func(thresh float64) func(interface{}) error {
return func(x interface{}) error {
// These sanity tests aren't necessarily valid
// with high -test.count values, so only run
// them once.
if testMemStatsCount > 1 {
return nil
}

if reflect.ValueOf(x).Convert(reflect.TypeOf(thresh)).Float() < thresh {
return nil
}
Expand Down

0 comments on commit 9b7a8aa

Please sign in to comment.