mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-26 20:01:13 +08:00
Fix Race Condition in TestXfrmMonitorExpire
This commit is contained in:

committed by
Alessandro Boch

parent
e37f4b431a
commit
48a75e0e38
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user