Adjust coverage measure 17/245617/2
authorSeungha Son <seungha.son@samsung.com>
Tue, 13 Oct 2020 08:01:29 +0000 (17:01 +0900)
committerSeungha Son <seungha.son@samsung.com>
Thu, 22 Oct 2020 07:09:25 +0000 (16:09 +0900)
 When building with the "gcov on" option,
 It can check the coverage result in the build log.

Change-Id: Id9a05454342a720aedb58052b7035264d957e778
Signed-off-by: Seungha Son <seungha.son@samsung.com>
CMakeLists.txt
packaging/ttrace.spec
src/ttrace.c

index 349621f11f2b493b1681826d14238c81ca893be8..fd6944db8617f5938dbfc71d5259a60c3d4d2b07 100755 (executable)
@@ -49,9 +49,14 @@ FOREACH(flag ${pkg_ttrace_CFLAGS})
        SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} ${flag}")
 ENDFOREACH(flag)
 
+IF("${COVERAGE}" STREQUAL "on")
+       ADD_DEFINITIONS("-DTTRACE_COVERAGE")
+ENDIF()
+
 ADD_LIBRARY(${TTRACE} SHARED ${SRCS_ttrace}
                              src/trace.c
                              )
+
 SET_TARGET_PROPERTIES(${TTRACE} PROPERTIES SOVERSION ${MAJORVER})
 SET_TARGET_PROPERTIES(${TTRACE} PROPERTIES VERSION ${FULLVER})
 SET_TARGET_PROPERTIES(${TTRACE} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_common})
index ecb09130db0753186a6d38b0c9dc9567ad0b8987..a698f93e0b2f08440f251b946bf7340b663ec5c8 100644 (file)
@@ -17,6 +17,13 @@ BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(gmock)
 BuildRequires: cmake
 
+%if 0%{?gcov:1}
+BuildRequires: lcov
+%define TTRACE_COVERAGE on
+%else
+%define TTRACE_COVERAGE off
+%endif
+
 %define keepstatic 1
 
 # tizen_profile_name is for optional features that are not built in Tizen Public OBS.
@@ -78,7 +85,8 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
       -DTTRACE_PROFILE=%{TTRACE_PROFILE} -DTTRACE_TIZEN_VERSION_MAJOR=%{TTRACE_TIZEN_VERSION_MAJOR} \
       -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
-      -DATRACE_VERSION=%{ATRACE_VERSION} -DATRACE_HELPER_VERSION=%{ATRACE_HELPER_VERSION}
+      -DATRACE_VERSION=%{ATRACE_VERSION} -DATRACE_HELPER_VERSION=%{ATRACE_HELPER_VERSION} \
+      -DCOVERAGE=%{TTRACE_COVERAGE}
 make %{?jobs:-j%jobs}
 
 %if 0%{?gcov:1}
@@ -88,6 +96,10 @@ find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
 
 %check
 (cd test && LD_LIBRARY_PATH=../ ctest -V)
+%if 0%{?gcov:1}
+lcov -c --ignore-errors graph --no-external -q -d . -o ttrace.info
+genhtml ttrace.info -o ttrace.out
+%endif
 
 %install
 rm -rf %{buildroot}
index 89e8509bce67c065a11a6500464249db5d63f747..9db9cbb1d58caa7798aa64d35a6f693385d255a0 100755 (executable)
@@ -102,8 +102,8 @@ static uint64_t traceInit()
                if (g_trace_handle_fd < 0) {
                        TTRACE_LOG("Fail to open trace file: %s(%d)", strerror(errno), errno);
                        /*
-                        * If ftrace debugfs is not mounted, ttrace does not call traceInit() anymore. 
-                        * we should decide how to handle if file permission is not given properly. keep try? or Nerver try agin? 
+                        * If ftrace debugfs is not mounted, ttrace does not call traceInit() anymore.
+                        * we should decide how to handle if file permission is not given properly. keep try? or Nerver try agin?
                        */
                        if (errno == ENOENT)
                                g_trace_handle_fd = TRACE_FILE_NOT_EXIST;
@@ -119,6 +119,10 @@ static uint64_t traceInit()
 
 static inline uint64_t isTagEnabled(uint64_t cur_tag)
 {
+#ifdef TTRACE_COVERAGE
+       return 1;
+#endif
+
        if (g_trace_handle_fd == TRACE_FILE_NOT_EXIST)
                return 0;
        /* if no tag is enabled, trace all tags. */