Add the coverage measurement for muse 34/231834/7
authorYoungHun Kim <yh8004.kim@samsung.com>
Fri, 24 Apr 2020 10:19:36 +0000 (19:19 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Mon, 27 Apr 2020 06:52:10 +0000 (15:52 +0900)
Change-Id: Ia8a2594517622e7685d5fcfbb283466f73e97f30

client/src/muse_client.c
core/include/muse_core.h
core/include/muse_core_internal.h
core/src/muse_core.c
packaging/mused.spec
server/src/muse_server_ipc.c
server/src/muse_server_private.c

index 7ebcaba..636f1a9 100644 (file)
@@ -252,6 +252,10 @@ int muse_client_close(int sock_fd)
 
        g_mutex_unlock(&mc_mutex);
 
+#ifdef MUSE_GCOV_TEST
+       muse_core_gcov_flush();
+#endif
+
        return MM_ERROR_NONE;
 }
 
index 57ddf50..b4ecc24 100644 (file)
@@ -85,6 +85,10 @@ typedef struct muse_external_storage_info {
        const char *path;
 } muse_external_storage_info_t;
 
+#ifdef MUSE_GCOV_TEST
+extern void __gcov_flush(void);
+#endif
+
 int muse_core_connection_close(int sock_fd);
 int muse_core_set_nonblocking(int fd, bool value);
 int muse_core_set_socket_timeout(int sock_fd, int timeout_sec);
index 6d17c68..6671840 100644 (file)
@@ -184,6 +184,12 @@ typedef struct muse_msg_info {
        int size;
 } muse_msg_info_t;
 
+
+#ifdef MUSE_GCOV_TEST
+void muse_core_gcov_flush(void);
+void muse_core_setenv(const char *name, const char *value, int replace);
+#endif
+
 bool muse_core_msg_recv_len(int fd, char *buf, int msg_len);
 void muse_core_update_fd_state(int fd);
 void muse_core_get_cur_time(char *time_buf);
index 1ff438f..f330c21 100644 (file)
@@ -46,6 +46,19 @@ static void _muse_msg_json_factory_args(json_object *jobj, va_list ap);
 static json_object *_muse_msg_json_find_obj(json_object *jobj, const char *find_key);
 static gboolean _muse_msg_json_get_obj_value(json_object *obj, muse_core_msg_type_e m_type, void *data);
 
+#ifdef MUSE_GCOV_TEST
+void muse_core_gcov_flush(void)
+{
+       __gcov_flush();
+}
+
+void muse_core_setenv(const char *name, const char *value, int replace)
+{
+       setenv(name, value, replace);
+}
+
+#endif
+
 static int _muse_get_valid_fd_count(int *fds)
 {
        int idx;
index fb28b90..3696a87 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.3.110
+Version:    0.3.111
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -70,6 +70,12 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE -D_GNU_SOURCE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE -D_GNU_SOURCE"
 %endif
 
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage -DMUSE_GCOV_TEST "
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DMUSE_GCOV_TEST "
+export LDFLAGS+=" -lgcov "
+%endif
+
 %if ("%{_vd_cfg_product_type}" == "AUDIO") || ("%{_vd_cfg_product_type}" == "TV") || ("%{_vd_cfg_product_type}" == "LFD") || ("%{_vd_cfg_product_type}" == "HTV") || ("%{_vd_cfg_product_type}" == "AV") || ("%{_vd_cfg_product_type}" == "IWB") || ("%{_vd_cfg_product_type}" == "WALL")
 export CFLAGS+=" -DMUSE_REGISTER_VIP -DMUSE_USE_LWIPC -DMUSE_TTRACE_LOG"
 %cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DLIBDIR=%{_libdir} -DTZ_SYS_DATA=%TZ_SYS_DATA -DMUSE_REGISTER_VIP=1 -DMUSE_TTRACE_LOG=1 -DMUSE_USE_LWIPC=1
index 37b1d27..c845f3d 100644 (file)
@@ -312,6 +312,11 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
        _ms_ipc_module_cleanup(m);
 
        LOGD("worker exit");
+
+#ifdef MUSE_GCOV_TEST
+       muse_core_gcov_flush();
+#endif
+
        g_thread_exit(NULL);
 
        return NULL;
index c5d3d42..697a893 100644 (file)
@@ -902,6 +902,10 @@ void ms_init(char **argv)
        trace_end();
 #endif
 
+#ifdef MUSE_GCOV_TEST
+       muse_core_setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
        LOGD("Leave");
 }