Add LOOP_VINFO_MAX_VECT_FACTOR
[official-gcc.git] / libgo / go / internal / pprof / profile / profile_test.go
blobe1963f33515fee395c498c91a76b4d0ed1fb9e66
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package profile
7 import (
8 "bytes"
9 "testing"
12 func TestEmptyProfile(t *testing.T) {
13 var buf bytes.Buffer
14 p, err := Parse(&buf)
15 if err != nil {
16 t.Error("Want no error, got", err)
18 if p == nil {
19 t.Fatal("Want a valid profile, got <nil>")
21 if !p.Empty() {
22 t.Errorf("Profile should be empty, got %#v", p)
26 func TestParseContention(t *testing.T) {
27 tests := []struct {
28 name string
29 in string
30 wantErr bool
33 name: "valid",
34 in: `--- mutex:
35 cycles/second=3491920901
36 sampling period=1
37 43227965305 1659640 @ 0x45e851 0x45f764 0x4a2be1 0x44ea31
38 34035731690 15760 @ 0x45e851 0x45f764 0x4a2b17 0x44ea31
42 name: "valid with comment",
43 in: `--- mutex:
44 cycles/second=3491920901
45 sampling period=1
46 43227965305 1659640 @ 0x45e851 0x45f764 0x4a2be1 0x44ea31
47 # 0x45e850 sync.(*Mutex).Unlock+0x80 /go/src/sync/mutex.go:126
48 # 0x45f763 sync.(*RWMutex).Unlock+0x83 /go/src/sync/rwmutex.go:125
49 # 0x4a2be0 main.main.func3+0x70 /go/src/internal/pprof/profile/a_binary.go:58
51 34035731690 15760 @ 0x45e851 0x45f764 0x4a2b17 0x44ea31
52 # 0x45e850 sync.(*Mutex).Unlock+0x80 /go/src/sync/mutex.go:126
53 # 0x45f763 sync.(*RWMutex).Unlock+0x83 /go/src/sync/rwmutex.go:125
54 # 0x4a2b16 main.main.func2+0xd6 /go/src/internal/pprof/profile/a_binary.go:48
58 name: "empty",
59 in: `--- mutex:`,
60 wantErr: true,
63 name: "invalid header",
64 in: `--- channel:
65 43227965305 1659640 @ 0x45e851 0x45f764 0x4a2be1 0x44ea31`,
66 wantErr: true,
69 for _, tc := range tests {
70 _, err := parseContention([]byte(tc.in))
71 if tc.wantErr && err == nil {
72 t.Errorf("parseContention(%q) succeeded unexpectedly", tc.name)
74 if !tc.wantErr && err != nil {
75 t.Errorf("parseContention(%q) failed unexpectedly: %v", tc.name, err)