mirror of
https://github.com/golang/go
synced 2024-11-26 16:36:49 -07:00
test/chan: avoid wrap-around in memstats comparison
The select2.go test assumed that the memory allocated between its two samplings of runtime.ReadMemStats is strictly increasing. To avoid failing the tests when this is not true, a greater-than check is introduced before computing the difference in allocated memory. R=golang-dev, r, cshapiro CC=golang-dev https://golang.org/cl/13701046
This commit is contained in:
parent
0826c04e14
commit
1c45f98fa3
@ -47,7 +47,8 @@ func main() {
|
||||
runtime.GC()
|
||||
runtime.ReadMemStats(memstats)
|
||||
|
||||
if memstats.Alloc-alloc > 1.1e5 {
|
||||
// Be careful to avoid wraparound.
|
||||
if memstats.Alloc > alloc && memstats.Alloc-alloc > 1.1e5 {
|
||||
println("BUG: too much memory for 100,000 selects:", memstats.Alloc-alloc)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user