From: saerome.kim Date: Thu, 8 Mar 2018 13:00:01 +0000 (+0900) Subject: enable gcov and increase line coverage X-Git-Tag: submit/tizen/20180412.075158~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df0d8ce07ab3659aa1a99f4e844d7d14c20aefb0;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git enable gcov and increase line coverage Change-Id: I9db4a17be31bc0c34311002b83ed7a521b820133 Signed-off-by: saerome.kim --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f04c32..a0cb29f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,12 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) +IF(BUILD_GCOV) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden -fprofile-arcs -ftest-coverage") +ELSE(BUILD_GCOV) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden") +ENDIF(BUILD_GCOV) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/packaging/capi-network-wifi-mesh.spec b/packaging/capi-network-wifi-mesh.spec index b5d4c36..27a12f0 100644 --- a/packaging/capi-network-wifi-mesh.spec +++ b/packaging/capi-network-wifi-mesh.spec @@ -34,6 +34,11 @@ Mesh Core API library (development library) cp %{SOURCE1001} . %build + +%if 0%{?gcov:1} +export LDFLAGS+=" -lgcov" +%endif + MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DLIB_INSTALL_DIR=%{_libdir} \ @@ -41,7 +46,8 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DINCLUDE_INSTALL_DIR=%{_includedir} \ -DLIB_PATH=%{_lib} \ -DFULLVER=%{version} \ - -DMAJORVER=${MAJORVER} + -DMAJORVER=${MAJORVER} \ + -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} make %{?jobs:-j%jobs} diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index 4f96ac9..191529b 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -69,10 +69,10 @@ static GDBusProxy *_proxy_get_mesh_service(struct mesh_handle *handle) return proxy; } +/* LCOV_EXCL_START */ static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec, gpointer *user_data) { - /* LCOV_EXCL_START */ GDBusProxy *proxy = G_DBUS_PROXY(object); gchar *name_owner = g_dbus_proxy_get_name_owner(proxy); wifi_mesh_h handle = (wifi_mesh_h)user_data; @@ -80,11 +80,11 @@ static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec, LOGD("Name owner notify [%s]", name_owner); if (NULL == name_owner) - _wifi_mesh_close_gdbus_call(handle); //LCOV_EXCL_LINE - + _wifi_mesh_close_gdbus_call(handle); g_free(name_owner); - /* LCOV_EXCL_STOP */ + } +/* LCOV_EXCL_STOP */ static int _wifi_mesh_create_gdbus_call(wifi_mesh_h handle) { @@ -135,14 +135,14 @@ static int _wifi_mesh_close_gdbus_call(wifi_mesh_h handle) } static GList *g_networks = { 0, }; +/* LCOV_EXCL_START */ static void _wifi_mesh_free_network(gpointer data) { - /* LCOV_EXCL_START */ struct mesh_network_s *network = data; g_free(network); network = NULL; - /* LCOV_EXCL_STOP */ } +/* LCOV_EXCL_STOP */ static void _mesh_remove_networks() { @@ -323,25 +323,21 @@ int _wifi_mesh_find_peers(wifi_mesh_h handle) return result; } +/* LCOV_EXCL_START */ static void _mesh_signal_handler(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { - /* LCOV_EXCL_START */ mesh_handle_s *h = user_data; if (NULL == h) { - /* LCOV_EXCL_START */ LOGE("user_data is null"); return; - /* LCOV_EXCL_STOP */ } if (NULL == h->event_handler) { - /* LCOV_EXCL_START */ LOGE("event_handler is null"); return; - /* LCOV_EXCL_STOP */ } LOGD("signal received = %s", signal_name); @@ -353,7 +349,7 @@ static void _mesh_signal_handler(GDBusConnection *connection, ev.data.wifi_mesh_enable = calloc(1, sizeof(wifi_mesh_enabled_event_s)); if (NULL == ev.data.wifi_mesh_enable) - LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE + LOGE("Failed to memory allocation !"); ev.data.wifi_mesh_enable->result = __convert_service_error_type(result); @@ -375,7 +371,7 @@ static void _mesh_signal_handler(GDBusConnection *connection, ev.data.connection_state = calloc(1, sizeof(wifi_mesh_connection_state_event_s)); if (NULL == ev.data.connection_state) - LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE + LOGE("Failed to memory allocation !"); g_snprintf(ev.data.connection_state->mesh_id, MAX_MESHID_LEN, "%s", mesh_id); g_snprintf(ev.data.connection_state->bssid, MAX_BSSID_LEN, "%s", bssid); ev.data.connection_state->channel = channel; @@ -391,7 +387,7 @@ static void _mesh_signal_handler(GDBusConnection *connection, wifi_mesh_event_data_s ev; ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); if (NULL == ev.data.sta_info) - LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE + LOGE("Failed to memory allocation !"); g_variant_get(parameters, "(si)", &bssid, &station_type); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); ev.data.sta_info->station_type = station_type; @@ -405,7 +401,7 @@ static void _mesh_signal_handler(GDBusConnection *connection, ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); if (NULL == ev.data.sta_info) - LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE + LOGE("Failed to memory allocation !"); g_variant_get(parameters, "(si)", &bssid, &station_type); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); ev.data.sta_info->station_type = station_type; @@ -414,6 +410,7 @@ static void _mesh_signal_handler(GDBusConnection *connection, free(ev.data.sta_info); } } +/* LCOV_EXCL_STOP */ static void _mesh_subscribe_event(wifi_mesh_h handle) { @@ -1163,6 +1160,7 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw return WIFI_MESH_ERROR_NONE; } + /* LCOV_EXCL_START */ if (WIFI_MESH_ERROR_NONE != result) return result; @@ -1191,6 +1189,7 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw } *_network = &g_joined_network; + /* LCOV_EXCL_STOP */ } else if (error) { /* LCOV_EXCL_START */ LOGE("Failed DBus call [%s]", error->message); @@ -1707,12 +1706,12 @@ int _wifi_mesh_get_stations_info(wifi_mesh_h handle, -1, NULL, &error); if (variant) { + /* LCOV_EXCL_START */ /* handle station list here */ g_variant_get(variant, "(aa{sv}i)", &iter, &result); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { struct mesh_station_info_s station; memset(&station, 0, sizeof(struct mesh_station_info_s)); - /* LCOV_EXCL_START */ station.sta_type = sta_type; while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) { if (strcasecmp(key, "bssid") == 0) { @@ -1817,11 +1816,11 @@ int _wifi_mesh_get_stations_info(wifi_mesh_h handle, } } g_variant_iter_free(iter_row); - /* LCOV_EXCL_STOP */ } g_variant_iter_free(iter); LOGD("get_saved_mesh_networks status 0x%x", result); result = __convert_service_error_type(result); + /* LCOV_EXCL_STOP */ } else if (error) { /* LCOV_EXCL_START */ LOGE("Failed DBus call [%s]", error->message); @@ -1967,9 +1966,9 @@ int _wifi_mesh_get_meshconf_info(wifi_mesh_h handle, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + /* LCOV_EXCL_START */ if (variant) { g_variant_get(variant, "(a{sv}i)", &iter, &result); - /* LCOV_EXCL_START */ struct mesh_meshconf_dump_s *meshparam = g_malloc0(sizeof(struct mesh_meshconf_dump_s)); @@ -2018,12 +2017,12 @@ int _wifi_mesh_get_meshconf_info(wifi_mesh_h handle, LOGE("GATE_ANNOUNCEMENTS=%u", meshparam->gate_announcements); } } - /* LCOV_EXCL_STOP */ g_variant_iter_free(iter); LOGD("get_meshconf_info status 0x%x", result); result = __convert_service_error_type(result); *meshconf = (wifi_mesh_meshconf_info_h) meshparam; + /* LCOV_EXCL_STOP */ } else if (error) { /* LCOV_EXCL_START */ LOGE("Failed DBus call [%s]", error->message);