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 <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2020-04-01 16:01:38 +03:00 committed by Johan Hedberg
commit b3f39226ec
4 changed files with 16 additions and 16 deletions

View file

@ -728,7 +728,7 @@ static void net_ctx_recv_v6_timeout(void)
tid = start_timeout_v6_thread(WAIT_TIME_LONG); tid = start_timeout_v6_thread(WAIT_TIME_LONG);
k_sem_reset(&wait_data); 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(); net_ctx_send_v6();
@ -756,7 +756,7 @@ static void net_ctx_recv_v4_timeout(void)
tid = start_timeout_v4_thread(WAIT_TIME_LONG); tid = start_timeout_v4_thread(WAIT_TIME_LONG);
k_sem_reset(&wait_data); 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(); net_ctx_send_v4();
@ -784,7 +784,7 @@ static void net_ctx_recv_v6_timeout_forever(void)
tid = start_timeout_v6_thread(K_FOREVER); tid = start_timeout_v6_thread(K_FOREVER);
/* Wait a bit so that we see if recv waited or not */ /* 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(); net_ctx_send_v6();
@ -810,7 +810,7 @@ static void net_ctx_recv_v4_timeout_forever(void)
tid = start_timeout_v4_thread(K_FOREVER); tid = start_timeout_v4_thread(K_FOREVER);
/* Wait a bit so that we see if recv waited or not */ /* 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(); net_ctx_send_v4();

View file

@ -538,7 +538,7 @@ static void test_prefix_timeout(void)
net_if_ipv6_prefix_set_lf(prefix, false); net_if_ipv6_prefix_set_lf(prefix, false);
net_if_ipv6_prefix_set_timer(prefix, lifetime); 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(), prefix = net_if_ipv6_prefix_lookup(net_if_get_default(),
&addr, len); &addr, len);
@ -1338,7 +1338,7 @@ static void test_dst_iface_scope_mcast_send(void)
"Interface local scope multicast packet was dropped (%d)", "Interface local scope multicast packet was dropped (%d)",
ret); 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, " zassert_true(recv_cb_called, "No data received on time, "
"IPv6 recv test failed"); "IPv6 recv test failed");

View file

@ -252,7 +252,7 @@ static void catch_join_group(void)
join_group(); 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"); zassert_true(0, "Timeout while waiting join event");
} }
@ -269,7 +269,7 @@ static void catch_leave_group(void)
leave_group(); 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"); zassert_true(0, "Timeout while waiting leave event");
} }
@ -288,7 +288,7 @@ static void verify_join_group(void)
join_group(); 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"); zassert_true(0, "Timeout while waiting join event");
} }
@ -305,7 +305,7 @@ static void verify_leave_group(void)
leave_group(); 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"); zassert_true(0, "Timeout while waiting leave event");
} }
@ -413,7 +413,7 @@ static void catch_query(void)
k_yield(); 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"); zassert_true(0, "Timeout while waiting query event");
} }
@ -440,7 +440,7 @@ static void verify_send_report(void)
k_yield(); k_yield();
/* Did we send a report? */ /* 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"); zassert_true(0, "Timeout while waiting report");
} }
@ -461,7 +461,7 @@ static void test_allnodes(void)
net_ipv6_addr_create_ll_allnodes_mcast(&addr); net_ipv6_addr_create_ll_allnodes_mcast(&addr);
/* Let the DAD succeed so that the multicast address will be there */ /* 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); ifmaddr = net_if_ipv6_maddr_lookup(&addr, &iface);

View file

@ -1674,7 +1674,7 @@ static bool test_init_tcp_connect(void)
return false; 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"); TC_ERROR("Timeout while waiting data back\n");
return false; return false;
} }
@ -1696,7 +1696,7 @@ static bool test_init_tcp_connect(void)
DBG("Waiting v6 connection\n"); 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"); TC_ERROR("Timeout while waiting data back\n");
return false; return false;
} }
@ -1716,7 +1716,7 @@ static bool test_init_tcp_connect(void)
return false; return false;
} }
k_sem_take(&wait_connect, WAIT_TIME); k_sem_take(&wait_connect, K_MSEC(WAIT_TIME));
if (!connect_cb_called) { if (!connect_cb_called) {
TC_ERROR("No IPv4 connect cb called on time, " TC_ERROR("No IPv4 connect cb called on time, "
"TCP connect test failed\n"); "TCP connect test failed\n");