diff mbox series

[RFC,v2,5/5] vsock_test: update message bounds test for MSG_EOR

Message ID 20210810114119.1215014-1-arseny.krasnov@kaspersky.com (mailing list archive)
State New, archived
Headers show
Series virtio/vsock: introduce MSG_EOR flag for SEQPACKET | expand

Commit Message

Arseny Krasnov Aug. 10, 2021, 11:41 a.m. UTC
Set 'MSG_EOR' in one of message sent, check that 'MSG_EOR'
is visible in corresponding message at receiver.

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
---
 tools/testing/vsock/vsock_test.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Stefano Garzarella Aug. 11, 2021, 9:12 a.m. UTC | #1
On Tue, Aug 10, 2021 at 02:41:16PM +0300, Arseny Krasnov wrote:
>Set 'MSG_EOR' in one of message sent, check that 'MSG_EOR'
>is visible in corresponding message at receiver.
>
>Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
>---
> tools/testing/vsock/vsock_test.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>index 67766bfe176f..2a3638c0a008 100644
>--- a/tools/testing/vsock/vsock_test.c
>+++ b/tools/testing/vsock/vsock_test.c
>@@ -282,6 +282,7 @@ static void test_stream_msg_peek_server(const struct test_opts *opts)
> }
>
> #define MESSAGES_CNT 7
>+#define MSG_EOR_IDX (MESSAGES_CNT / 2)
> static void test_seqpacket_msg_bounds_client(const struct test_opts *opts)
> {
> 	int fd;
>@@ -294,7 +295,7 @@ static void test_seqpacket_msg_bounds_client(const struct test_opts *opts)
>
> 	/* Send several messages, one with MSG_EOR flag */
> 	for (int i = 0; i < MESSAGES_CNT; i++)
>-		send_byte(fd, 1, 0);
>+		send_byte(fd, 1, (i == MSG_EOR_IDX) ? MSG_EOR : 0);
>
> 	control_writeln("SENDDONE");
> 	close(fd);
>@@ -324,6 +325,11 @@ static void test_seqpacket_msg_bounds_server(const struct test_opts *opts)
> 			perror("message bound violated");
> 			exit(EXIT_FAILURE);
> 		}
>+
>+		if ((i == MSG_EOR_IDX) ^ !!(msg.msg_flags & MSG_EOR)) {
>+			perror("MSG_EOR");
>+			exit(EXIT_FAILURE);
>+		}
> 	}
>
> 	close(fd);
>-- 
>2.25.1
>

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
diff mbox series

Patch

diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index 67766bfe176f..2a3638c0a008 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -282,6 +282,7 @@  static void test_stream_msg_peek_server(const struct test_opts *opts)
 }
 
 #define MESSAGES_CNT 7
+#define MSG_EOR_IDX (MESSAGES_CNT / 2)
 static void test_seqpacket_msg_bounds_client(const struct test_opts *opts)
 {
 	int fd;
@@ -294,7 +295,7 @@  static void test_seqpacket_msg_bounds_client(const struct test_opts *opts)
 
 	/* Send several messages, one with MSG_EOR flag */
 	for (int i = 0; i < MESSAGES_CNT; i++)
-		send_byte(fd, 1, 0);
+		send_byte(fd, 1, (i == MSG_EOR_IDX) ? MSG_EOR : 0);
 
 	control_writeln("SENDDONE");
 	close(fd);
@@ -324,6 +325,11 @@  static void test_seqpacket_msg_bounds_server(const struct test_opts *opts)
 			perror("message bound violated");
 			exit(EXIT_FAILURE);
 		}
+
+		if ((i == MSG_EOR_IDX) ^ !!(msg.msg_flags & MSG_EOR)) {
+			perror("MSG_EOR");
+			exit(EXIT_FAILURE);
+		}
 	}
 
 	close(fd);