| 1 | // Copyright 2018 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 19 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 20 | "reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/" |
| 21 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 22 | |
| 23 | "github.com/google/pprof/internal/proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/" |
| 24 | ) |
| 25 | |
| 26 | func TestMapMappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestMapMapping().(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#) { |
| 27 | pm := &profileMergerscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#{ |
| 28 | pscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#p.: &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{}, |
| 29 | mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#mappings.: make(map[mappingKeyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappingKey#]*Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#), |
| 30 | mappingsByIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#mappingsByID.: make(map[uint64]mapInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#), |
| 31 | } |
| 32 | for _, tc := range []struct { |
| 33 | desc string |
| 34 | m1 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping# |
| 35 | m2 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping# |
| 36 | wantMerged bool |
| 37 | }{ |
| 38 | { |
| 39 | desc: "same file name", |
| 40 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 41 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 1, |
| 42 | Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "test-file-1", |
| 43 | }, |
| 44 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 45 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 2, |
| 46 | Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "test-file-1", |
| 47 | }, |
| 48 | wantMerged: true, |
| 49 | }, |
| 50 | { |
| 51 | desc: "same build ID", |
| 52 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 53 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 3, |
| 54 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-1", |
| 55 | }, |
| 56 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 57 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 4, |
| 58 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-1", |
| 59 | }, |
| 60 | wantMerged: true, |
| 61 | }, |
| 62 | { |
| 63 | desc: "same fake mapping", |
| 64 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 65 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 5, |
| 66 | }, |
| 67 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 68 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 6, |
| 69 | }, |
| 70 | wantMerged: true, |
| 71 | }, |
| 72 | { |
| 73 | desc: "different start", |
| 74 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 75 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 7, |
| 76 | Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x1000, |
| 77 | Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x2000, |
| 78 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-2", |
| 79 | }, |
| 80 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 81 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 8, |
| 82 | Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x3000, |
| 83 | Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x4000, |
| 84 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-2", |
| 85 | }, |
| 86 | wantMerged: true, |
| 87 | }, |
| 88 | { |
| 89 | desc: "different file name", |
| 90 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 91 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 9, |
| 92 | Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "test-file-2", |
| 93 | }, |
| 94 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 95 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 10, |
| 96 | Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "test-file-3", |
| 97 | }, |
| 98 | }, |
| 99 | { |
| 100 | desc: "different build id", |
| 101 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 102 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 11, |
| 103 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-3", |
| 104 | }, |
| 105 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 106 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 12, |
| 107 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-4", |
| 108 | }, |
| 109 | }, |
| 110 | { |
| 111 | desc: "different size", |
| 112 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 113 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 13, |
| 114 | Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x1000, |
| 115 | Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x3000, |
| 116 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-5", |
| 117 | }, |
| 118 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 119 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 14, |
| 120 | Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x1000, |
| 121 | Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x5000, |
| 122 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-5", |
| 123 | }, |
| 124 | }, |
| 125 | { |
| 126 | desc: "different offset", |
| 127 | m1: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 128 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 15, |
| 129 | Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset.: 1, |
| 130 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-6", |
| 131 | }, |
| 132 | m2: Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 133 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 16, |
| 134 | Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset.: 2, |
| 135 | BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.: "test-build-id-6", |
| 136 | }, |
| 137 | }, |
| 138 | } { |
| 139 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.desc, func(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#) { |
| 140 | info1 := pm.mapMappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#mapMapping().(&tc.m1) |
| 141 | info2 := pm.mapMappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/profileMerger#mapMapping().(&tc.m2) |
| 142 | gotM1, gotM2 := *info1.mscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#m., *info2.mscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#m. |
| 143 | |
| 144 | wantM1 := tc.m1 |
| 145 | wantM1.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. = gotM1.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. |
| 146 | if gotM1 != wantM1 { |
| 147 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("first mapping got %v, want %v", gotM1, wantM1) |
| 148 | } |
| 149 | |
| 150 | if tc.wantMerged { |
| 151 | if gotM1 != gotM2 { |
| 152 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("first mapping got %v, second mapping got %v, want equal", gotM1, gotM2) |
| 153 | } |
| 154 | if info1.offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#offset. != 0 { |
| 155 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("first mapping info got offset %d, want 0", info1.offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#offset.) |
| 156 | } |
| 157 | if wantOffset := int64(tc.m1.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.) - int64(tc.m2.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.); wantOffset != info2.offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#offset. { |
| 158 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("second mapping info got offset %d, want %d", info2.offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mapInfo#offset., wantOffset) |
| 159 | } |
| 160 | } else { |
| 161 | if gotM1.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. == gotM2.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. { |
| 162 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("first mapping got %v, second mapping got %v, want different IDs", gotM1, gotM2) |
| 163 | } |
| 164 | wantM2 := tc.m2 |
| 165 | wantM2.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. = gotM2.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. |
| 166 | if gotM2 != wantM2 { |
| 167 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("second mapping got %v, want %v", gotM2, wantM2) |
| 168 | } |
| 169 | } |
| 170 | }) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | func TestLocationIDMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestLocationIDMap().(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#) { |
| 175 | ids := []uint64{1, 2, 5, 9, 10, 11, 100, 1000, 1000000} |
| 176 | missing := []uint64{3, 4, 200} |
| 177 | |
| 178 | // Populate the map,. |
| 179 | idmap := makeLocationIDMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/makeLocationIDMap().(10) |
| 180 | for _, id := range ids { |
| 181 | loc := &Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: id} |
| 182 | idmap.setscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/locationIDMap#set().(id, loc) |
| 183 | } |
| 184 | |
| 185 | // Check ids that should be present in the map. |
| 186 | for _, id := range ids { |
| 187 | loc := idmap.getscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/locationIDMap#get().(id) |
| 188 | if loc == nil { |
| 189 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("No location found for %d", id) |
| 190 | } else if loc.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID. != id { |
| 191 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Wrong location %d found for %d", loc.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID., id) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // Check ids that should not be present in the map. |
| 196 | for _, id := range missing { |
| 197 | loc := idmap.getscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/locationIDMap#get().(id) |
| 198 | if loc != nil { |
| 199 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Unexpected location %d found for %d", loc.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID., id) |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | func BenchmarkMergescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/BenchmarkMerge().(b *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Bscip-go gomod github.com/golang/go/src go1.24.0 testing/B#) { |
| 205 | data := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.LargeProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/LargeProfile().(b) |
| 206 | for n := 1; n <= 2; n++ { // Merge either 1 or 2 instances. |
| 207 | b.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/B#Run().(fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%d", n), func(b *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Bscip-go gomod github.com/golang/go/src go1.24.0 testing/B#) { |
| 208 | list := make([]*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, n) |
| 209 | for i := 0; i < n; i++ { |
| 210 | prof, err := Parsescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Parse().(bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewBuffer().(data)) |
| 211 | if err != nil { |
| 212 | b.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 213 | } |
| 214 | list[i] = prof |
| 215 | } |
| 216 | b.ResetTimerscip-go gomod github.com/golang/go/src go1.24.0 testing/B#ResetTimer().() |
| 217 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.24.0 testing/B#N.; i++ { |
| 218 | _, err := Mergescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Merge().(list) |
| 219 | if err != nil { |
| 220 | b.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 221 | } |
| 222 | } |
| 223 | }) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | func TestCompatibilizeSampleTypesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestCompatibilizeSampleTypes().(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#) { |
| 228 | for _, tc := range []struct { |
| 229 | desc string |
| 230 | ps []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# |
| 231 | want []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# |
| 232 | wantError bool |
| 233 | }{ |
| 234 | { |
| 235 | desc: "drop first sample types", |
| 236 | ps: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 237 | { |
| 238 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "delete1", |
| 239 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 240 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit1"}, |
| 241 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit2"}, |
| 242 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 243 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 244 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 245 | }, |
| 246 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 247 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3, 4, 5}}, |
| 248 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30, 40, 50}}, |
| 249 | }, |
| 250 | }, |
| 251 | { |
| 252 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep1", |
| 253 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 254 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 255 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 256 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 257 | }, |
| 258 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 259 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 260 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 261 | }, |
| 262 | }, |
| 263 | }, |
| 264 | want: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 265 | { |
| 266 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep1", |
| 267 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 268 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 269 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 270 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 271 | }, |
| 272 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 273 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{3, 4, 5}}, |
| 274 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{30, 40, 50}}, |
| 275 | }, |
| 276 | }, |
| 277 | { |
| 278 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep1", |
| 279 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 280 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 281 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 282 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 283 | }, |
| 284 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 285 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 286 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 287 | }, |
| 288 | }, |
| 289 | }, |
| 290 | }, |
| 291 | { |
| 292 | desc: "drop last sample types", |
| 293 | ps: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 294 | { |
| 295 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "delete2", |
| 296 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 297 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 298 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 299 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 300 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit1"}, |
| 301 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit2"}, |
| 302 | }, |
| 303 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 304 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3, 4, 5}}, |
| 305 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30, 40, 50}}, |
| 306 | }, |
| 307 | }, |
| 308 | { |
| 309 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep2", |
| 310 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 311 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 312 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 313 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 314 | }, |
| 315 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 316 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 317 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 318 | }, |
| 319 | }, |
| 320 | }, |
| 321 | want: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 322 | { |
| 323 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep1", |
| 324 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 325 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 326 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 327 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 328 | }, |
| 329 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 330 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 331 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 332 | }, |
| 333 | }, |
| 334 | { |
| 335 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep2", |
| 336 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 337 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 338 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 339 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 340 | }, |
| 341 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 342 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 343 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 344 | }, |
| 345 | }, |
| 346 | }, |
| 347 | }, |
| 348 | { |
| 349 | desc: "drop sample types and reorder", |
| 350 | ps: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 351 | { |
| 352 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep3", |
| 353 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 354 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit1"}, |
| 355 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 356 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "delete2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit2"}, |
| 357 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 358 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 359 | }, |
| 360 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 361 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3, 4, 5}}, |
| 362 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30, 40, 50}}, |
| 363 | }, |
| 364 | }, |
| 365 | { |
| 366 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep2", |
| 367 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 368 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 369 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 370 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 371 | }, |
| 372 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 373 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 2, 3}}, |
| 374 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10, 20, 30}}, |
| 375 | }, |
| 376 | }, |
| 377 | }, |
| 378 | want: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 379 | { |
| 380 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep3", |
| 381 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 382 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 383 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 384 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 385 | }, |
| 386 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 387 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{2, 4, 5}}, |
| 388 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{20, 40, 50}}, |
| 389 | }, |
| 390 | }, |
| 391 | { |
| 392 | DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType.: "keep2", |
| 393 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 394 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 395 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 396 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 397 | }, |
| 398 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 399 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{3, 2, 1}}, |
| 400 | {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{30, 20, 10}}, |
| 401 | }, |
| 402 | }, |
| 403 | }, |
| 404 | }, |
| 405 | { |
| 406 | desc: "empty common types", |
| 407 | ps: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 408 | { |
| 409 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 410 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep1", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit1"}, |
| 411 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep2", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit2"}, |
| 412 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep3", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit3"}, |
| 413 | }, |
| 414 | }, |
| 415 | { |
| 416 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 417 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep4", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit4"}, |
| 418 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "keep5", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "Unit5"}, |
| 419 | }, |
| 420 | }, |
| 421 | }, |
| 422 | wantError: true, |
| 423 | }, |
| 424 | } { |
| 425 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.desc, func(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#) { |
| 426 | err := CompatibilizeSampleTypesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/CompatibilizeSampleTypes().(tc.ps) |
| 427 | if (err != nil) != tc.wantError { |
| 428 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("CompatibilizeSampleTypes() returned error: %v, want any error=%t", err, tc.wantError) |
| 429 | } |
| 430 | if err != nil { |
| 431 | return |
| 432 | } |
| 433 | for i := 0; i < len(tc.want); i++ { |
| 434 | gotStr := tc.ps[i].Stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#String().() |
| 435 | wantStr := tc.want[i].Stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#String().() |
| 436 | if gotStr != wantStr { |
| 437 | d, err := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.Diffscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/Diff().([]byte(wantStr), []byte(gotStr)) |
| 438 | if err != nil { |
| 439 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("failed to get diff: %v", err) |
| 440 | } |
| 441 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("CompatibilizeSampleTypes(): profile[%d] got diff (-want +got)\n%s", i, string(d)) |
| 442 | } |
| 443 | } |
| 444 | }) |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | func TestDocURLMergescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestDocURLMerge().(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#) { |
| 449 | const url1 = "http://example.com/url1" |
| 450 | const url2 = "http://example.com/url2" |
| 451 | type testCase struct { |
| 452 | name string |
| 453 | profiles []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# |
| 454 | want string |
| 455 | } |
| 456 | profile := func(url string) *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# { |
| 457 | return &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 458 | PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: &ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "seconds"}, |
| 459 | DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL.: url, |
| 460 | } |
| 461 | } |
| 462 | for _, test := range []testCase{ |
| 463 | { |
| 464 | name: "nolinks", |
| 465 | profiles: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 466 | profile(""), |
| 467 | profile(""), |
| 468 | }, |
| 469 | want: "", |
| 470 | }, |
| 471 | { |
| 472 | name: "single", |
| 473 | profiles: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 474 | profile(url1), |
| 475 | }, |
| 476 | want: url1, |
| 477 | }, |
| 478 | { |
| 479 | name: "mix", |
| 480 | profiles: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 481 | profile(""), |
| 482 | profile(url1), |
| 483 | }, |
| 484 | want: url1, |
| 485 | }, |
| 486 | { |
| 487 | name: "different", |
| 488 | profiles: []*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 489 | profile(url1), |
| 490 | profile(url2), |
| 491 | }, |
| 492 | want: url1, |
| 493 | }, |
| 494 | } { |
| 495 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(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#) { |
| 496 | merged, err := combineHeadersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/combineHeaders().(test.profiles) |
| 497 | if err != nil { |
| 498 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 499 | } |
| 500 | got := merged.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL. |
| 501 | if !reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.24.0 reflect/DeepEqual().(test.want, got) { |
| 502 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("unexpected links; want: %#v, got: %#v", test.want, got) |
| 503 | } |
| 504 | }) |
| 505 | } |
| 506 | } |