From cb2b55e6aebfeca098d42d08ab70b2662d148ae0 Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Mon, 23 May 2016 21:25:58 +0900 Subject: [PATCH] Add lcov comments for coverage measurement Change-Id: If5ff51abedefb5fa218babbd2bbb125cdf153352 Signed-off-by: Kichan Kwon --- src/runtime_info.c | 2 ++ src/runtime_info_system.c | 7 +++++++ src/runtime_info_usage.c | 35 ++++++++++++++++++++++++++++++++++- src/runtime_info_vconf.c | 4 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/runtime_info.c b/src/runtime_info.c index cb1477d..4fc9471 100644 --- a/src/runtime_info.c +++ b/src/runtime_info.c @@ -414,6 +414,7 @@ API int runtime_info_unset_changed_cb(runtime_info_key_e key) return RUNTIME_INFO_ERROR_NONE; } +//LCOV_EXCL_START : Not called callback void runtime_info_updated(runtime_info_key_e key) { runtime_info_item_h runtime_info_item; @@ -457,3 +458,4 @@ void runtime_info_updated(runtime_info_key_e key) runtime_info_item->event_subscription->changed_cb(key, runtime_info_item->event_subscription->user_data); } } +//LCOV_EXCL_STOP diff --git a/src/runtime_info_system.c b/src/runtime_info_system.c index 2761305..fb48f74 100644 --- a/src/runtime_info_system.c +++ b/src/runtime_info_system.c @@ -292,6 +292,8 @@ int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_%s_freq", core_idx, type); cpufreq_fp = fopen(path, "r"); + + //LCOV_EXCL_START : fallback routine if (cpufreq_fp == NULL) { if (core_idx > 0) { _I("Fail to get the information about core%d. Get the core0's instead", @@ -307,12 +309,15 @@ int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) return RUNTIME_INFO_ERROR_IO_ERROR; } } + //LCOV_EXCL_STOP if (!fscanf(cpufreq_fp, "%d", &result)) { + //LCOV_EXCL_START : system error _E("IO_ERROR(0x%08x) : there is no information in the cpuinfo file", RUNTIME_INFO_ERROR_IO_ERROR); fclose(cpufreq_fp); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } *cpu_freq = result / 1000; @@ -320,6 +325,7 @@ int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) return RUNTIME_INFO_ERROR_NONE; } +//LCOV_EXCL_START : fallback routine int runtime_info_get_frequency_cpuinfo(int core_idx, int *cpu_freq) { FILE *cpuinfo_fp; @@ -363,3 +369,4 @@ int runtime_info_get_frequency_cpuinfo(int core_idx, int *cpu_freq) fclose(cpuinfo_fp); return RUNTIME_INFO_ERROR_NOT_SUPPORTED; } +//LCOV_EXCL_STOP diff --git a/src/runtime_info_usage.c b/src/runtime_info_usage.c index d03e565..ea2a007 100644 --- a/src/runtime_info_usage.c +++ b/src/runtime_info_usage.c @@ -36,6 +36,7 @@ #define kBtoKiB(val) (int)(((long long)val * 1024)/1000) +//LCOV_EXCL_START : system error static int runtime_info_get_dbus_error(const char *err_name) { int size; @@ -53,6 +54,7 @@ static int runtime_info_get_dbus_error(const char *err_name) else return RUNTIME_INFO_ERROR_REMOTE_IO; } +//LCOV_EXCL_STOP /* Handler function which handles dbus related instructions * for both per process memory and cpu requests. @@ -68,18 +70,22 @@ static DBusMessage *runtime_info_dbus_process_usage_info(int *pid, int size, int int ret; if (!pid || !error) { + //LCOV_EXCL_START : system error _E("INVALID_PARAMETER(0x%08x): pid list and error params cannot be null"); if (error) *error = RUNTIME_INFO_ERROR_INVALID_PARAMETER; return NULL; + //LCOV_EXCL_STOP } conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (!conn) { + //LCOV_EXCL_START : system error _E("DBUS_CONNECTION_ERROR"); *error = RUNTIME_INFO_ERROR_REMOTE_IO; return NULL; + //LCOV_EXCL_STOP } if (info == MEMORY_USAGE) { @@ -114,10 +120,12 @@ static DBusMessage *runtime_info_dbus_process_usage_info(int *pid, int size, int ret = dbus_message_append_args(msg, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &pid, size, DBUS_TYPE_INVALID); if (!ret) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: not able to append pid array to message"); *error = RUNTIME_INFO_ERROR_IO_ERROR; dbus_message_unref(msg); return NULL; + //LCOV_EXCL_STOP } dbus_error_init(&err); @@ -132,13 +140,15 @@ static DBusMessage *runtime_info_dbus_process_usage_info(int *pid, int size, int reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err); if (!reply) - _E("DBUS_METHOD_CALL: not able to send message"); + _E("DBUS_METHOD_CALL: not able to send message"); //LCOV_EXCL_LINE : system error if (dbus_error_is_set(&err)) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: dbus_connection_send error(%s:%s)", err.name, err.message); *error = runtime_info_get_dbus_error(err.name); dbus_error_free(&err); reply = NULL; + //LCOV_EXCL_STOP } dbus_message_unref(msg); @@ -211,22 +221,28 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ /* Get the needed information from resourced daemon using dbus */ replymsg = runtime_info_dbus_process_usage_info(pid, size, MEMORY_USAGE, &error); if (!replymsg) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; + //LCOV_EXCL_STOP } /* Check if the message is an error message or not in expected * format and return error value */ dbus_message_iter_init(replymsg, &iter); if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) { + //LCOV_EXCL_START : system error dbus_message_iter_get_basic(&iter, &error); _E("DBUS_METHOD_CALL: call to resourced returned error message"); dbus_message_unref(replymsg); return error; + //LCOV_EXCL_STOP } else if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); dbus_message_unref(replymsg); return RUNTIME_INFO_ERROR_REMOTE_IO; + //LCOV_EXCL_STOP } /* Populate the entries of info array using the data received from resourced */ @@ -333,31 +349,40 @@ API int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage /* Get the needed information from resourced daemon using dbus */ replymsg = runtime_info_dbus_process_usage_info(pid, size, CPU_USAGE, &error); + if (!replymsg) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; + //LCOV_EXCL_STOP } /* Check if the message is an error message or not in expected format * and return error value */ dbus_message_iter_init(replymsg, &iter); if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) { + //LCOV_EXCL_START : system error dbus_message_iter_get_basic(&iter, &error); _E("DBUS_METHOD_CALL: call to resourced returned error message"); dbus_message_unref(replymsg); return error; + //LCOV_EXCL_STOP } else if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) { + //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); dbus_message_unref(replymsg); return RUNTIME_INFO_ERROR_REMOTE_IO; + //LCOV_EXCL_STOP } /* Populate the entries of info array using the data received from resourced */ *usage = (process_cpu_usage_s *)malloc(size * sizeof(process_cpu_usage_s)); if (!(*usage)) { + //LCOV_EXCL_START : system error _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); dbus_message_unref(replymsg); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } dbus_message_iter_recurse(&iter, &iter_array); @@ -393,16 +418,20 @@ API int runtime_info_get_processor_count(int *num_core) cpuinfo_fp = fopen("/sys/devices/system/cpu/possible", "r"); if (cpuinfo_fp == NULL) { + //LCOV_EXCL_START : system error _E("IO_ERROR(0x%08x) : failed to open file to read cpu information", RUNTIME_INFO_ERROR_IO_ERROR); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } if (!fscanf(cpuinfo_fp, "%d-%d", &buf, &result)) { + //LCOV_EXCL_START : system error _E("IO_ERROR(0x%08x) : there is no information in the system file", RUNTIME_INFO_ERROR_IO_ERROR); fclose(cpuinfo_fp); return RUNTIME_INFO_ERROR_IO_ERROR; + //LCOV_EXCL_STOP } *num_core = result + 1; @@ -435,6 +464,7 @@ API int runtime_info_get_processor_current_frequency(int core_idx, int *cpu_freq if (runtime_info_get_frequency_cpufreq(core_idx, "cur", cpu_freq) != RUNTIME_INFO_ERROR_NONE) { + //LCOV_EXCL_START : system error _I("This system doesn't support cpufreq. Use cpuinfo instead."); switch (runtime_info_get_frequency_cpuinfo(core_idx, cpu_freq)) { @@ -448,6 +478,7 @@ API int runtime_info_get_processor_current_frequency(int core_idx, int *cpu_freq _E("Fail to get current CPU frequency"); return RUNTIME_INFO_ERROR_IO_ERROR; }; + //LCOV_EXCL_STOP } return RUNTIME_INFO_ERROR_NONE; @@ -477,6 +508,7 @@ API int runtime_info_get_processor_max_frequency(int core_idx, int *cpu_freq) if (runtime_info_get_frequency_cpufreq(core_idx, "max", cpu_freq) != RUNTIME_INFO_ERROR_NONE) { + //LCOV_EXCL_START : system error _I("This system doesn't support cpufreq. Use cpuinfo instead."); switch (runtime_info_get_frequency_cpuinfo(core_idx, cpu_freq)) { @@ -489,6 +521,7 @@ API int runtime_info_get_processor_max_frequency(int core_idx, int *cpu_freq) _E("Fail to get current CPU frequency"); return RUNTIME_INFO_ERROR_IO_ERROR; }; + //LCOV_EXCL_STOP } return RUNTIME_INFO_ERROR_NONE; diff --git a/src/runtime_info_vconf.c b/src/runtime_info_vconf.c index e9c8e38..8213031 100644 --- a/src/runtime_info_vconf.c +++ b/src/runtime_info_vconf.c @@ -57,6 +57,7 @@ int runtime_info_vconf_get_value_bool(const char *vconf_key, int *value) return ret; } +//LCOV_EXCL_START : not used function int runtime_info_vconf_get_value_double(const char *vconf_key, double *value) { int ret = vconf_get_dbl(vconf_key, value); @@ -79,7 +80,9 @@ int runtime_info_vconf_get_value_string(const char *vconf_key, char **value) *value = str_value; return RUNTIME_INFO_ERROR_NONE; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START : not called callback typedef void (*runtime_info_vconf_event_cb)(keynode_t *node, void *event_data); static void runtime_info_vconf_event_cb0(keynode_t *node, void *event_data) @@ -134,6 +137,7 @@ static runtime_info_vconf_event_cb runtime_info_vconf_get_event_cb_slot(int slot return NULL; } } +//LCOV_EXCL_STOP int runtime_info_vconf_set_event_cb(const char *vconf_key, runtime_info_key_e runtime_info_key, int slot) { -- 2.7.4