identifyPanicwebSignature tries to assign one of the predefined signature to the bucket provided. One challenge is that the path will be different depending if this test is run within GOPATH or outside.
(t *testing.T, b *Bucket, pwebDir string)
| 2275 | // One challenge is that the path will be different depending if this test is |
| 2276 | // run within GOPATH or outside. |
| 2277 | func identifyPanicwebSignature(t *testing.T, b *Bucket, pwebDir string) panicwebSignatureType { |
| 2278 | ver := "" |
| 2279 | if !isInGOPATH { |
| 2280 | ver = "/v2" |
| 2281 | } |
| 2282 | |
| 2283 | // The first bucket (the one calling panic()) is deterministic. |
| 2284 | if b.First { |
| 2285 | if len(b.IDs) != 1 { |
| 2286 | t.Fatal("first bucket is not correct") |
| 2287 | return pstUnknown |
| 2288 | } |
| 2289 | want := Signature{ |
| 2290 | State: "running", |
| 2291 | Stack: Stack{ |
| 2292 | Calls: []Call{ |
| 2293 | newCallLocal("main.main", Args{}, pathJoin(pwebDir, "main.go"), 80), |
| 2294 | }, |
| 2295 | }, |
| 2296 | } |
| 2297 | similarSignatures(t, &want, &b.Signature) |
| 2298 | return pstMain |
| 2299 | } |
| 2300 | |
| 2301 | // We should find exactly 10 sleeping routines in the URL1Handler handler |
| 2302 | // signature and 3 in URL2Handler. |
| 2303 | if s := b.Stack.Calls[0].Func.Name; s == "URL1Handler" || s == "URL2Handler" { |
| 2304 | if b.State != "chan receive" { |
| 2305 | t.Fatalf("suspicious: %#v", b) |
| 2306 | return pstUnknown |
| 2307 | } |
| 2308 | if b.Stack.Calls[0].ImportPath != "github.com/maruel/panicparse"+ver+"/cmd/panicweb/internal" { |
| 2309 | t.Fatalf("suspicious: %q\n%#v", b.Stack.Calls[0].ImportPath, b) |
| 2310 | return pstUnknown |
| 2311 | } |
| 2312 | if b.Stack.Calls[0].SrcName != "internal.go" { |
| 2313 | t.Fatalf("suspicious: %#v", b) |
| 2314 | return pstUnknown |
| 2315 | } |
| 2316 | if b.CreatedBy.Calls[0].SrcName != "server.go" { |
| 2317 | t.Fatalf("suspicious: %#v", b) |
| 2318 | return pstUnknown |
| 2319 | } |
| 2320 | if b.CreatedBy.Calls[0].ImportPath != "net/http" { |
| 2321 | t.Fatalf("suspicious: %#v", b) |
| 2322 | return pstUnknown |
| 2323 | } |
| 2324 | if b.CreatedBy.Calls[0].Func.Name != "(*Server).Serve" { |
| 2325 | t.Fatalf("suspicious: %#v", b) |
| 2326 | return pstUnknown |
| 2327 | } |
| 2328 | if s == "URL1Handler" { |
| 2329 | return pstURL1handler |
| 2330 | } |
| 2331 | return pstURL2handler |
| 2332 | } |
| 2333 | |
| 2334 | // Find the client goroutine signatures. For the client, it is likely that |
no test coverage detected
searching dependent graphs…