Breakpoints are hit multiple times or skipped sometimes (tests)
This commit is contained in:
parent
d6920d96d6
commit
a353735715
@ -626,3 +626,39 @@ func TestGetG(t *testing.T) {
|
||||
testGSupportFunc("cgo", t, p, fixture)
|
||||
})
|
||||
}
|
||||
|
||||
func TestContinueMulti(t *testing.T) {
|
||||
withTestProcess("integrationprog", t, func(p *Process, fixture protest.Fixture) {
|
||||
bp1, err := p.SetBreakpointByLocation("main.main")
|
||||
assertNoError(err, t, "BreakByLocation()")
|
||||
|
||||
bp2, err := p.SetBreakpointByLocation("main.sayhi")
|
||||
assertNoError(err, t, "BreakByLocation()")
|
||||
|
||||
mainCount := 0
|
||||
sayhiCount := 0
|
||||
for {
|
||||
err := p.Continue()
|
||||
if p.exited {
|
||||
break
|
||||
}
|
||||
assertNoError(err, t, "Continue()")
|
||||
|
||||
if p.CurrentBreakpoint().ID == bp1.ID {
|
||||
mainCount++
|
||||
}
|
||||
|
||||
if p.CurrentBreakpoint().ID == bp2.ID {
|
||||
sayhiCount++
|
||||
}
|
||||
}
|
||||
|
||||
if mainCount != 1 {
|
||||
t.Fatalf("Main breakpoint hit wrong number of times: %d\n", mainCount)
|
||||
}
|
||||
|
||||
if sayhiCount != 3 {
|
||||
t.Fatalf("Sayhi breakpoint hit wrong number of times: %d\n", sayhiCount)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -486,3 +486,46 @@ func TestClientServer_traceContinue(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientServer_traceContinue2(t *testing.T) {
|
||||
withTestClient("integrationprog", t, func(c service.Client) {
|
||||
bp1, err := c.CreateBreakpoint(&api.Breakpoint{FunctionName: "main.main", Tracepoint: true})
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v\n", err)
|
||||
}
|
||||
bp2, err := c.CreateBreakpoint(&api.Breakpoint{FunctionName: "main.sayhi", Tracepoint: true})
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v\n", err)
|
||||
}
|
||||
countMain := 0
|
||||
countSayhi := 0
|
||||
contChan := c.Continue()
|
||||
for state := range contChan {
|
||||
if state.Breakpoint != nil {
|
||||
switch state.Breakpoint.ID {
|
||||
case bp1.ID:
|
||||
countMain++
|
||||
case bp2.ID:
|
||||
countSayhi++
|
||||
}
|
||||
|
||||
t.Logf("%v", state)
|
||||
}
|
||||
if state.Exited {
|
||||
continue
|
||||
}
|
||||
if state.Err != nil {
|
||||
t.Fatalf("Unexpected error during continue: %v\n", state.Err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if countMain != 1 {
|
||||
t.Fatalf("Wrong number of continues (main.main) hit: %d\n", countMain)
|
||||
}
|
||||
|
||||
if countSayhi != 3 {
|
||||
t.Fatalf("Wrong number of continues (main.sayhi) hit: %d\n", countSayhi)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user