Skip to content

Commit 4a4a260

Browse files
committed
Rewrite test_buffer_wraparound_tx() by manually prefilling the buffer.
This is still testing the same case which would be masked away by the upcoming contiguous space optimization (which is important for PacketBuffers and still helpful to TcpSockets).
1 parent b2e2a64 commit 4a4a260

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/socket/tcp.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,33 +3656,25 @@ mod test {
36563656
#[test]
36573657
fn test_buffer_wraparound_tx() {
36583658
let mut s = socket_established();
3659-
s.tx_buffer = SocketBuffer::new(vec![0; 6]);
3660-
assert_eq!(s.send_slice(b"abc"), Ok(3));
3659+
s.tx_buffer = SocketBuffer::new(vec![b'.'; 9]);
3660+
assert_eq!(s.tx_buffer.enqueue_many(6).len(), 6);
3661+
assert_eq!(s.tx_buffer.dequeue_many(3).len(), 3);
3662+
assert_eq!(s.tx_buffer.len(), 3);
3663+
3664+
// "abcdef" not contiguous in tx buffer
3665+
assert_eq!(s.send_slice(b"abcdef"), Ok(6));
36613666
recv!(s, Ok(TcpRepr {
36623667
seq_number: LOCAL_SEQ + 1,
36633668
ack_number: Some(REMOTE_SEQ + 1),
3664-
payload: &b"abc"[..],
3669+
payload: &b"...abc"[..],
36653670
..RECV_TEMPL
36663671
}));
3667-
send!(s, TcpRepr {
3668-
seq_number: REMOTE_SEQ + 1,
3669-
ack_number: Some(LOCAL_SEQ + 1 + 3),
3670-
..SEND_TEMPL
3671-
});
3672-
assert_eq!(s.send_slice(b"defghi"), Ok(6));
36733672
recv!(s, Ok(TcpRepr {
3674-
seq_number: LOCAL_SEQ + 1 + 3,
3673+
seq_number: LOCAL_SEQ + 1 + 6,
36753674
ack_number: Some(REMOTE_SEQ + 1),
36763675
payload: &b"def"[..],
36773676
..RECV_TEMPL
36783677
}));
3679-
// "defghi" not contiguous in tx buffer
3680-
recv!(s, Ok(TcpRepr {
3681-
seq_number: LOCAL_SEQ + 1 + 3 + 3,
3682-
ack_number: Some(REMOTE_SEQ + 1),
3683-
payload: &b"ghi"[..],
3684-
..RECV_TEMPL
3685-
}));
36863678
}
36873679

36883680
// =========================================================================================//

0 commit comments

Comments
 (0)