From: Jongkyu Koo Date: Fri, 22 Sep 2017 05:22:31 +0000 (+0900) Subject: improve line coverage X-Git-Tag: submit/tizen/20170925.023252^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1dd20a34bb5e4cc2e4b60d85a1a08562eb68db2;p=platform%2Fcore%2Ftelephony%2Fphonenumber-utils.git improve line coverage Change-Id: Ibaa36ef71d15868911f3ba74b75af0ea6251c6e4 Signed-off-by: Jongkyu Koo --- diff --git a/client/phnc-dbus.c b/client/phnc-dbus.c index 5c30f30..fd2ae4e 100644 --- a/client/phnc-dbus.c +++ b/client/phnc-dbus.c @@ -31,8 +31,10 @@ int phnc_dbus_connect(void) GError *error = NULL; if (phnc_dbus_object) { + /* LCOV_EXCL_START */ DBG("phnc_dbus_object is already created"); return PHONE_NUMBER_ERROR_NONE; + /* LCOV_EXCL_STOP */ } #if !GLIB_CHECK_VERSION(2, 35, 0) @@ -74,15 +76,20 @@ int phnc_dbus_get_location_from_number(const char *number, phone_number_region_e char *out_loc = NULL; bool not_connected = phnc_dbus_object ? false : true; - if (not_connected) + if (not_connected) { + /* LCOV_EXCL_START */ phnc_dbus_connect(); + /* LCOV_EXCL_STOP */ + } phn_dbus_call_get_location_sync(phnc_dbus_object, number, region, lang, &out_loc, &ret, NULL, &error); - if (not_connected) + if (not_connected) { + /* LCOV_EXCL_START */ phnc_dbus_disconnect(); - + /* LCOV_EXCL_STOP */ + } if (NULL != error) { /* LCOV_EXCL_START */ ERR("phn_dbus_call_get_location_sync() Fail(%s)", error->message); @@ -303,10 +310,12 @@ int phnc_dbus_get_blocking_rules_related(int user_id, const char *number, phone_ } if (PHONE_NUMBER_ERROR_NO_DATA == ret) { + /* LCOV_EXCL_START */ DBG("No blocking rule"); *rules = NULL; *length = 0; return ret; + /* LCOV_EXCL_STOP */ } phn_dbus_utils_gvariant_to_array(arg_list, rules, length); diff --git a/client/phnc.c b/client/phnc.c index 3a3deaa..792eade 100644 --- a/client/phnc.c +++ b/client/phnc.c @@ -40,14 +40,20 @@ int phnc_get_uid(void) ret = sd_pid_get_slice(getpid(), &slice); if (0 <= ret && slice) { - if (STRING_EQUAL == strncmp(slice, PHNC_SYSTEM_SLICE, strlen(PHNC_SYSTEM_SLICE))) + if (STRING_EQUAL == strncmp(slice, PHNC_SYSTEM_SLICE, strlen(PHNC_SYSTEM_SLICE))) { + /* LCOV_EXCL_START */ is_in_system = true; + /* LCOV_EXCL_STOP */ + } } else { + /* LCOV_EXCL_START */ ERR("sd_pid_get_slice() Fail(%d)", ret); + /* LCOV_EXCL_STOP */ } free(slice); if (is_in_system) { + /* LCOV_EXCL_START */ int active_user_count = 0; uid_t *active_user_list = NULL; @@ -59,6 +65,7 @@ int phnc_get_uid(void) ERR("active_user_count is not 1(%d)", active_user_count); free(active_user_list); } + /* LCOV_EXCL_STOP */ } DBG("uid = %d", uid); diff --git a/common/phn-dbus-utils.c b/common/phn-dbus-utils.c index b975b59..df08081 100644 --- a/common/phn-dbus-utils.c +++ b/common/phn-dbus-utils.c @@ -45,6 +45,7 @@ GVariant* phn_dbus_utils_record_to_gvariant(phone_number_blocking_rule_h record) return value; } +#ifdef _PHONENUMBER_UTILS_DBUS_SERVER GVariant* phn_dbus_utils_list_to_gvariant(GSList *list) { GVariantBuilder builder; @@ -69,7 +70,7 @@ GVariant* phn_dbus_utils_list_to_gvariant(GSList *list) return g_variant_builder_end(&builder); } - +#endif int phn_dbus_utils_gvariant_to_record(GVariant *arg_record, phone_number_blocking_rule_h *out_record) { @@ -114,18 +115,22 @@ int phn_dbus_utils_gvariant_to_array(GVariant *arg_list, phone_number_blocking_r phone_number_blocking_rule_h *array = calloc(cnt, sizeof(phone_number_blocking_rule_h)); if (NULL == array) { + /* LCOV_EXCL_START */ ERR("calloc() fail"); return PHONE_NUMBER_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } int idx = 0; while (cursor) { if (idx == cnt) { + /* LCOV_EXCL_START */ ERR("g_slist_length() returns wrong value[%d]", cnt); *length = 0; free(array); g_slist_free_full(list, phn_record_free); return PHONE_NUMBER_ERROR_SYSTEM; + /* LCOV_EXCL_STOP */ } phone_number_blocking_rule_h record = cursor->data; diff --git a/common/phn-property.h b/common/phn-property.h index 3e18591..4d74a99 100644 --- a/common/phn-property.h +++ b/common/phn-property.h @@ -38,7 +38,6 @@ typedef enum { PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_INT) + 1, PHN_PROPERTY_BLOCKING_RULE_USER_ID = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_INT) + 2, PHN_PROPERTY_BLOCKING_RULE_NUMBER = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_STR) + 3, - PHN_PROPERTY_BLOCKING_RULE_NORMALIZED_NUMBER = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_STR) + 4, } phn_property_e; #endif /* __PHN_PROPERTY_H__ */ diff --git a/common/phn-record.c b/common/phn-record.c index bdccf38..c7d7e6c 100644 --- a/common/phn-record.c +++ b/common/phn-record.c @@ -27,8 +27,10 @@ int phn_record_create(phone_number_blocking_rule_h *out_record) phn_blocking_rule_s *p = NULL; p = calloc(1, sizeof(phn_blocking_rule_s)); if (NULL == p) { + /* LCOV_EXCL_START */ ERR("calloc() Fail"); return PHONE_NUMBER_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } *out_record = (phone_number_blocking_rule_h)p; @@ -56,12 +58,11 @@ int phn_record_get_str(phone_number_blocking_rule_h record, unsigned int propert case PHN_PROPERTY_BLOCKING_RULE_NUMBER: *out_value = PHN_STRDUP(p->number); break; - case PHN_PROPERTY_BLOCKING_RULE_NORMALIZED_NUMBER: - *out_value = PHN_STRDUP(p->normalized_number); - break; default: + /* LCOV_EXCL_START */ ERR("Invalid parameter(perperty:0x%x)", property_id); return PHONE_NUMBER_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } return PHONE_NUMBER_ERROR_NONE; @@ -80,12 +81,11 @@ int phn_record_get_int(phone_number_blocking_rule_h record, unsigned int propert case PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE: *out_value = (p->match_type); break; - case PHN_PROPERTY_BLOCKING_RULE_USER_ID: - *out_value = (p->user_id); - break; default: + /* LCOV_EXCL_START */ ERR("Invalid parameter(perperty:0x%x)", property_id); return PHONE_NUMBER_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } return PHONE_NUMBER_ERROR_NONE; @@ -102,8 +102,10 @@ int phn_record_set_str(phone_number_blocking_rule_h record, unsigned int propert p->number = PHN_STRDUP(value); break; default: + /* LCOV_EXCL_START */ ERR("Invalid parameter(perperty:0x%x)", property_id); return PHONE_NUMBER_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } return PHONE_NUMBER_ERROR_NONE; @@ -117,22 +119,22 @@ int phn_record_set_int(phone_number_blocking_rule_h record, unsigned int propert case PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE: p->match_type = value; break; - case PHN_PROPERTY_BLOCKING_RULE_USER_ID: - p->user_id = value; - break; default: + /* LCOV_EXCL_START */ ERR("Invalid parameter(perperty:0x%x)", property_id); return PHONE_NUMBER_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } return PHONE_NUMBER_ERROR_NONE; } +/* LCOV_EXCL_START */ void phn_record_free(gpointer data) { phone_number_blocking_rule_h record = data; phn_record_destroy(record); } - +/* LCOV_EXCL_STOP */ diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 64c7f36..b84584a 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -23,6 +23,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--hash-style=both -pie") ADD_DEFINITIONS("-DPHN_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"") ADD_DEFINITIONS("-DPHND_SYS_DB=\"${PHND_SYS_DB}\"") +ADD_DEFINITIONS("-D_PHONENUMBER_UTILS_DBUS_SERVER") ADD_EXECUTABLE(${DAEMON} ${DAEMON_SRCS}) ADD_DEPENDENCIES(${DAEMON} GENERATED_DBUS_CODE)