From: Youngjae Cho Date: Tue, 29 Aug 2023 08:48:43 +0000 (+0900) Subject: coverage: Exclude unnecessary lines for line coverage X-Git-Tag: tizen_8.0_m2_release X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Ftizen_8.0_m2_release;p=platform%2Fcore%2Fapi%2Fruntime-info.git coverage: Exclude unnecessary lines for line coverage Exclude 1. Internal functions and its subroutine. 2. System error such as memory allocation or file open failure. Change-Id: I606d16e058cea687594577ae32f9f5681db05389 Signed-off-by: Youngjae Cho --- diff --git a/src/runtime_info_usage.c b/src/runtime_info_usage.c index 5a4f626..3bbc238 100644 --- a/src/runtime_info_usage.c +++ b/src/runtime_info_usage.c @@ -82,6 +82,7 @@ static GVariant *runtime_info_append_args(int *args, int size) return g_variant_builder_end(&builder); } +//LCOV_EXCL_START static runtime_info_error_e errno_to_runtime_info_error(int err) { switch (err) { @@ -106,6 +107,7 @@ static runtime_info_error_e errno_to_runtime_info_error(int err) return RUNTIME_INFO_ERROR_NO_DATA; } } +//LCOV_EXCL_STOP /* Handler function which handles dbus related instructions * Creates the method call to resourced and receives the reply (if successful) @@ -136,8 +138,7 @@ static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e /* Fall through */ case USAGE_TYPE_APP_MEMORY: case USAGE_TYPE_APP_CPU: - if (!error) { - //LCOV_EXCL_START : system error + if (!error) { //LCOV_EXCL_START : system error _E("INVALID_PARAMETER(0x%08x): error parameter cannot be null", RUNTIME_INFO_ERROR_INVALID_PARAMETER); return NULL; @@ -238,26 +239,32 @@ static int runtime_info_get_all_apps_usage(runtime_info_usage_type_e type, /* Populate the entries of info array using the data received from resourced */ len = g_variant_n_children(reply); if (len <= 0) { + //LCOV_EXCL_START _E("NO_DATA(0x%08x) : there is no registered app", RUNTIME_INFO_ERROR_NO_DATA); g_variant_unref(reply); return RUNTIME_INFO_ERROR_NO_DATA; + //LCOV_EXCL_STOP } usages = calloc(1, sizeof(struct app_usages_s)); if (!usages) { + //LCOV_EXCL_START _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } usages->len = (int)len; usages->list = calloc(len, sizeof(struct app_usage_s)); if (!usages->list) { + //LCOV_EXCL_START _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); free(usages); g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } g_variant_iter_init(&iter, reply); @@ -293,9 +300,11 @@ API int runtime_info_get_system_memory_info(runtime_memory_info_s *info) fp = fopen("/proc/meminfo", "r"); if (fp == NULL) { + //LCOV_EXCL_START _E("IO_ERROR(0x%08x) : failed to open file to read memory usage", RUNTIME_INFO_ERROR_IO_ERROR); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } info->total = info->free = info->cache = 0; @@ -375,9 +384,11 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ /* Populate the entries of info array using the data received from resourced */ *info = (process_memory_info_s *)malloc(size * sizeof(process_memory_info_s)); if (!(*info)) { + //LCOV_EXCL_START _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } g_variant_iter_init(&iter, reply); @@ -396,6 +407,7 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ return RUNTIME_INFO_ERROR_NONE; } +//LCOV_EXCL_START Internal API static int get_process_memory_info_direct(int *pid, int size, process_memory_info_key_e key, int **info) { int ret_hal, i; @@ -469,20 +481,16 @@ static int get_process_memory_swap_info(int *pid, int size, int **info) /* Get the needed information from resourced daemon using dbus */ reply = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_SWAP, pid, size, &error); if (!reply) { - //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; - //LCOV_EXCL_STOP } /* Check whether the received usage has expected format or not */ if (g_strcmp0(g_variant_get_type_string(reply), "a(i)") || g_variant_n_children(reply) != size) { - //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); g_variant_unref(reply); return RUNTIME_INFO_ERROR_REMOTE_IO; - //LCOV_EXCL_STOP } /* Populate the entries of info array using the data received from resourced */ @@ -587,6 +595,7 @@ API int runtime_info_get_process_memory_value_int(int *pid, int size, process_me return RUNTIME_INFO_ERROR_INVALID_PARAMETER; } } +//LCOV_EXCL_STOP API int runtime_info_get_cpu_usage(runtime_cpu_usage_s *usage) { @@ -609,9 +618,11 @@ API int runtime_info_get_cpu_usage(runtime_cpu_usage_s *usage) cpuinfo_fp = fopen("/proc/stat", "r"); if (cpuinfo_fp == NULL) { + //LCOV_EXCL_START _E("IO_ERROR(0x%08x) : failed to open file to read cpu usage", RUNTIME_INFO_ERROR_IO_ERROR); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } while (fgets(buf, sizeof(buf), cpuinfo_fp) != NULL) { @@ -829,9 +840,11 @@ API int runtime_info_get_physical_memory_size(int *size) int sum; FILE *fp = fopen("/proc/zoneinfo", "r"); if (!fp) { + //LCOV_EXCL_START _E("IO_ERROR(0x%08x) : failed to open file to read memory size", RUNTIME_INFO_ERROR_IO_ERROR); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } if (!size) {