aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/malloc_test.go')
-rw-r--r--src/pkg/runtime/malloc_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc_test.go b/src/pkg/runtime/malloc_test.go
index 1afd32d08c..2b686a6e7e 100644
--- a/src/pkg/runtime/malloc_test.go
+++ b/src/pkg/runtime/malloc_test.go
@@ -5,10 +5,25 @@
package runtime_test
import (
+ . "runtime"
"testing"
"unsafe"
)
+func TestMemStats(t *testing.T) {
+ // Test that MemStats has sane values.
+ st := new(MemStats)
+ ReadMemStats(st)
+ if st.HeapSys == 0 || st.StackSys == 0 || st.MSpanSys == 0 || st.MCacheSys == 0 ||
+ st.BuckHashSys == 0 || st.GCSys == 0 || st.OtherSys == 0 {
+ t.Fatalf("Zero sys value: %+v", *st)
+ }
+ if st.Sys != st.HeapSys+st.StackSys+st.MSpanSys+st.MCacheSys+
+ st.BuckHashSys+st.GCSys+st.OtherSys {
+ t.Fatalf("Bad sys value: %+v", *st)
+ }
+}
+
var mallocSink uintptr
func BenchmarkMalloc8(b *testing.B) {