Skip to content

Commit

Permalink
vsock/test: track bytes in sk_buff merging test for SOCK_SEQPACKET
Browse files Browse the repository at this point in the history
The test was a bit complicated to read.
Added variables to keep track of the bytes read and to be read
in each step. Also some comments.

The test is unchanged.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stefano Garzarella authored and David S. Miller committed Sep 17, 2023
1 parent 2a8548a commit bc7bea4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tools/testing/vsock/vsock_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ static void test_stream_virtio_skb_merge_client(const struct test_opts *opts)

static void test_stream_virtio_skb_merge_server(const struct test_opts *opts)
{
size_t read = 0, to_read;
unsigned char buf[64];
int fd;

Expand All @@ -1015,14 +1016,21 @@ static void test_stream_virtio_skb_merge_server(const struct test_opts *opts)
control_expectln("SEND0");

/* Read skbuff partially. */
recv_buf(fd, buf, 2, 0, 2);
to_read = 2;
recv_buf(fd, buf + read, to_read, 0, to_read);
read += to_read;

control_writeln("REPLY0");
control_expectln("SEND1");

recv_buf(fd, buf + 2, 8, 0, 8);
/* Read the rest of both buffers */
to_read = strlen(HELLO_STR WORLD_STR) - read;
recv_buf(fd, buf + read, to_read, 0, to_read);
read += to_read;

recv_buf(fd, buf, sizeof(buf) - 8 - 2, MSG_DONTWAIT, -EAGAIN);
/* No more bytes should be there */
to_read = sizeof(buf) - read;
recv_buf(fd, buf + read, to_read, MSG_DONTWAIT, -EAGAIN);

if (memcmp(buf, HELLO_STR WORLD_STR, strlen(HELLO_STR WORLD_STR))) {
fprintf(stderr, "pattern mismatch\n");
Expand Down

0 comments on commit bc7bea4

Please sign in to comment.