Skip to content

Commit 68be56d

Browse files
rlubosnashif
authored andcommitted
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: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent cc77f27 commit 68be56d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/net/tcp/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
2727
CONFIG_NET_IF_MAX_IPV4_COUNT=2
2828
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
2929
CONFIG_NET_TCP_CHECKSUM=n
30+
CONFIG_NET_TCP_RANDOMIZED_RTO=n
31+
CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT=100
3032

3133
CONFIG_NET_IPV6_ND=n
3234
CONFIG_NET_IPV6_DAD=n

tests/net/tcp/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ ZTEST(net_tcp, test_server_ipv4)
794794
/* Trigger the peer to send DATA */
795795
k_work_reschedule(&test_server, K_NO_WAIT);
796796

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

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

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

0 commit comments

Comments
 (0)