summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-13 23:15:36 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-13 23:15:36 +0000
commitfac2373eba045b87019c34579770d4139e488ac7 (patch)
treef91783d65584efb8f8cd6823ca20d56da2458519 /libgo
parentc235a48ce0ce55679dcc96f4035a15c3468693f0 (diff)
downloadgcc-fac2373eba045b87019c34579770d4139e488ac7.tar.gz
runtime: Change gc_test to test only newly allocated memory.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182315 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/gc_test.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/libgo/go/runtime/gc_test.go b/libgo/go/runtime/gc_test.go
index fad60a36804..156d3bc7d30 100644
--- a/libgo/go/runtime/gc_test.go
+++ b/libgo/go/runtime/gc_test.go
@@ -6,16 +6,24 @@ import (
)
func TestGcSys(t *testing.T) {
+ runtime.GC()
+ runtime.UpdateMemStats()
+ sys := runtime.MemStats.Sys
+
for i := 0; i < 1000000; i++ {
workthegc()
}
// Should only be using a few MB.
runtime.UpdateMemStats()
- sys := runtime.MemStats.Sys
- t.Logf("using %d MB", sys>>20)
- if sys > 10e6 {
- t.Fatalf("using too much memory: %d MB", sys>>20)
+ if sys > runtime.MemStats.Sys {
+ sys = 0
+ } else {
+ sys = runtime.MemStats.Sys - sys
+ }
+ t.Logf("used %d extra bytes", sys)
+ if sys > 2<<20 {
+ t.Fatalf("using too much memory: %d bytes", sys)
}
}