From: Ian Lance Taylor Date: Tue, 13 Dec 2011 23:15:36 +0000 (+0000) Subject: runtime: Change gc_test to test only newly allocated memory. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=90a9ea010a03a970d97a96b532a987f4caf9008a;p=gcc.git runtime: Change gc_test to test only newly allocated memory. From-SVN: r182315 --- 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) } }