From: jusung Date: Wed, 15 Dec 2021 02:07:04 +0000 (+0900) Subject: [UTC][ITC][cion][Non-ACR] Fix timing issue X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F268026%2F2;p=test%2Ftct%2Fnative%2Fapi.git [UTC][ITC][cion][Non-ACR] Fix timing issue - check connection result - adjust wait time Change-Id: Ie6c2e9adac4aab927b91fbce9d2503cacd8f09c0 Signed-off-by: jusung --- diff --git a/src/itc/cion/ITs-cion-client.c b/src/itc/cion/ITs-cion-client.c index a942e0423..4011814c8 100755 --- a/src/itc/cion/ITs-cion-client.c +++ b/src/itc/cion/ITs-cion-client.c @@ -22,6 +22,8 @@ * @{ */ bool g_bCallbackCalledDiscover; +bool g_bCallbackCalledResult; + struct cbdata { cion_client_h client; bool connected; @@ -36,7 +38,7 @@ static gboolean __timeout_cb(gpointer data) static void RunPollingLoop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(10000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; @@ -73,7 +75,7 @@ static gpointer SendDataThread(gpointer data) * @parameter const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data * @return NA */ -void ServerDataReceivedCB(const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data) +void ServerDataReceivedCB(const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data) { FPRINTF("[Line : %d][%s] Callback ServerDataReceivedCB called\\n", __LINE__, API_NAMESPACE); char pszStr[] ="data_result"; @@ -151,6 +153,8 @@ static void ClientServerDiscoveredCB3(const char *service_name,const cion_peer_i nRetVal = cion_client_connect(cbdata->client, peer_info); if (nRetVal != CION_ERROR_NONE) FPRINTF("[Line : %d][%s] Failed cion_client_connect\\n", __LINE__, API_NAMESPACE); + + StopPollingLoop(); } /** @@ -209,8 +213,17 @@ static void ClientPayloadReceivedCB(const char *service_name,const cion_peer_inf */ static void ClientConnectionResultCB(const char *service_name,const cion_peer_info_h peer_info,const cion_connection_result_h result, void *user_data) { - FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB called\\n", __LINE__, API_NAMESPACE); + cion_connection_status_e status; + int nRetVal; + + nRetVal = cion_connection_result_get_status(result, &status); + + FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB called[%d][%d]\\n", __LINE__, API_NAMESPACE, nRetVal, status); sleep(2); + + if (status == CION_CONNECTION_STATUS_OK) + g_bCallbackCalledResult = true; + StopPollingLoop(); } @@ -454,6 +467,7 @@ int ITc_cion_client_send_data_p(void) cion_server_h hServer; g_bCallbackCalled = false; g_bCallbackCalledDiscover = false; + g_bCallbackCalledResult = false; int nTimeoutId = -1; GThread *thread; @@ -474,7 +488,7 @@ int ITc_cion_client_send_data_p(void) nRetVal = cion_server_listen(hServer, ServerConnectionRequestCB,hServer); PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_server_listen", CionGetError(nRetVal)); - nRetVal = cion_client_add_connection_result_cb(hClient,ClientConnectionResultCB, NULL); + nRetVal = cion_client_add_connection_result_cb(hClient, ClientConnectionResultCB, NULL); PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_client_add_connection_result_cb", CionGetError(nRetVal)); cbdata.client = hClient; @@ -487,11 +501,19 @@ int ITc_cion_client_send_data_p(void) FPRINTF("[Line : %d][%s] Callback ClientServerDiscoveredCB4 not invoked\\n", __LINE__, API_NAMESPACE); return 1; } + + RunPollingLoop(); + if(g_bCallbackCalledResult != true) + { + FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB not invoked\\n", __LINE__, API_NAMESPACE); + return 1; + } + send_data.client = hClient; thread = g_thread_new("send_data", SendDataThread, &send_data); RunPollingLoop(); - PRINT_RESULT(CION_ERROR_NONE, send_data.ret, "cion_client_try_discovery", CionGetError(send_data.ret)); + PRINT_RESULT(CION_ERROR_NONE, send_data.ret, "cion_client_send_data", CionGetError(send_data.ret)); if(strncmp((const char *)send_data.return_data, "data_result",send_data.return_data_size) != 0) { FPRINTF("[Line : %d][%s] data is not correct\\n", __LINE__, API_NAMESPACE); @@ -536,6 +558,7 @@ int ITc_cion_client_send_payload_async_p(void) unsigned char pszData[] = "ITc_cion_client_send_payload_async_p"; struct cbdata cbdata; g_bCallbackCalled = false; + g_bCallbackCalledResult = false; int nTimeoutId = -1; nRetVal = cion_server_create(&hServer,"ITc_cion_client_send_payload_async_p","ITc_cion_client_send_payload_async_p", NULL); @@ -555,6 +578,9 @@ int ITc_cion_client_send_payload_async_p(void) nRetVal = cion_client_try_discovery(hClient, ClientServerDiscoveredCB3,&cbdata); PRINT_RESULT_CLEANUP(CION_ERROR_NONE, nRetVal, "cion_client_try_discovery", CionGetError(nRetVal),cion_server_destroy(hServer);cion_client_destroy(hClient)); + nRetVal = cion_client_add_connection_result_cb(hClient,ClientConnectionResultCB, NULL); + PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_client_add_connection_result_cb", CionGetError(nRetVal)); + RunPollingLoop(); if(g_bCallbackCalled != true) { @@ -564,6 +590,13 @@ int ITc_cion_client_send_payload_async_p(void) return 1; } + RunPollingLoop(); + if(g_bCallbackCalledResult != true) + { + FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB not invoked\\n", __LINE__, API_NAMESPACE); + return 1; + } + nRetVal = cion_payload_create(&hPayload, CION_PAYLOAD_TYPE_DATA); PRINT_RESULT_CLEANUP(CION_ERROR_NONE, nRetVal, "cion_payload_create", CionGetError(nRetVal),cion_server_destroy(hServer);cion_client_destroy(hClient)); CHECK_HANDLE(hPayload,"cion_payload_create"); diff --git a/src/itc/cion/ITs-cion-common.h b/src/itc/cion/ITs-cion-common.h index d65961d8d..7ae8c1746 100755 --- a/src/itc/cion/ITs-cion-common.h +++ b/src/itc/cion/ITs-cion-common.h @@ -26,8 +26,8 @@ #include #define API_NAMESPACE "CION_ITC" -#define TIMEOUT_CB 10000 -#define TIMEOUT_CB1 5000 +#define TIMEOUT_CB 60000 +#define TIMEOUT_CB1 60000 /** @addtogroup itc-%{MODULE_NAME} * @ingroup itc * @{ diff --git a/src/itc/cion/ITs-cion-payload.c b/src/itc/cion/ITs-cion-payload.c index 83c2ca889..8cf8bb9cb 100755 --- a/src/itc/cion/ITs-cion-payload.c +++ b/src/itc/cion/ITs-cion-payload.c @@ -32,7 +32,7 @@ static gboolean __timeout_cb(gpointer data) static void RunPollingLoop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(5000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; @@ -745,4 +745,4 @@ int ITc_cion_payload_get_total_bytes_p(void) /** @} */ -/** @} */ \ No newline at end of file +/** @} */ diff --git a/src/itc/cion/ITs-cion-server.c b/src/itc/cion/ITs-cion-server.c index f12391ba9..57dfe8783 100755 --- a/src/itc/cion/ITs-cion-server.c +++ b/src/itc/cion/ITs-cion-server.c @@ -37,7 +37,7 @@ static gboolean __timeout_cb(gpointer data) static void RunPollingLoop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(10000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; @@ -119,6 +119,8 @@ static void ServerConnectionRequestCB3(const char *service_name,const cion_peer_ ret = cion_peer_info_clone(peer_info, peer); if (ret != CION_ERROR_NONE) FPRINTF("[Line : %d][%s] failed cion_peer_info_clone\\n", __LINE__, API_NAMESPACE); + + StopPollingLoop(); } /** diff --git a/src/utc/cion/utc-cion-client.c b/src/utc/cion/utc-cion-client.c index 329625bf5..b57da50dc 100644 --- a/src/utc/cion/utc-cion-client.c +++ b/src/utc/cion/utc-cion-client.c @@ -47,7 +47,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(10000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; @@ -248,6 +248,12 @@ int utc_cion_client_stop_discovery_n(void) static void __server_connection_request_cb(const char *service_name, const cion_peer_info_h peer_info, void *user_data) { + int ret; + cion_server_h server = (cion_server_h)user_data; + + ret = cion_server_accept(server, peer_info); + if (ret != CION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "[%s] Failed to accept client", __func__); } static void __client_server_discovered_cb2(const char *service_name, @@ -288,7 +294,7 @@ int utc_cion_client_connect_p(void) __client_connection_result_cb1, NULL); assert_eq(ret, CION_ERROR_NONE); - ret = cion_server_listen(server, __server_connection_request_cb, NULL); + ret = cion_server_listen(server, __server_connection_request_cb, server); assert_eq(ret, CION_ERROR_NONE); ret = cion_client_try_discovery(client, __client_server_discovered_cb2, @@ -332,17 +338,6 @@ int utc_cion_client_connect_n(void) return 0; } -static void __server_connection_request_cb2(const char *service_name, - const cion_peer_info_h peer_info, void *user_data) -{ - int ret; - cion_server_h server = (cion_server_h)user_data; - - ret = cion_server_accept(server, peer_info); - if (ret != CION_ERROR_NONE) - dlog_print(DLOG_ERROR, LOG_TAG, "[%s] Failed to accept client", __func__); -} - static void __client_server_discovered_cb3(const char *service_name, const cion_peer_info_h peer_info, void *user_data) { @@ -416,7 +411,11 @@ int utc_cion_client_disconnect_p(void) NULL); assert_eq(ret, CION_ERROR_NONE); - ret = cion_server_listen(server, __server_connection_request_cb2, server); + ret = cion_client_add_connection_result_cb(cbdata.client, + __client_connection_result_cb1, NULL); + assert_eq(ret, CION_ERROR_NONE); + + ret = cion_server_listen(server, __server_connection_request_cb, server); assert_eq(ret, CION_ERROR_NONE); ret = cion_client_try_discovery(cbdata.client, __client_server_discovered_cb3, @@ -424,7 +423,11 @@ int utc_cion_client_disconnect_p(void) assert_eq(ret, CION_ERROR_NONE); dlog_print(DLOG_INFO, LOG_TAG, - "[%s] Wait for discovering & connecting to server", __func__); + "[%s] Wait for discovering to server", __func__); + __run_polling_loop(); + + dlog_print(DLOG_INFO, LOG_TAG, + "[%s] Wait for connecting to server", __func__); __run_polling_loop(); assert_eq(cbdata.connected, true); @@ -479,7 +482,7 @@ int utc_cion_client_send_data_p(void) ret = cion_server_set_data_received_cb(server, __server_data_received_cb, NULL); assert_eq(ret, CION_ERROR_NONE); - ret = cion_server_listen(server, __server_connection_request_cb2, server); + ret = cion_server_listen(server, __server_connection_request_cb, server); assert_eq(ret, CION_ERROR_NONE); ret = cion_client_add_connection_result_cb(client, @@ -576,7 +579,11 @@ int utc_cion_client_send_payload_async_p(void) "utc_cion_client_send_payload_async_p", NULL); assert_eq(ret, CION_ERROR_NONE); - ret = cion_server_listen(server, __server_connection_request_cb2, server); + ret = cion_client_add_connection_result_cb(client, + __client_connection_result_cb1, NULL); + assert_eq(ret, CION_ERROR_NONE); + + ret = cion_server_listen(server, __server_connection_request_cb, server); assert_eq(ret, CION_ERROR_NONE); cbdata.client = client; @@ -587,7 +594,11 @@ int utc_cion_client_send_payload_async_p(void) assert_eq(ret, CION_ERROR_NONE); dlog_print(DLOG_INFO, LOG_TAG, - "[%s] Wait for discovering & connecting to server", __func__); + "[%s] Wait for discovering to server", __func__); + __run_polling_loop(); + + dlog_print(DLOG_INFO, LOG_TAG, + "[%s] Wait for connecting to server", __func__); __run_polling_loop(); ret = cion_payload_create(&payload, CION_PAYLOAD_TYPE_DATA); diff --git a/src/utc/cion/utc-cion-connection_result.c b/src/utc/cion/utc-cion-connection_result.c index de85cf84a..54e34036c 100644 --- a/src/utc/cion/utc-cion-connection_result.c +++ b/src/utc/cion/utc-cion-connection_result.c @@ -34,7 +34,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(10000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; diff --git a/src/utc/cion/utc-cion-payload.c b/src/utc/cion/utc-cion-payload.c index 4dc5fdc88..e9730ff88 100644 --- a/src/utc/cion/utc-cion-payload.c +++ b/src/utc/cion/utc-cion-payload.c @@ -35,7 +35,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(5000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; diff --git a/src/utc/cion/utc-cion-payload_async_result.c b/src/utc/cion/utc-cion-payload_async_result.c index 8e1252413..060c60414 100644 --- a/src/utc/cion/utc-cion-payload_async_result.c +++ b/src/utc/cion/utc-cion-payload_async_result.c @@ -34,7 +34,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(5000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; diff --git a/src/utc/cion/utc-cion-peer_info.c b/src/utc/cion/utc-cion-peer_info.c index 1083da03e..eb1cdbbe1 100644 --- a/src/utc/cion/utc-cion-peer_info.c +++ b/src/utc/cion/utc-cion-peer_info.c @@ -34,7 +34,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(5000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL; diff --git a/src/utc/cion/utc-cion-server.c b/src/utc/cion/utc-cion-server.c index 349bca525..9e790b440 100644 --- a/src/utc/cion/utc-cion-server.c +++ b/src/utc/cion/utc-cion-server.c @@ -34,7 +34,7 @@ static gboolean __timeout_cb(gpointer data) static void __run_polling_loop(void) { main_loop = g_main_loop_new(NULL, FALSE); - source_id = g_timeout_add(10000, __timeout_cb, NULL);\ + source_id = g_timeout_add(60000, __timeout_cb, NULL);\ g_main_loop_run(main_loop);\ g_source_remove(source_id); main_loop = NULL;