From: hyunuk.tak Date: Tue, 28 Apr 2020 02:13:24 +0000 (+0900) Subject: [ITC][stc][Non-ACR][Fix stc_stats_info_clone_destroy TC when there is no data] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8e9438e5e66c57be5bd501248db44c182c307bf;p=test%2Ftct%2Fnative%2Fapi.git [ITC][stc][Non-ACR][Fix stc_stats_info_clone_destroy TC when there is no data] Change-Id: I460bc4588633bdefd54e1da5c83bc8559039dc2e Signed-off-by: hyunuk.tak --- diff --git a/src/itc/stc/ITs-stc.c b/src/itc/stc/ITs-stc.c index 238527076..6cebfe376 100755 --- a/src/itc/stc/ITs-stc.c +++ b/src/itc/stc/ITs-stc.c @@ -16,7 +16,7 @@ #include "ITs-stc-common.h" //& set: Stc -bool g_bIsAPISuccess = false; +int g_bIsAPISuccess = 1; /** @addtogroup itc-stc * @ingroup itc * @{ @@ -33,6 +33,9 @@ bool g_bIsAPISuccess = false; stc_callback_ret_e StcForeachStatsCallback(stc_error_e result, stc_stats_info_h info, void *user_data) { stc_stats_info_h hCloned = NULL; + + g_bIsAPISuccess = STC_ERROR_NONE; + switch (g_eStatsInfo) { case STATS_INFO_FOREACH_ALL: { @@ -40,7 +43,7 @@ stc_callback_ret_e StcForeachStatsCallback(stc_error_e result, stc_stats_info_h int nRet = stc_stats_info_clone(info, &hCloned); if(nRet != STC_ERROR_NONE || hCloned == NULL) { - g_bIsAPISuccess = false; + g_bIsAPISuccess = nRet; FPRINTF("[Line : %d][%s] stc_stats_info_clone API failed \\n", __LINE__, API_NAMESPACE); return STC_CALLBACK_CANCEL; } @@ -48,11 +51,10 @@ stc_callback_ret_e StcForeachStatsCallback(stc_error_e result, stc_stats_info_h nRet = stc_stats_info_destroy(hCloned); if(nRet != STC_ERROR_NONE) { - g_bIsAPISuccess = false; + g_bIsAPISuccess = nRet; FPRINTF("[Line : %d][%s] stc_stats_info_destroy API failed \\n", __LINE__, API_NAMESPACE); return STC_CALLBACK_CANCEL; } - g_bIsAPISuccess = true; } break; default: @@ -1234,7 +1236,7 @@ int ITs_stc_stats_info_get_process_state_p(void) * @apicovered stc_stats_info_clone, stc_stats_info_destroy * @passcase If stc_stats_info_clone and stc_stats_info_destroy returns zero * @failcase If stc_stats_info_clone or stc_stats_info_destroy do not return zero -* @precondition STC should be initialized +* @precondition STC should be initialized and stats data must be exist in the testing device * @postcondition NA */ int ITs_stc_stats_info_clone_destroy_p(void) @@ -1244,37 +1246,38 @@ int ITs_stc_stats_info_clone_destroy_p(void) stc_stats_info_e eInfo = STATS_INFO_FOREACH_ALL; int nRet = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP); - PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_app_id", StcGetError(nRet)); - - from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); - time(&to); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_app_id", StcGetError(nRet)); - nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); - PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_time_interval", StcGetError(nRet)); + from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); + time(&to); - g_bCallbackCalled = false; - g_iTargetApiCallback = -1; - g_eStatsInfo = eInfo; + nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_time_interval", StcGetError(nRet)); - nRet = stc_get_all_stats(g_hSTC, g_hRule, StcGetStatsFinishedCallback, NULL); - PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_get_all_stats", StcGetError(nRet)); + g_bCallbackCalled = false; + g_iTargetApiCallback = -1; + g_bIsAPISuccess = 1; + g_eStatsInfo = eInfo; - RUN_GMAIN_LOOP; - if(g_iTargetApiCallback != STC_ERROR_NONE) - { - FPRINTF("[Line : %d][%s] Target Api failed in the callback= %s\\n", __LINE__, API_NAMESPACE, "StcGetStatsFinishedCallback"); - return 1; - } - if(g_bCallbackCalled == false) - { - FPRINTF("[Line : %d][%s] Callback not invoked for %s\\n", __LINE__, API_NAMESPACE, "stc_get_all_stats"); - return 1; + nRet = stc_get_all_stats(g_hSTC, g_hRule, StcGetStatsFinishedCallback, NULL); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_get_all_stats", StcGetError(nRet)); + RUN_GMAIN_LOOP; + if(g_iTargetApiCallback != STC_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] Target Api failed in the callback= %s\\n", __LINE__, API_NAMESPACE, "StcGetStatsFinishedCallback"); + return 1; } - if(g_bIsAPISuccess == false) - { - return 1; + if(g_bCallbackCalled == false) + { + FPRINTF("[Line : %d][%s] Callback not invoked for %s\\n", __LINE__, API_NAMESPACE, "stc_get_all_stats"); + return 1; + } + if(g_bIsAPISuccess != 1 && g_bIsAPISuccess != STC_ERROR_NONE) + { + return 1; } + return 0; } /** @} */