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.
12 func TestEmptyProfile(t
*testing
.T
) {
16 t
.Error("Want no error, got", err
)
19 t
.Fatal("Want a valid profile, got <nil>")
22 t
.Errorf("Profile should be empty, got %#v", p
)
26 func TestParseContention(t
*testing
.T
) {
35 cycles/second=3491920901
37 43227965305 1659640 @ 0x45e851 0x45f764 0x4a2be1 0x44ea31
38 34035731690 15760 @ 0x45e851 0x45f764 0x4a2b17 0x44ea31
42 name
: "valid with comment",
44 cycles/second=3491920901
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
63 name
: "invalid header",
65 43227965305 1659640 @ 0x45e851 0x45f764 0x4a2be1 0x44ea31`,
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
)