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