aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/vsock/vsock_test.c
diff options
context:
space:
mode:
authorStefano Garzarella <sgarzare@redhat.com>2019-12-18 19:07:05 +0100
committerDavid S. Miller <davem@davemloft.net>2019-12-20 21:09:21 -0800
commit770ce0078cbf97262e86c9cc210684ce3b4266f5 (patch)
tree85e0eea8ad26fec89991c34184144bd5ae8bbf73 /tools/testing/vsock/vsock_test.c
parentVSOCK: add AF_VSOCK test cases (diff)
downloadlinux-dev-770ce0078cbf97262e86c9cc210684ce3b4266f5.tar.xz
linux-dev-770ce0078cbf97262e86c9cc210684ce3b4266f5.zip
vsock_test: wait for the remote to close the connection
Before check if a send returns -EPIPE, we need to make sure the connection is closed. To do that, we use epoll API to wait EPOLLRDHUP or EPOLLHUP events on the socket. Reported-by: Jorgen Hansen <jhansen@vmware.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--tools/testing/vsock/vsock_test.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index fae8ddc3ef72..629d7ce58202 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -66,7 +66,6 @@ static void test_stream_client_close_client(const struct test_opts *opts)
send_byte(fd, 1, 0);
close(fd);
- control_writeln("CLOSED");
}
static void test_stream_client_close_server(const struct test_opts *opts)
@@ -79,7 +78,10 @@ static void test_stream_client_close_server(const struct test_opts *opts)
exit(EXIT_FAILURE);
}
- control_expectln("CLOSED");
+ /* Wait for the remote to close the connection, before check
+ * -EPIPE error on send.
+ */
+ vsock_wait_remote_close(fd);
send_byte(fd, -EPIPE, 0);
recv_byte(fd, 1, 0);
@@ -97,7 +99,10 @@ static void test_stream_server_close_client(const struct test_opts *opts)
exit(EXIT_FAILURE);
}
- control_expectln("CLOSED");
+ /* Wait for the remote to close the connection, before check
+ * -EPIPE error on send.
+ */
+ vsock_wait_remote_close(fd);
send_byte(fd, -EPIPE, 0);
recv_byte(fd, 1, 0);
@@ -117,7 +122,6 @@ static void test_stream_server_close_server(const struct test_opts *opts)
send_byte(fd, 1, 0);
close(fd);
- control_writeln("CLOSED");
}
/* With the standard socket sizes, VMCI is able to support about 100