Commit 68be56d2 authored by Robert Lubos's avatar Robert Lubos Committed by Anas Nashif
Browse files

tests: net: tcp: Fix server tests



Fixing the bug with shadowed ret variable (and hence not returning
timeout error) reveled another bug in TCP server tests. Here, the
listening context was incorrectly used to receive new data, and since it
never arrived, the function timed out.

This commits fixes that issue, and limits the retransmission timeout to
ensure that Nagle's algorithm impact does not affect test timings.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent cc77f274
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_IF_MAX_IPV4_COUNT=2
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_TCP_CHECKSUM=n
CONFIG_NET_TCP_RANDOMIZED_RTO=n
CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT=100

CONFIG_NET_IPV6_ND=n
CONFIG_NET_IPV6_DAD=n
+3 −3
Original line number Diff line number Diff line
@@ -794,7 +794,7 @@ ZTEST(net_tcp, test_server_ipv4)
	/* Trigger the peer to send DATA  */
	k_work_reschedule(&test_server, K_NO_WAIT);

	ret = net_context_recv(ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	ret = net_context_recv(accepted_ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	if (ret < 0) {
		zassert_true(false, "Failed to recv data from peer");
	}
@@ -863,7 +863,7 @@ ZTEST(net_tcp, test_server_with_options_ipv4)
	/* Trigger the peer to send DATA  */
	k_work_reschedule(&test_server, K_NO_WAIT);

	ret = net_context_recv(ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	ret = net_context_recv(accepted_ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	if (ret < 0) {
		zassert_true(false, "Failed to recv data from peer");
	}
@@ -932,7 +932,7 @@ ZTEST(net_tcp, test_server_ipv6)
	/* Trigger the peer to send DATA  */
	k_work_reschedule(&test_server, K_NO_WAIT);

	ret = net_context_recv(ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	ret = net_context_recv(accepted_ctx, test_tcp_recv_cb, K_MSEC(200), NULL);
	if (ret < 0) {
		zassert_true(false, "Failed to recv data from peer");
	}