...

Source file src/github.com/google/pprof/internal/report/synth_test.go

Documentation: github.com/google/pprof/internal/report

     1  package report
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/google/pprof/profile"
     7  )
     8  
     9  func TestSynthAddresses(t *testing.T) {
    10  	s := newSynthCode(nil)
    11  	l1 := &profile.Location{}
    12  	addr1 := s.address(l1)
    13  	if s.address(l1) != addr1 {
    14  		t.Errorf("different calls with same location returned different addresses")
    15  	}
    16  
    17  	l2 := &profile.Location{}
    18  	addr2 := s.address(l2)
    19  	if addr2 == addr1 {
    20  		t.Errorf("same address assigned to different locations")
    21  	}
    22  
    23  }
    24  
    25  func TestSynthAvoidsMapping(t *testing.T) {
    26  	mappings := []*profile.Mapping{
    27  		{Start: 100, Limit: 200},
    28  		{Start: 300, Limit: 400},
    29  	}
    30  	s := newSynthCode(mappings)
    31  	loc := &profile.Location{}
    32  	addr := s.address(loc)
    33  	if addr >= 100 && addr < 200 || addr >= 300 && addr < 400 {
    34  		t.Errorf("synthetic location %d overlaps mapping %v", addr, mappings)
    35  	}
    36  }
    37  

View as plain text