aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-13 23:15:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-13 23:15:36 +0000
commit90a9ea010a03a970d97a96b532a987f4caf9008a (patch)
treef91783d65584efb8f8cd6823ca20d56da2458519
parentc915f63f7324de03f233803667d6401088fec783 (diff)
downloadgcc-90a9ea010a03a970d97a96b532a987f4caf9008a.zip
gcc-90a9ea010a03a970d97a96b532a987f4caf9008a.tar.gz
gcc-90a9ea010a03a970d97a96b532a987f4caf9008a.tar.bz2
runtime: Change gc_test to test only newly allocated memory.
From-SVN: r182315
-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 fad60a3..156d3bc 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)
}
}