From 33ac6a61d9a0c148ec9540eb1c087320f6ab2f73 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Thu, 9 Jun 2022 14:17:12 +0900 Subject: [PATCH] Apply gcov automation Change-Id: I923a0c75323f1abd7f8f6b6896e2cf9f66631bc1 --- CMakeLists.txt | 5 +--- packaging/capi-network-tethering.spec | 55 +++++++++++++++++++++++++++++------ tests/CMakeLists.txt | 2 ++ 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac4e1b..05ca685 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,10 +67,7 @@ CONFIGURE_FILE( INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) ADD_SUBDIRECTORY(tools) - -IF(BUILD_GTESTS) - ADD_SUBDIRECTORY(tests) -ENDIF(BUILD_GTESTS) +ADD_SUBDIRECTORY(tests) IF(UNIX) diff --git a/packaging/capi-network-tethering.spec b/packaging/capi-network-tethering.spec index c0fc719..5bba20d 100644 --- a/packaging/capi-network-tethering.spec +++ b/packaging/capi-network-tethering.spec @@ -17,6 +17,7 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(gmock) BuildRequires: cmake %if 0%{?gcov:1} +BuildRequires: gtest-devel BuildRequires: lcov BuildRequires: tar %endif @@ -46,6 +47,12 @@ Group: Network/Testing gcov objects for coverage test %endif +%package unittests +Summary: %{name} unittests binary + +%description unittests +unittests binary + %prep %setup -q @@ -55,7 +62,6 @@ gcov objects for coverage test export CFLAGS+=" -fprofile-arcs -ftest-coverage" export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" export FFLAGS+=" -fprofile-arcs -ftest-coverage" -export LDFLAGS+=" -lgcov" %endif %if "%{?tizen_profile_name}" == "tv" @@ -63,25 +69,52 @@ export CFLAGS+=" -DTIZEN_TV_EXT" export CXXFLAGS+=" -DTIZEN_TV_EXT" %endif -%cmake -DBUILD_GTESTS=%{?gcov:1}%{!?gcov:0} -DLIB_INSTALL_DIR=%{_libdir} \ +%cmake -DLIB_INSTALL_DIR=%{_libdir} \ . make %{?_smp_mflags} %install +rm -rf %{buildroot} %make_install %if 0%{?gcov:1} -find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - -install -d -m 755 %{buildroot}%{_datadir}/gcov/obj/%{name} -tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj/%{name} +# 컴파일시 gcno 파일이 생성됨 해당 파일을 gcov.rpm 에 추가할수 있게 복사 +builddir=$(basename $PWD) +gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" +mkdir -p "$gcno_obj_dir" +find . -name '*.gcno' ! -path '*/tools/*' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/tethering-gtest +} + +teardown() { + echo "teardown start" +} + +main() { + setup + test_main + teardown +} + +main "\$*" +EOF + +mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name} +install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/ + %check %if 0%{?gcov:1} tests/tethering-gtest -%endif - -%if 0%{?gcov:1} lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info genhtml %{name}.info -o out --legend --show-details %endif @@ -108,5 +141,9 @@ genhtml %{name}.info -o out --legend --show-details %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/%{name}/* +%{_datadir}/gcov/obj/* %endif + +%files unittests +%{_bindir}/tethering-gtest +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8fb86c8..246cd9b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,3 +34,5 @@ SET_TARGET_PROPERTIES(${TETHERING_GTEST} PROPERTIES --wrap=vconf_get_int,\ --wrap=vconf_set_int,\ --wrap=vconf_get_str") + +INSTALL(TARGETS ${TETHERING_GTEST} DESTINATION bin/) -- 2.7.4