#include "ITs-stc-common.h"
//& set: Stc
-bool g_bIsAPISuccess = false;
+int g_bIsAPISuccess = 1;
/** @addtogroup itc-stc
* @ingroup itc
* @{
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:
{
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;
}
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:
* @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)
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;
}
/** @} */