Add gcov build options 22/243522/1
authorhyunho <hhstark.kang@samsung.com>
Tue, 8 Sep 2020 01:49:38 +0000 (10:49 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 8 Sep 2020 01:49:38 +0000 (10:49 +0900)
Enable coverage check option

--define 'gcov 1'

Change-Id: Ibb2920d0a4e94f3ddb5b2bceafeecc3d13cecbb7
Signed-off-by: hyunho <hhstark.kang@samsung.com>
CMakeLists.txt
packaging/libscreen_connector.spec
screen_connector_remote_surface_evas/remote_surface_evas.cc
screen_connector_remote_surface_evas/remote_surface_evas_implementation.h
unittest/CMakeLists.txt

index b2292a2..33d392a 100644 (file)
@@ -1,5 +1,6 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
+ENABLE_TESTING()
 ADD_SUBDIRECTORY(screen_connector_launcher_service)
 ADD_SUBDIRECTORY(screen_connector_launcher_service_evas)
 ADD_SUBDIRECTORY(screen_connector_shared_widget_launch)
index 8cfb896..e780641 100644 (file)
@@ -26,6 +26,11 @@ BuildRequires: pkgconfig(gmock)
 BuildRequires: pkgconfig(tzsh-launcher-service)
 BuildRequires: pkgconfig(libtbm)
 
+%if 0%{?gcov:1}
+BuildRequires:  lcov
+BuildRequires:  zip
+%endif
+
 %description
 API for creating a new instance of the widget and managing its life-cycle.
 
@@ -37,6 +42,15 @@ Requires: %{name} = %{version}-%{release}
 %description devel
 Header and package configuration files for the widget viewer development
 
+%if 0%{?gcov:1}
+%package gcov
+Summary:  Screen Connector(gcov)
+Group:    Application Framework/Libraries
+
+%description gcov
+gcov objects of a screen-connector library
+%endif
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -49,17 +63,48 @@ cp %{SOURCE1007} .
 cp %{SOURCE1008} .
 
 %build
-
-export CFLAGS+=" -DEFL_BETA_API_SUPPORT "
-export CXXFLAGS+=" -DEFL_BETA_API_SUPPORT "
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+export CFLAGS+=" -DEFL_BETA_API_SUPPORT"
+export CXXFLAGS+=" -DEFL_BETA_API_SUPPORT"
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DTZ_SYS_SHARE=/usr/share -DMAJORVER=${MAJORVER} -DFULLVER=%{version}
 make %{?jobs:-j%jobs}
 
+%if 0%{?gcov:1}
+mkdir -p gcov-obj
+find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+%endif
+
 %install
 rm -rf %{buildroot}
 %make_install
 
+%if 0%{?gcov:1}
+mkdir -p %{buildroot}%{_datadir}/gcov/obj
+install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+%endif
+
+%check
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}/usr/lib/
+ctest -V
+
+%if 0%{?gcov:1}
+lcov -c --ignore-errors graph --no-external -q -d . -o screen-connector.info
+genhtml screen-connector.info -o screen-connector.out
+zip -r screen-connector.zip screen-connector.out
+install -m 0644 screen-connector.zip %{buildroot}%{_datadir}/gcov/
+%endif
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/*
+%endif
 
 #################################################
 # libscreen_connector_watcher
index 32e1880..fa91694 100644 (file)
@@ -58,6 +58,7 @@ RemoteSurfaceEvas::RemoteSurfaceEvas(RemoteSurfaceEvas&&) noexcept = default;
 RemoteSurfaceEvas& RemoteSurfaceEvas::operator=(
     RemoteSurfaceEvas&&) noexcept = default;
 
+RemoteSurfaceEvas::Impl::~Impl() = default;
 RemoteSurfaceEvas::Impl::Impl(RemoteSurfaceEvas* parent,
     std::shared_ptr<EvasObject> viewerWin, bool mock)
     : ImageEventListener((RemoteSurface*)parent),
index 064f715..d926a46 100644 (file)
@@ -31,7 +31,7 @@ namespace screen_connector {
 
 class RemoteSurfaceEvas::Impl : public ImageEventListener {
  public:
-  virtual ~Impl() = default;
+  virtual ~Impl();
 
  private:
   Impl(RemoteSurfaceEvas* parent,
index 3af7e51..bc7fbca 100644 (file)
@@ -25,6 +25,11 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        ${SOURCES}
 )
 
+ADD_TEST(
+  NAME gtest-screen-connector
+  COMMAND gtest-screen-connector
+)
+
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest-screen-connector_LDFLAGS} screen_connector_watcher)
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)