Skip to content

Commit

Permalink
Fix Race Condition in TestXfrmMonitorExpire
Browse files Browse the repository at this point in the history
  • Loading branch information
mmellison authored and aboch committed Jan 4, 2019
1 parent e37f4b4 commit 48a75e0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions xfrm_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,24 @@ func TestXfrmMonitorExpire(t *testing.T) {
t.Fatal(err)
}

hardFound := false
softFound := false

msg := (<-ch).(*XfrmMsgExpire)
if msg.XfrmState.Spi != state.Spi || msg.Hard {
t.Fatal("Received unexpected msg")
if msg.XfrmState.Spi != state.Spi {
t.Fatal("Received unexpected msg, spi does not match")
}
hardFound = msg.Hard || hardFound
softFound = !msg.Hard || softFound

msg = (<-ch).(*XfrmMsgExpire)
if msg.XfrmState.Spi != state.Spi || !msg.Hard {
t.Fatal("Received unexpected msg")
if msg.XfrmState.Spi != state.Spi {
t.Fatal("Received unexpected msg, spi does not match")
}
hardFound = msg.Hard || hardFound
softFound = !msg.Hard || softFound

if !hardFound || !softFound {
t.Fatal("Missing expire msg: hard found:", hardFound, "soft found:", softFound)
}
}

0 comments on commit 48a75e0

Please sign in to comment.