|
@@ -381,7 +381,12 @@ func TestHttpsInsecure(t *testing.T) {
|
381
|
381
|
go func() {
|
382
|
382
|
deadline := time.Now().Add(5 * time.Second)
|
383
|
383
|
for time.Now().Before(deadline) {
|
384
|
|
- // Simulate a hotspot function.
|
|
384
|
+ // Simulate a hotspot function. Spin in the inner loop for 100M iterations
|
|
385
|
+ // to ensure we get most of the samples landed here rather than in the
|
|
386
|
+ // library calls. We assume Go compiler won't elide the empty loop.
|
|
387
|
+ for i := 0; i < 1e8; i++ {
|
|
388
|
+ }
|
|
389
|
+ runtime.Gosched()
|
385
|
390
|
}
|
386
|
391
|
}()
|
387
|
392
|
|
|
@@ -409,13 +414,24 @@ func TestHttpsInsecure(t *testing.T) {
|
409
|
414
|
t.Fatal(err)
|
410
|
415
|
}
|
411
|
416
|
if len(p.SampleType) == 0 {
|
412
|
|
- t.Fatalf("grabProfile(%s) got empty profile: len(p.SampleType)==0", address)
|
|
417
|
+ t.Fatalf("fetchProfiles(%s) got empty profile: len(p.SampleType)==0", address)
|
|
418
|
+ }
|
|
419
|
+ if len(p.Function) == 0 {
|
|
420
|
+ t.Fatalf("fetchProfiles(%s) got non-symbolized profile: len(p.Function)==0", address)
|
413
|
421
|
}
|
414
|
|
- if err := checkProfileHasFunction(p, "TestHttpsInsecure"); err != nil {
|
415
|
|
- t.Fatalf("grabProfile(%s) %v", address, err)
|
|
422
|
+ if err := checkProfileHasFunction(p, "TestHttpsInsecure"); !badSigprofOS[runtime.GOOS] && err != nil {
|
|
423
|
+ t.Fatalf("fetchProfiles(%s) %v", address, err)
|
416
|
424
|
}
|
417
|
425
|
}
|
418
|
426
|
|
|
427
|
+// Some operating systems don't trigger the profiling signal right.
|
|
428
|
+// See https://github.com/golang/go/issues/13841.
|
|
429
|
+var badSigprofOS = map[string]bool{
|
|
430
|
+ "darwin": true,
|
|
431
|
+ "netbsd": true,
|
|
432
|
+ "plan9": true,
|
|
433
|
+}
|
|
434
|
+
|
419
|
435
|
func checkProfileHasFunction(p *profile.Profile, fname string) error {
|
420
|
436
|
for _, f := range p.Function {
|
421
|
437
|
if strings.Contains(f.Name, fname) {
|