diff options
author | Carl Shapiro <cshapiro@google.com> | 2013-09-20 17:27:56 -0700 |
---|---|---|
committer | Carl Shapiro <cshapiro@google.com> | 2013-09-20 17:27:56 -0700 |
commit | 02725f0b86a9ada36f92acfe7a547953dffc324e (patch) | |
tree | 12b5570b47e15b4748bdcc9a9fca2325dc769ac5 /test | |
parent | 6995d3e7ff466f3504da6d6d826751a110d1c4ac (diff) | |
download | go-02725f0b86a9ada36f92acfe7a547953dffc324e.tar.gz |
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://codereview.appspot.com/13701046
Diffstat (limited to 'test')
-rw-r--r-- | test/chan/select2.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/chan/select2.go b/test/chan/select2.go index 4a0813912..ccf9dab81 100644 --- a/test/chan/select2.go +++ b/test/chan/select2.go @@ -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) } } |