proc/test: improve TestStepParked
It was possible for TestStepParked to pick a runtime goroutine and attempt to step it. Nothing guarantees that a goroutine other than the ones we are using to run the code would actually ever resume before the end of the program. This makes the test more discerning in its choice of goroutines.
This commit is contained in:
parent
92faa95bf9
commit
f2581e608a
@ -1861,13 +1861,23 @@ func TestStepParked(t *testing.T) {
|
||||
assertNoError(err, t, "GoroutinesInfo()")
|
||||
|
||||
for _, g := range gs {
|
||||
if g.thread == nil {
|
||||
if g.thread == nil && g.CurrentLoc.Fn != nil && g.CurrentLoc.Fn.Name == "main.sayhi" {
|
||||
parkedg = g
|
||||
break LookForParkedG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("Parked g is: %v\n", parkedg)
|
||||
frames, _ := parkedg.Stacktrace(20)
|
||||
for _, frame := range frames {
|
||||
name := ""
|
||||
if frame.Call.Fn != nil {
|
||||
name = frame.Call.Fn.Name
|
||||
}
|
||||
t.Logf("\t%s:%d in %s (%#x)", frame.Call.File, frame.Call.Line, name, frame.Current.PC)
|
||||
}
|
||||
|
||||
assertNoError(p.SwitchGoroutine(parkedg.ID), t, "SwitchGoroutine()")
|
||||
p.ClearBreakpoint(bp.Addr)
|
||||
assertNoError(p.Step(), t, "Step()")
|
||||
|
Loading…
Reference in New Issue
Block a user