From 47590c38531b3b62d6bf0531e115aa04a9f6aa43 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Mon, 25 Feb 2019 18:11:59 +0900 Subject: [PATCH] Test to get all statistics info Change-Id: If43661019a26727d5940bd2379531a0770f699a5 Signed-off-by: hyunuktak --- test/statistics.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/test/statistics.c b/test/statistics.c index b568cec..08671a2 100755 --- a/test/statistics.c +++ b/test/statistics.c @@ -138,6 +138,27 @@ static stc_callback_ret_e __test_stc_stats_info_cb( return STC_CALLBACK_CONTINUE; } +void __test_stc_get_stats_finished_cb(stc_error_e result, + stc_all_stats_info_h info, void *user_data) +{ + if (result != STC_ERROR_NONE) { + msg("Response get stats finished error " LOG_RED "[%s]" LOG_END, + test_stc_convert_error_type_to_string(result)); + return; + } + + int ret = STC_ERROR_NONE; + + ret = stc_foreach_all_stats(info, __test_stc_stats_info_cb, NULL); + if (ret == STC_ERROR_NONE) + msg(LOG_GREEN "Success to get all stats info" LOG_END); + else + msg("Fail to Success to get all stats info " LOG_RED "[%s]" LOG_END, + test_stc_convert_error_type_to_string(ret)); + + return; +} + static int __test_stc_set_reset_rule(MManager *mm, struct menu_data *menu) { int ret = STC_ERROR_NONE; @@ -329,7 +350,7 @@ static int __test_stc_stats_get(MManager *mm, struct menu_data *menu) return ret; } -static int __test_stc_foreach_stats(MManager *mm, struct menu_data *menu) +static int __test_stc_stats_get_all(MManager *mm, struct menu_data *menu) { int ret = STC_ERROR_NONE; time_t from = 0; @@ -344,9 +365,9 @@ static int __test_stc_foreach_stats(MManager *mm, struct menu_data *menu) msg("Fail to set time interval " LOG_RED "[%s]" LOG_END, test_stc_convert_error_type_to_string(ret)); - ret = stc_foreach_stats(g_stc, + ret = stc_get_all_stats(g_stc, g_stats_rule, - __test_stc_stats_info_cb, + __test_stc_get_stats_finished_cb, NULL); if (ret == STC_ERROR_NONE) msg(LOG_GREEN "Success to request stats all info" LOG_END); @@ -470,7 +491,7 @@ static struct menu_data menu_reset[] = { static struct menu_data menu_stats[] = { { "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " stats rule", menu_stats_rule, NULL, NULL}, { "2", LOG_LIGHTBLUE "[Get]" LOG_END " stats", NULL, __test_stc_stats_get, NULL}, - { "3", LOG_LIGHTBLUE "[Get]" LOG_END " all stats", NULL, __test_stc_foreach_stats, NULL}, + { "3", LOG_LIGHTBLUE "[Get]" LOG_END " all stats", NULL, __test_stc_stats_get_all, NULL}, { "4", LOG_LIGHTBLUE "[Get]" LOG_END " total stats", NULL, __test_stc_stats_get_total, NULL}, { NULL, NULL, }, }; -- 2.7.4