MCPcopy Index your code
hub / github.com/maruel/panicparse / identifyPanicwebSignature

Function identifyPanicwebSignature

stack/context_test.go:2277–2479  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2275// One challenge is that the path will be different depending if this test is
2276// run within GOPATH or outside.
2277func 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

Callers 1

TestPanicwebFunction · 0.85

Calls 8

GetGoMinorVersionFunction · 0.92
IsUsingModulesFunction · 0.92
pathJoinFunction · 0.85
similarSignaturesFunction · 0.85
compareStacksFunction · 0.85
zapStacksFunction · 0.85
zapCallsFunction · 0.85
newCallLocalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…