|
@@ -161,16 +161,29 @@ func TestFetch(t *testing.T) {
|
161
|
161
|
// Intercept http.Get calls from HTTPFetcher.
|
162
|
162
|
httpGet = stubHTTPGet
|
163
|
163
|
|
164
|
|
- for _, source := range [][2]string{
|
165
|
|
- {path + "go.crc32.cpu", "go.crc32.cpu"},
|
166
|
|
- {"http://localhost/profile?file=cppbench.cpu", "cppbench.cpu"},
|
|
164
|
+ type testcase struct {
|
|
165
|
+ source, execName string
|
|
166
|
+ }
|
|
167
|
+
|
|
168
|
+ for _, tc := range []testcase{
|
|
169
|
+ {path + "go.crc32.cpu", ""},
|
|
170
|
+ {path + "go.nomappings.crash", "/bin/gotest.exe"},
|
|
171
|
+ {"http://localhost/profile?file=cppbench.cpu", ""},
|
167
|
172
|
} {
|
168
|
|
- p, _, err := fetch(source[0], 0, 10*time.Second, &proftest.TestUI{t, 0})
|
|
173
|
+ p, _, _, err := grabProfile(&source{ExecName: tc.execName}, tc.source, 0, nil, testObj{}, &proftest.TestUI{t, 0})
|
169
|
174
|
if err != nil {
|
170
|
|
- t.Fatalf("%s: %s", source[0], err)
|
|
175
|
+ t.Fatalf("%s: %s", tc.source, err)
|
171
|
176
|
}
|
172
|
177
|
if len(p.Sample) == 0 {
|
173
|
|
- t.Errorf("want non-zero samples")
|
|
178
|
+ t.Errorf("%s: want non-zero samples", tc.source)
|
|
179
|
+ }
|
|
180
|
+ if e := tc.execName; e != "" {
|
|
181
|
+ switch {
|
|
182
|
+ case len(p.Mapping) == 0 || p.Mapping[0] == nil:
|
|
183
|
+ t.Errorf("%s: want mapping[0].execName == %s, got no mappings", tc.source, e)
|
|
184
|
+ case p.Mapping[0].File != e:
|
|
185
|
+ t.Errorf("%s: want mapping[0].execName == %s, got %s", tc.source, e, p.Mapping[0].File)
|
|
186
|
+ }
|
174
|
187
|
}
|
175
|
188
|
}
|
176
|
189
|
}
|