Message ID | 20230915121452.87192-6-sgarzare@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | bc7bea452d322b785d960fd20795babff664975c |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | vsock/test: add recv_buf()/send_buf() utility functions and some improvements | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 9 this patch: 9 |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/build_clang | success | Errors and warnings before: 9 this patch: 9 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 9 this patch: 9 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 31 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
Small remark on 'Subject' - this is not MSG_PEEK test, it is test for sk_buff merging. Considering that: Reviewed-by: Arseniy Krasnov <avkrasnov@salutedevices.com> Thanks, Arseniy On 15.09.2023 15:14, Stefano Garzarella wrote: > 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> > --- > tools/testing/vsock/vsock_test.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c > index b18acbaf92e2..5743dcae2350 100644 > --- a/tools/testing/vsock/vsock_test.c > +++ b/tools/testing/vsock/vsock_test.c > @@ -1002,6 +1002,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; > > @@ -1014,14 +1015,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");
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index b18acbaf92e2..5743dcae2350 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -1002,6 +1002,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; @@ -1014,14 +1015,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");
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> --- tools/testing/vsock/vsock_test.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)