From 3e7e3a0336e460597c4dfdcb93ceca400f2e7af1 Mon Sep 17 00:00:00 2001 From: Francois Gervais Date: Tue, 24 Sep 2024 18:51:56 -0400 Subject: [PATCH] tests: coap_client: wait enough for requests to be unallocated As confirmable requests will stay allocated for (3 * ACK_TIMEOUT), we need to adjust the timings so all requests are unallocated by the end of the test. (cherry picked from commit 13cad59542d15e57fd4a70dfc9354b7251a8b0f4) Original-Signed-off-by: Francois Gervais GitOrigin-RevId: 13cad59542d15e57fd4a70dfc9354b7251a8b0f4 Cr-Build-Id: 8735719366973287825 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8735719366973287825 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: I5eb256f0b93b51e5b70b7e8fa95409e41bf29200 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5893147 Tested-by: ChromeOS Prod (Robot) Reviewed-by: Fabio Baltieri Commit-Queue: Fabio Baltieri Tested-by: Fabio Baltieri --- tests/net/lib/coap_client/CMakeLists.txt | 2 +- tests/net/lib/coap_client/src/main.c | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/tests/net/lib/coap_client/CMakeLists.txt b/tests/net/lib/coap_client/CMakeLists.txt index d99bb3145f9..e12214fc6a9 100644 --- a/tests/net/lib/coap_client/CMakeLists.txt +++ b/tests/net/lib/coap_client/CMakeLists.txt @@ -26,7 +26,7 @@ add_compile_definitions(CONFIG_COAP_CLIENT_MESSAGE_HEADER_SIZE=48) add_compile_definitions(CONFIG_COAP_CLIENT_STACK_SIZE=1024) add_compile_definitions(CONFIG_COAP_CLIENT_THREAD_PRIORITY=10) add_compile_definitions(CONFIG_COAP_LOG_LEVEL=4) -add_compile_definitions(CONFIG_COAP_INIT_ACK_TIMEOUT_MS=200) +add_compile_definitions(CONFIG_COAP_INIT_ACK_TIMEOUT_MS=10) add_compile_definitions(CONFIG_COAP_CLIENT_MAX_REQUESTS=2) add_compile_definitions(CONFIG_COAP_CLIENT_MAX_INSTANCES=2) add_compile_definitions(CONFIG_COAP_MAX_RETRANSMIT=4) diff --git a/tests/net/lib/coap_client/src/main.c b/tests/net/lib/coap_client/src/main.c index 665aab30892..b487bdf7d5a 100644 --- a/tests/net/lib/coap_client/src/main.c +++ b/tests/net/lib/coap_client/src/main.c @@ -377,7 +377,6 @@ ZTEST(coap_client, test_get_request) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -406,7 +405,7 @@ ZTEST(coap_client, test_resend_request) LOG_INF("Send request"); ret = coap_client_req(&client, 0, &address, &client_request, NULL); zassert_true(ret >= 0, "Sending request failed, %d", ret); - k_sleep(K_MSEC(300)); + k_sleep(K_MSEC(15)); set_socket_events(ZSOCK_POLLIN); k_sleep(K_MSEC(100)); @@ -440,7 +439,6 @@ ZTEST(coap_client, test_echo_option) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -471,7 +469,6 @@ ZTEST(coap_client, test_echo_option_next_req) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); @@ -486,7 +483,6 @@ ZTEST(coap_client, test_echo_option_next_req) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -540,7 +536,6 @@ ZTEST(coap_client, test_send_large_data) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -574,8 +569,8 @@ ZTEST(coap_client, test_no_response) ret = coap_client_req(&client, 0, &address, &client_request, ¶ms); zassert_true(ret >= 0, "Sending request failed, %d", ret); - k_sleep(K_MSEC(300)); + k_sleep(K_MSEC(700)); zassert_equal(last_response_code, -ETIMEDOUT, "Unexpected response"); } @@ -605,9 +600,7 @@ ZTEST(coap_client, test_separate_response) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); - zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -638,11 +631,9 @@ ZTEST(coap_client, test_multiple_requests) ret = coap_client_req(&client, 0, &address, &client_request, NULL); zassert_true(ret >= 0, "Sending request failed, %d", ret); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); - k_sleep(K_MSEC(5)); k_sleep(K_MSEC(100)); zassert_equal(last_response_code, COAP_RESPONSE_CODE_OK, "Unexpected response"); } @@ -676,9 +667,8 @@ ZTEST(coap_client, test_unmatching_tokens) zassert_true(ret >= 0, "Sending request failed, %d", ret); set_socket_events(ZSOCK_POLLIN); - k_sleep(K_MSEC(1)); - k_sleep(K_MSEC(1)); + k_sleep(K_MSEC(2)); clear_socket_events(); - k_sleep(K_MSEC(500)); + k_sleep(K_MSEC(700)); zassert_equal(last_response_code, -ETIMEDOUT, "Unexpected response"); }