mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
vsock: add handshake regression test
This patch has been cherry-picked from the Firecracker tree. The reference commit is 6dbe8e021a64ba3742081741a7538cdfd93a102e. Signed-off-by: Gabriel Ionescu <gbi@amazon.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
parent
6ab4e247e6
commit
bb3cf7c30c
@ -764,6 +764,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> VsockConnection<S>
|
||||
where
|
||||
S: Read + Write + AsRawFd,
|
||||
{
|
||||
/// Get the fwd_cnt value from the connection.
|
||||
pub(crate) fn fwd_cnt(&self) -> Wrapping<u32> {
|
||||
self.fwd_cnt
|
||||
}
|
||||
}
|
||||
|
||||
fn init_pkt(pkt: &mut VsockPacket, op: u16, len: u32) -> &mut VsockPacket {
|
||||
for b in pkt.hdr_mut() {
|
||||
*b = 0;
|
||||
|
@ -1356,4 +1356,26 @@ mod tests {
|
||||
|
||||
assert!(!ctx.muxer.has_pending_rx());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_regression_handshake() {
|
||||
// Address one of the issues found while fixing the following issue:
|
||||
// https://github.com/firecracker-microvm/firecracker/issues/1751
|
||||
// This test checks that the handshake message is not accounted for
|
||||
let mut ctx = MuxerTestContext::new("regression_handshake");
|
||||
let peer_port = 1025;
|
||||
|
||||
// Create a local connection.
|
||||
let (_, local_port) = ctx.local_connect(peer_port);
|
||||
|
||||
// Get the connection from the connection map.
|
||||
let key = ConnMapKey {
|
||||
local_port,
|
||||
peer_port,
|
||||
};
|
||||
let conn = ctx.muxer.conn_map.get_mut(&key).unwrap();
|
||||
|
||||
// Check that fwd_cnt is 0 - "OK ..." was not accounted for.
|
||||
assert_eq!(conn.fwd_cnt().0, 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user