|
@@ -35,8 +35,10 @@ import (
|
35
|
35
|
"testing"
|
36
|
36
|
"time"
|
37
|
37
|
|
|
38
|
+ "github.com/google/pprof/internal/binutils"
|
38
|
39
|
"github.com/google/pprof/internal/plugin"
|
39
|
40
|
"github.com/google/pprof/internal/proftest"
|
|
41
|
+ "github.com/google/pprof/internal/symbolizer"
|
40
|
42
|
"github.com/google/pprof/profile"
|
41
|
43
|
)
|
42
|
44
|
|
|
@@ -275,14 +277,37 @@ func TestHttpsInsecure(t *testing.T) {
|
275
|
277
|
defer os.Remove(outputTempFile.Name())
|
276
|
278
|
defer outputTempFile.Close()
|
277
|
279
|
|
278
|
|
- address := "https+insecure://" + l.Addr().String() + "/debug/pprof/profile?seconds=5"
|
279
|
|
- p, _, _, err := grabProfile(&source{}, address, 0, nil, testObj{}, &proftest.TestUI{T: t})
|
|
280
|
+ address := "https+insecure://" + l.Addr().String() + "/debug/pprof/profile"
|
|
281
|
+ s := &source{
|
|
282
|
+ Sources: []string{address},
|
|
283
|
+ Seconds: 10,
|
|
284
|
+ Timeout: 10,
|
|
285
|
+ Symbolize: "remote",
|
|
286
|
+ }
|
|
287
|
+ o := &plugin.Options{
|
|
288
|
+ Obj: &binutils.Binutils{},
|
|
289
|
+ UI: &proftest.TestUI{T: t, IgnoreRx: "Saved profile in"},
|
|
290
|
+ }
|
|
291
|
+ o.Sym = &symbolizer.Symbolizer{Obj: o.Obj, UI: o.UI}
|
|
292
|
+ p, err := fetchProfiles(s, o)
|
280
|
293
|
if err != nil {
|
281
|
294
|
t.Fatal(err)
|
282
|
295
|
}
|
283
|
296
|
if len(p.SampleType) == 0 {
|
284
|
297
|
t.Fatalf("grabProfile(%s) got empty profile: len(p.SampleType)==0", address)
|
285
|
298
|
}
|
|
299
|
+ if err := checkProfileHasFunction(p, "TestHttpsInsecure"); err != nil {
|
|
300
|
+ t.Fatalf("grabProfile(%s) %v", address, err)
|
|
301
|
+ }
|
|
302
|
+}
|
|
303
|
+
|
|
304
|
+func checkProfileHasFunction(p *profile.Profile, fname string) error {
|
|
305
|
+ for _, f := range p.Function {
|
|
306
|
+ if strings.Contains(f.Name, fname) {
|
|
307
|
+ return nil
|
|
308
|
+ }
|
|
309
|
+ }
|
|
310
|
+ return fmt.Errorf("got %s, want function %q", p.String(), fname)
|
286
|
311
|
}
|
287
|
312
|
|
288
|
313
|
func selfSignedCert(t *testing.T) tls.Certificate {
|