-
Notifications
You must be signed in to change notification settings - Fork 5
/
pprof_test.go
52 lines (42 loc) · 1.04 KB
/
pprof_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pprofserver
import (
"reflect"
"strings"
"testing"
)
func TestParsePprofHome(t *testing.T) {
r := strings.NewReader(`<html>
<head>
<title>/debug/pprof/</title>
</head>
<body>
/debug/pprof/<br>
<br>
profiles:<br>
<table>
<tr><td align=right>0<td><a href="block?debug=1">block</a>
<tr><td align=right>33<td><a href="goroutine?debug=1">goroutine</a>
<tr><td align=right>3<td><a href="heap?debug=1">heap</a>
<tr><td align=right>0<td><a href="mutex?debug=1">mutex</a>
<tr><td align=right>11<td><a href="threadcreate?debug=1">threadcreate</a>
</table>
<br>
<a href="goroutine?debug=2">full goroutine stack dump</a><br>
</body>
</html>
`)
p, err := parsePprofHome(r)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(p, []profile{
{Name: "block", URL: "block?debug=1"},
{Name: "goroutine", URL: "goroutine?debug=1"},
{Name: "heap", URL: "heap?debug=1"},
{Name: "mutex", URL: "mutex?debug=1"},
{Name: "threadcreate", URL: "threadcreate?debug=1"},
{Name: "full goroutine stack dump", URL: "goroutine?debug=2"},
}) {
t.Error(p)
}
}