Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vsock_test: add SOCK_STREAM MSG_PEEK test

Test if the MSG_PEEK flags of recv(2) works as expected.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stefano Garzarella and committed by
David S. Miller
d6269a93 8d00b93f

+34
+34
tools/testing/vsock/vsock_test.c
··· 178 178 close(fds[i]); 179 179 } 180 180 181 + static void test_stream_msg_peek_client(const struct test_opts *opts) 182 + { 183 + int fd; 184 + 185 + fd = vsock_stream_connect(opts->peer_cid, 1234); 186 + if (fd < 0) { 187 + perror("connect"); 188 + exit(EXIT_FAILURE); 189 + } 190 + 191 + send_byte(fd, 1, 0); 192 + close(fd); 193 + } 194 + 195 + static void test_stream_msg_peek_server(const struct test_opts *opts) 196 + { 197 + int fd; 198 + 199 + fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL); 200 + if (fd < 0) { 201 + perror("accept"); 202 + exit(EXIT_FAILURE); 203 + } 204 + 205 + recv_byte(fd, 1, MSG_PEEK); 206 + recv_byte(fd, 1, 0); 207 + close(fd); 208 + } 209 + 181 210 static struct test_case test_cases[] = { 182 211 { 183 212 .name = "SOCK_STREAM connection reset", ··· 226 197 .name = "SOCK_STREAM multiple connections", 227 198 .run_client = test_stream_multiconn_client, 228 199 .run_server = test_stream_multiconn_server, 200 + }, 201 + { 202 + .name = "SOCK_STREAM MSG_PEEK", 203 + .run_client = test_stream_msg_peek_client, 204 + .run_server = test_stream_msg_peek_server, 229 205 }, 230 206 {}, 231 207 };