From b3f39226ececf3ad79b30d3e311eb8b1ae45a2f7 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 1 Apr 2020 16:01:38 +0300 Subject: [PATCH] net: tests: Fix timeout passed to k_sleep() Use the appropriate K_SECONDS() or K_MSEC() macros to pass a timeout to k_sleep() and other kernel APIs. Signed-off-by: Johan Hedberg --- tests/net/context/src/main.c | 8 ++++---- tests/net/ipv6/src/main.c | 4 ++-- tests/net/mld/src/main.c | 14 +++++++------- tests/net/tcp/src/main.c | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/net/context/src/main.c b/tests/net/context/src/main.c index 78d0d1c708c..a21d74bfe81 100644 --- a/tests/net/context/src/main.c +++ b/tests/net/context/src/main.c @@ -728,7 +728,7 @@ static void net_ctx_recv_v6_timeout(void) tid = start_timeout_v6_thread(WAIT_TIME_LONG); k_sem_reset(&wait_data); - k_sem_take(&wait_data, WAIT_TIME_LONG * 2U); + k_sem_take(&wait_data, K_MSEC(WAIT_TIME_LONG * 2)); net_ctx_send_v6(); @@ -756,7 +756,7 @@ static void net_ctx_recv_v4_timeout(void) tid = start_timeout_v4_thread(WAIT_TIME_LONG); k_sem_reset(&wait_data); - k_sem_take(&wait_data, WAIT_TIME_LONG * 2U); + k_sem_take(&wait_data, K_MSEC(WAIT_TIME_LONG * 2)); net_ctx_send_v4(); @@ -784,7 +784,7 @@ static void net_ctx_recv_v6_timeout_forever(void) tid = start_timeout_v6_thread(K_FOREVER); /* Wait a bit so that we see if recv waited or not */ - k_sleep(WAIT_TIME); + k_sleep(K_MSEC(WAIT_TIME)); net_ctx_send_v6(); @@ -810,7 +810,7 @@ static void net_ctx_recv_v4_timeout_forever(void) tid = start_timeout_v4_thread(K_FOREVER); /* Wait a bit so that we see if recv waited or not */ - k_sleep(WAIT_TIME); + k_sleep(K_MSEC(WAIT_TIME)); net_ctx_send_v4(); diff --git a/tests/net/ipv6/src/main.c b/tests/net/ipv6/src/main.c index b5ba0c983f9..0fc0acf3ace 100644 --- a/tests/net/ipv6/src/main.c +++ b/tests/net/ipv6/src/main.c @@ -538,7 +538,7 @@ static void test_prefix_timeout(void) net_if_ipv6_prefix_set_lf(prefix, false); net_if_ipv6_prefix_set_timer(prefix, lifetime); - k_sleep((lifetime * 2U) * MSEC_PER_SEC); + k_sleep(K_SECONDS(lifetime * 2U)); prefix = net_if_ipv6_prefix_lookup(net_if_get_default(), &addr, len); @@ -1338,7 +1338,7 @@ static void test_dst_iface_scope_mcast_send(void) "Interface local scope multicast packet was dropped (%d)", ret); - k_sem_take(&wait_data, WAIT_TIME); + k_sem_take(&wait_data, K_MSEC(WAIT_TIME)); zassert_true(recv_cb_called, "No data received on time, " "IPv6 recv test failed"); diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index 43589960b59..0a5abd3ee78 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -252,7 +252,7 @@ static void catch_join_group(void) join_group(); - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting join event"); } @@ -269,7 +269,7 @@ static void catch_leave_group(void) leave_group(); - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting leave event"); } @@ -288,7 +288,7 @@ static void verify_join_group(void) join_group(); - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting join event"); } @@ -305,7 +305,7 @@ static void verify_leave_group(void) leave_group(); - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting leave event"); } @@ -413,7 +413,7 @@ static void catch_query(void) k_yield(); - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting query event"); } @@ -440,7 +440,7 @@ static void verify_send_report(void) k_yield(); /* Did we send a report? */ - if (k_sem_take(&wait_data, WAIT_TIME)) { + if (k_sem_take(&wait_data, K_MSEC(WAIT_TIME))) { zassert_true(0, "Timeout while waiting report"); } @@ -461,7 +461,7 @@ static void test_allnodes(void) net_ipv6_addr_create_ll_allnodes_mcast(&addr); /* Let the DAD succeed so that the multicast address will be there */ - k_sleep(DAD_TIMEOUT); + k_sleep(K_MSEC(DAD_TIMEOUT)); ifmaddr = net_if_ipv6_maddr_lookup(&addr, &iface); diff --git a/tests/net/tcp/src/main.c b/tests/net/tcp/src/main.c index df84bf4fa7e..c4c069d4761 100644 --- a/tests/net/tcp/src/main.c +++ b/tests/net/tcp/src/main.c @@ -1674,7 +1674,7 @@ static bool test_init_tcp_connect(void) return false; } - if (k_sem_take(&wait_in_accept, WAIT_TIME_LONG)) { + if (k_sem_take(&wait_in_accept, K_MSEC(WAIT_TIME_LONG))) { TC_ERROR("Timeout while waiting data back\n"); return false; } @@ -1696,7 +1696,7 @@ static bool test_init_tcp_connect(void) DBG("Waiting v6 connection\n"); - if (k_sem_take(&wait_connect, WAIT_TIME_LONG)) { + if (k_sem_take(&wait_connect, K_MSEC(WAIT_TIME_LONG))) { TC_ERROR("Timeout while waiting data back\n"); return false; } @@ -1716,7 +1716,7 @@ static bool test_init_tcp_connect(void) return false; } - k_sem_take(&wait_connect, WAIT_TIME); + k_sem_take(&wait_connect, K_MSEC(WAIT_TIME)); if (!connect_cb_called) { TC_ERROR("No IPv4 connect cb called on time, " "TCP connect test failed\n");