Lines Matching +full:poll +full:- +full:timeout +full:- +full:ms
4 * SPDX-License-Identifier: Apache-2.0
38 int c_sock = -1, s_sock = -1, new_sock = -1;
132 for (int i = 0; i < msg->msg_iovlen; i++) { in test_sendmsg()
133 struct iovec *vec = msg->msg_iov + i; in test_sendmsg()
135 total_len += vec->iov_len; in test_sendmsg()
170 c_sock = -1; in test_sockets_close()
175 s_sock = -1; in test_sockets_close()
180 new_sock = -1; in test_sockets_close()
269 if (test_data->retries > 0) { in test_msg_waitall_tx_work_handler()
270 test_send(test_data->sock, test_data->data + test_data->offset, 1, 0); in test_msg_waitall_tx_work_handler()
271 test_data->offset++; in test_msg_waitall_tx_work_handler()
272 test_data->retries--; in test_msg_waitall_tx_work_handler()
273 test_work_reschedule(&test_data->tx_work, K_MSEC(10)); in test_msg_waitall_tx_work_handler()
289 test_connect(data->sock, data->addr, data->addr->sa_family == AF_INET ? in client_connect_work_handler()
300 test_connect(data->sock, data->addr, data->addr->sa_family == AF_INET ? in dtls_client_connect_send_work_handler()
302 test_send(data->sock, &tx_buf, sizeof(tx_buf), 0); in dtls_client_connect_send_work_handler()
337 /* Helper work for the connect operation - need to handle client/server in test_prepare_tls_connection()
396 * unblock poll(). in test_prepare_dtls_connection()
401 zassert_equal(ret, 1, "poll() did not report data ready"); in test_prepare_dtls_connection()
416 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
424 /* Regular MSG_WAITALL - make sure recv returns only after in ZTEST()
440 /* MSG_WAITALL + SO_RCVTIMEO - make sure recv returns the amount of data in ZTEST()
449 test_data.retries = sizeof(rx_buf) - 1; in ZTEST()
455 ret = zsock_recv(new_sock, rx_buf, sizeof(rx_buf) - 1, ZSOCK_MSG_WAITALL); in ZTEST()
456 zassert_equal(ret, sizeof(rx_buf) - 1, "Invalid length received"); in ZTEST()
457 zassert_mem_equal(rx_buf, TEST_STR_SMALL, sizeof(rx_buf) - 1, in ZTEST()
472 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
480 /* Regular MSG_WAITALL - make sure recv returns only after in ZTEST()
496 /* MSG_WAITALL + SO_RCVTIMEO - make sure recv returns the amount of data in ZTEST()
505 test_data.retries = sizeof(rx_buf) - 1; in ZTEST()
511 ret = zsock_recv(new_sock, rx_buf, sizeof(rx_buf) - 1, ZSOCK_MSG_WAITALL); in ZTEST()
512 zassert_equal(ret, sizeof(rx_buf) - 1, "Invalid length received"); in ZTEST()
513 zassert_mem_equal(rx_buf, TEST_STR_SMALL, sizeof(rx_buf) - 1, in ZTEST()
535 test_send(test_data->sock, test_data->data, test_data->datalen, 0); in send_work_handler()
541 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in test_msg_trunc()
544 .datalen = sizeof(TEST_STR_SMALL) - 1 in test_msg_trunc()
557 zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "MSG_TRUNC flag failed"); in test_msg_trunc()
563 zassert_equal(rv, -1, "consecutive recv should've failed"); in test_msg_trunc()
598 test_sendmsg(test_data->sock, test_data->msg, 0); in test_sendmsg_tx_work_handler()
604 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in test_dtls_sendmsg_no_buf()
609 .iov_len = sizeof(TEST_STR_SMALL) - 1, in test_dtls_sendmsg_no_buf()
632 zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "recv failed"); in test_dtls_sendmsg_no_buf()
633 zassert_mem_equal(rx_buf, TEST_STR_SMALL, sizeof(TEST_STR_SMALL) - 1, "invalid rx data"); in test_dtls_sendmsg_no_buf()
637 /* sendmsg() with single non-empty fragment */ in test_dtls_sendmsg_no_buf()
646 zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "recv failed"); in test_dtls_sendmsg_no_buf()
647 zassert_mem_equal(rx_buf, TEST_STR_SMALL, sizeof(TEST_STR_SMALL) - 1, "invalid rx data"); in test_dtls_sendmsg_no_buf()
651 /* sendmsg() with multiple non-empty fragments */ in test_dtls_sendmsg_no_buf()
654 iov[0].iov_len = sizeof(TEST_STR_SMALL) - 1; in test_dtls_sendmsg_no_buf()
657 zassert_equal(rv, -1, "sendmsg succeeded"); in test_dtls_sendmsg_no_buf()
693 .iov_len = sizeof(TEST_STR_SMALL) - 1, in test_dtls_sendmsg()
697 .iov_len = sizeof(TEST_STR_SMALL) - 1, in test_dtls_sendmsg()
720 zassert_equal(rv, sizeof(expected_str) - 1, "recv failed"); in test_dtls_sendmsg()
721 zassert_mem_equal(buf, expected_str, sizeof(expected_str) - 1, "invalid rx data"); in test_dtls_sendmsg()
730 iov[2].iov_len = sizeof(TEST_STR_SMALL) - 1; in test_dtls_sendmsg()
738 zassert_equal(rv, sizeof(expected_str) - 1, "recv failed"); in test_dtls_sendmsg()
739 zassert_mem_equal(buf, expected_str, sizeof(expected_str) - 1, "invalid rx data"); in test_dtls_sendmsg()
777 zassert_equal(rv, -1, "sendmsg succeeded"); in test_dtls_sendmsg()
814 zsock_close(*data->fd); in close_work()
815 *data->fd = -1; in close_work()
827 test_config_psk(s_sock, -1); in ZTEST()
841 zassert_equal(new_sock, -1, "accept did not return error"); in ZTEST()
862 zassert_equal(ret, -1, "recv did not return error"); in ZTEST()
880 test_config_psk(-1, c_sock); in ZTEST()
891 -1, "connect succeed"); in ZTEST()
909 test_config_psk(-1, c_sock); in ZTEST()
918 -1, "connect succeed"); in ZTEST()
938 test_accept(data->sock, &new_sock, NULL, 0); in fake_tcp_server_work()
940 if (!data->reply) { in fake_tcp_server_work()
962 new_sock = -1; in fake_tcp_server_work()
984 s_data->sock = *s_sock; in test_prepare_fake_tcp_server()
985 s_data->reply = reply; in test_prepare_fake_tcp_server()
986 k_work_init_delayable(&s_data->work, fake_tcp_server_work); in test_prepare_fake_tcp_server()
987 test_work_reschedule(&s_data->work, K_NO_WAIT); in test_prepare_fake_tcp_server()
998 test_config_psk(-1, c_sock); in ZTEST()
1004 -1, "connect succeed"); in ZTEST()
1009 c_sock = -1; in ZTEST()
1025 test_config_psk(-1, c_sock); in ZTEST()
1031 -1, "connect succeed"); in ZTEST()
1049 test_config_psk(s_sock, -1); in ZTEST()
1056 zassert_true(k_uptime_get_32() - timestamp <= 100, ""); in ZTEST()
1057 zassert_equal(new_sock, -1, "accept did not return error"); in ZTEST()
1073 test_config_psk(s_sock, -1); in ZTEST()
1082 zassert_equal(new_sock, -1, "accept did not return error"); in ZTEST()
1092 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
1098 zassert_equal(ret, -1, "recv()) should've failed"); in ZTEST()
1104 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1120 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1131 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
1134 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1145 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1158 c_sock = -1; in ZTEST()
1173 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
1174 int buf_optval = TLS_RECORD_OVERHEAD + sizeof(TEST_STR_SMALL) - 1; in ZTEST()
1187 /* Wait for ACK (empty window, min. 100 ms due to silly window in ZTEST()
1195 zassert_equal(ret, -1, "send() should've failed"); in ZTEST()
1201 zassert_equal(ret, -1, "send() should've failed"); in ZTEST()
1222 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1245 while (off < test_data->datalen) { in recv_work_handler()
1246 size_t recvlen = MIN(sizeof(rx_buf), test_data->datalen - off); in recv_work_handler()
1248 ret = zsock_recv(test_data->sock, rx_buf, recvlen, 0); in recv_work_handler()
1250 zassert_mem_equal(rx_buf, test_data->data + off, ret, in recv_work_handler()
1254 zassert_true(off <= test_data->datalen, in recv_work_handler()
1262 int buf_optval = TLS_RECORD_OVERHEAD + sizeof(TEST_STR_SMALL) - 1; in ZTEST()
1263 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
1266 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1280 /* Wait for ACK (empty window, min. 100 ms due to silly window in ZTEST()
1300 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1310 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1] = { 0 }; in ZTEST()
1316 new_sock = -1; in ZTEST()
1323 zassert_equal(ret, -1, "send() should've failed"); in ZTEST()
1328 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1338 new_sock = -1; in ZTEST()
1349 zassert_equal(ret, -1, "send() should've failed"); in ZTEST()
1359 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in ZTEST()
1367 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1379 time_diff = k_uptime_get_32() - start_time; in ZTEST()
1381 zassert_equal(ret, -1, "recv() should've failed"); in ZTEST()
1383 zassert_true(time_diff >= 500, "Expected timeout after 500ms but " in ZTEST()
1390 /* recv() shall return as soon as it gets data, regardless of timeout. */ in ZTEST()
1392 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1402 int buf_optval = TLS_RECORD_OVERHEAD + sizeof(TEST_STR_SMALL) - 1; in ZTEST()
1410 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1425 ret = zsock_send(c_sock, TEST_STR_SMALL, sizeof(TEST_STR_SMALL) - 1, 0); in ZTEST()
1426 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "send() failed"); in ZTEST()
1433 ret = zsock_send(c_sock, TEST_STR_SMALL, sizeof(TEST_STR_SMALL) - 1, 0); in ZTEST()
1434 time_diff = k_uptime_get_32() - start_time; in ZTEST()
1436 zassert_equal(ret, -1, "send() should've failed"); in ZTEST()
1438 zassert_true(time_diff >= 500, "Expected timeout after 500ms but " in ZTEST()
1481 zsock_shutdown(data->sock, data->how); in shutdown_work()
1507 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in ZTEST()
1510 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1514 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1532 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1537 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1547 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in ZTEST()
1557 zassert_equal(ret, 0, "Unexpected poll() event"); in ZTEST()
1559 ret = zsock_send(c_sock, TEST_STR_SMALL, sizeof(TEST_STR_SMALL) - 1, 0); in ZTEST()
1563 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1568 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1578 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in ZTEST()
1581 .datalen = sizeof(TEST_STR_SMALL) - 1 in ZTEST()
1592 zassert_equal(ret, 0, "Unexpected poll() event"); in ZTEST()
1599 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1604 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1615 int buf_optval = TLS_RECORD_OVERHEAD + sizeof(TEST_STR_SMALL) - 1; in ZTEST()
1616 uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; in ZTEST()
1626 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1638 /* Wait for ACK (empty window, min. 100 ms due to silly window in ZTEST()
1643 /* poll() shouldn't report POLLOUT now */ in ZTEST()
1645 zassert_equal(ret, 0, "Unexpected poll() event"); in ZTEST()
1649 zassert_equal(ret, sizeof(TEST_STR_SMALL) - 1, "recv() failed"); in ZTEST()
1653 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1673 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1694 c_sock = -1; in ZTEST()
1697 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1722 c_sock = -1; in ZTEST()
1725 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1730 zassert_equal(ret, -1, "recv() should report EAGAIN"); in ZTEST()
1761 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1770 zassert_equal(ret, -1, "recv() did not report error"); in ZTEST()
1798 zassert_equal(ret, 1, "poll() should've report event"); in ZTEST()
1808 zassert_equal(ret, -1, "recv() did not report error"); in ZTEST()