@@ -903,3 +903,35 @@ ZTEST(coap_client, test_cancel_match)
903903 zassert_ok (k_sem_take (& sem2 , K_MSEC (MORE_THAN_EXCHANGE_LIFETIME_MS )));
904904
905905}
906+
907+ ZTEST (coap_client , test_non_confirmable )
908+ {
909+ struct coap_client_request req = {
910+ .method = COAP_METHOD_GET ,
911+ .confirmable = false,
912+ .path = test_path ,
913+ .fmt = COAP_CONTENT_FORMAT_TEXT_PLAIN ,
914+ .cb = coap_callback ,
915+ .payload = short_payload ,
916+ .len = strlen (short_payload ),
917+ .user_data = & sem1
918+ };
919+
920+ z_impl_zsock_sendto_fake .custom_fake = z_impl_zsock_sendto_custom_fake_no_reply ;
921+ set_socket_events (client .fd , ZSOCK_POLLOUT );
922+
923+ for (int i = 0 ; i < CONFIG_COAP_CLIENT_MAX_REQUESTS ; i ++ ) {
924+ zassert_ok (coap_client_req (& client , 0 , & dst_address , & req , NULL ));
925+ }
926+ zassert_equal (coap_client_req (& client , 0 , & dst_address , & req , NULL ), - EAGAIN , "" );
927+
928+ k_sleep (K_MSEC (MORE_THAN_LONG_EXCHANGE_LIFETIME_MS ));
929+
930+ for (int i = 0 ; i < CONFIG_COAP_CLIENT_MAX_REQUESTS ; i ++ ) {
931+ zassert_ok (coap_client_req (& client , 0 , & dst_address , & req , NULL ));
932+ }
933+ zassert_equal (coap_client_req (& client , 0 , & dst_address , & req , NULL ), - EAGAIN , "" );
934+
935+ /* No callbacks from non-confirmable */
936+ zassert_not_ok (k_sem_take (& sem1 , K_MSEC (MORE_THAN_EXCHANGE_LIFETIME_MS )));
937+ }
0 commit comments