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