提交 df2fb5f3 编写于 作者: D Dan Mace

Make TestHalt deterministic

Eliminate a race condition in TestHalt where the RequestManualStop
call can precede the Continue call, causing the test to sporadically
fail.
上级 92c1ae3a
......@@ -8,7 +8,6 @@ import (
"path/filepath"
"runtime"
"testing"
"time"
)
func withTestProcess(name string, t *testing.T, fn func(p *DebuggedProcess)) {
......@@ -91,10 +90,14 @@ func TestExit(t *testing.T) {
func TestHalt(t *testing.T) {
withTestProcess("../_fixtures/testprog", t, func(p *DebuggedProcess) {
go func() {
time.Sleep(10 * time.Millisecond)
err := p.RequestManualStop()
if err != nil {
t.Fatal(err)
for {
if p.Running() {
err := p.RequestManualStop()
if err != nil {
t.Fatal(err)
}
return
}
}
}()
err := p.Continue()
......@@ -388,7 +391,7 @@ func TestSwitchThread(t *testing.T) {
}
var nt int
ct := p.CurrentThread.Id
for tid, _ := range p.Threads {
for tid := range p.Threads {
if tid != ct {
nt = tid
break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册