@@ -699,7 +699,85 @@ static void test_stream_poll_rcvlowat_client(const struct test_opts *opts)
close(fd);
}
+static void test_stall_client(const struct test_opts *opts)
+{
+ int fd;
+ unsigned long lowat_val = 128*1024;
+ size_t data_size = 64 * 1024;
+ void *data;
+
+
+ fd = vsock_stream_connect(opts->peer_cid, 1234);
+ assert(fd != -1);
+
+ assert(!setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT,
+ &lowat_val, sizeof(lowat_val)));
+
+ data = malloc(data_size);
+ assert(data);
+
+ /* Wait for tx to send data. */
+ sleep(3);
+
+ while (1) {
+ struct pollfd fds = {0};
+
+ fds.fd = fd;
+ fds.events = POLLIN | POLLRDNORM | POLLERR | POLLRDHUP | POLLHUP;
+
+ /* Try to wait for 1 sec. */
+ printf("[RX] ENTER POLL\n");
+ assert(poll(&fds, 1, -1) >= 0);
+ printf("[RX] LEAVE POLL\n");
+
+ if (fds.revents & (POLLIN | POLLRDNORM)) {
+ read(fd, data, data_size);
+ }
+
+ if (fds.revents & POLLERR) {
+ printf("[RX] POLL ERR\n");
+ break;
+ }
+
+ if (fds.revents & (POLLRDHUP | POLLHUP)) {
+ printf("[RX] POLL DONE\n");
+ break;
+ }
+ }
+
+ close(fd);
+ exit(0);
+}
+
+static void test_stall_server(const struct test_opts *opts)
+{
+ size_t data_size = (256 * 1024) + 1;
+ void *data;
+ int fd;
+
+ fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
+ assert(fd != -1);
+
+ data = malloc(data_size);
+ assert(data);
+
+ printf("[TX] ENTER WRITE\n");
+ assert(write(fd, data, data_size) == data_size);
+
+ /* Never get here without kernel patch. */
+ printf("[TX] LEAVE WRITE\n");
+
+ close(fd);
+ exit(0);
+}
+
+
static struct test_case test_cases[] = {
+ {
+ .name = "Test stall",
+ .run_client = test_stall_client,
+ .run_server = test_stall_server,
+ },
{
.name = "SOCK_STREAM connection reset",
.run_client = test_stream_connection_reset,
This is not for merge, just demo. Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> --- tools/testing/vsock/vsock_test.c | 78 ++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)