]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Make gc_test test extra allocated space, not total space.
authorIan Lance Taylor <iant@golang.org>
Tue, 13 Dec 2011 23:12:55 +0000 (15:12 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 13 Dec 2011 23:12:55 +0000 (15:12 -0800)
Testing total space fails for gccgo when not using split
stacks, because then each goroutine has a large stack, and so
the total memory usage is large.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5487068

src/pkg/runtime/gc_test.go

index fad60a368041c7b457791f68b7345a595326e928..156d3bc7d30264675103696ef2c388be6fd3e74e 100644 (file)
@@ -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)
        }
 }