提交 f2581e60 编写于 作者: A aarzilli

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.
上级 92faa95b
......@@ -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()")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册