github.com/undoio/delve@v1.9.0/pkg/proc/variable_test.go (about) 1 package proc_test 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/undoio/delve/pkg/proc" 8 protest "github.com/undoio/delve/pkg/proc/test" 9 ) 10 11 func TestGoroutineCreationLocation(t *testing.T) { 12 protest.AllowRecording(t) 13 withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) { 14 bp := setFunctionBreakpoint(p, t, "main.agoroutine") 15 assertNoError(p.Continue(), t, "Continue()") 16 17 gs, _, err := proc.GoroutinesInfo(p, 0, 0) 18 assertNoError(err, t, "GoroutinesInfo") 19 20 for _, g := range gs { 21 currentLocation := g.UserCurrent() 22 currentFn := currentLocation.Fn 23 if currentFn != nil && currentFn.BaseName() == "agoroutine" { 24 createdLocation := g.Go() 25 if createdLocation.Fn == nil { 26 t.Fatalf("goroutine creation function is nil") 27 } 28 if createdLocation.Fn.BaseName() != "main" { 29 t.Fatalf("goroutine creation function has wrong name: %s", createdLocation.Fn.BaseName()) 30 } 31 if filepath.Base(createdLocation.File) != "goroutinestackprog.go" { 32 t.Fatalf("goroutine creation file incorrect: %s", filepath.Base(createdLocation.File)) 33 } 34 if createdLocation.Line != 23 { 35 t.Fatalf("goroutine creation line incorrect: %v", createdLocation.Line) 36 } 37 } 38 39 } 40 41 p.ClearBreakpoint(bp.Addr) 42 p.Continue() 43 }) 44 }