MCPcopy Create free account
hub / github.com/google/pprof / TestStackSources

Function TestStackSources

internal/report/stacks_test.go:98–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestStackSources(t *testing.T) {
99 // See report_test.go for the functions available to use in tests.
100 locs := clearLineAndColumn(testL)
101 main, foo, bar, tee, inl := locs[0], locs[1], locs[2], locs[3], locs[5]
102
103 type srcInfo struct {
104 name string
105 self int64
106 inlined bool
107 }
108
109 source := func(stacks StackSet, name string) srcInfo {
110 src := findSource(stacks, name)
111 return srcInfo{src.FullName, src.Self, src.Inlined}
112 }
113
114 for _, c := range []struct {
115 name string
116 stacks StackSet
117 srcs []srcInfo
118 }{
119 {
120 "empty",
121 makeTestStacks(),
122 []srcInfo{},
123 },
124 {
125 "two-leaves",
126 makeTestStacks(
127 testSample(100, bar, foo, main),
128 testSample(200, tee, bar, foo, main),
129 testSample(1000, tee, main),
130 ),
131 []srcInfo{
132 {"main", 0, false},
133 {"bar", 100, false},
134 {"foo", 0, false},
135 {"tee", 1200, false},
136 },
137 },
138 {
139 "inlined",
140 makeTestStacks(
141 testSample(100, inl),
142 testSample(200, inl),
143 ),
144 []srcInfo{
145 // inl has bar->tee
146 {"tee", 300, true},
147 },
148 },
149 {
150 "recursion",
151 makeTestStacks(
152 testSample(100, foo, foo, foo, main),
153 testSample(100, foo, foo, main),
154 ),
155 []srcInfo{

Callers

nothing calls this directly

Calls 5

clearLineAndColumnFunction · 0.85
findSourceFunction · 0.85
makeTestStacksFunction · 0.85
testSampleFunction · 0.85
sourceStruct · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…