Fix Race Condition in TestXfrmMonitorExpire

This commit is contained in:
Matt Ellison
2019-01-03 17:31:03 -05:00
committed by Alessandro Boch
parent e37f4b431a
commit 48a75e0e38

View File

@@ -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)
}
}