Skip to content

Commit

Permalink
tests: coap_client: wait enough for requests to be unallocated
Browse files Browse the repository at this point in the history
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 13cad59)

Original-Signed-off-by: Francois Gervais <francoisgervais@gmail.com>
GitOrigin-RevId: 13cad59
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) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
Tested-by: Fabio Baltieri <fabiobaltieri@google.com>
  • Loading branch information
fgervais authored and Chromeos LUCI committed Sep 26, 2024
1 parent b26a8c6 commit 3e7e3a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/net/lib/coap_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 4 additions & 14 deletions tests/net/lib/coap_client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");

Expand All @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -574,8 +569,8 @@ ZTEST(coap_client, test_no_response)
ret = coap_client_req(&client, 0, &address, &client_request, &params);

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");
}

Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}

0 comments on commit 3e7e3a0

Please sign in to comment.