From ad620adbf8e46d9cd3b9e3f3687f0994a51c03ed Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Thu, 9 Jun 2022 14:39:26 +0900 Subject: [PATCH] Apply gcov automation Change-Id: I956470ed08a0c4283e0983d8c8b7860f6f490601 --- CMakeLists.txt | 4 +-- packaging/capi-network-connection.spec | 57 +++++++++++++++++++++++++++------- unittest/CMakeLists.txt | 2 +- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05cbe34..bc2e7c1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,12 +76,10 @@ CONFIGURE_FILE( INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig) ADD_SUBDIRECTORY(test) -IF(BUILD_GCOV) IF(DEBUG_GCOV) ADD_DEFINITIONS(-DDEBUG_GCOV) ENDIF(DEBUG_GCOV) - ADD_SUBDIRECTORY(unittest) -ENDIF(BUILD_GCOV) +ADD_SUBDIRECTORY(unittest) IF(UNIX) diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index f308107..edbac22 100755 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -12,8 +12,8 @@ BuildRequires: pkgconfig(network) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) -%if 0%{?gcov:1} BuildRequires: gtest-devel +%if 0%{?gcov:1} BuildRequires: lcov %endif @@ -40,6 +40,12 @@ Group: Network/Testing gcov objects for coverage test %endif +%package unittests +Summary: %{name} unittests binary + +%description unittests +unittests binary + %prep %setup -q @@ -49,14 +55,12 @@ 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 export CFLAGS+=' -Wno-unused-local-typedefs' MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ - -DLIB_PATH=%{_lib} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \ - -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \ + -DLIB_PATH=%{_lib} -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \ %if 0%{?model_build_feature_network_dsds} == 1 -DTIZEN_DUALSIM_ENABLE=1 \ %endif @@ -64,19 +68,44 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ make %{?_smp_mflags} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' ! -iname "*mptcp*" -exec cp '{}' gcov-obj ';' -%endif - %install %make_install %if 0%{?gcov:1} -mkdir -p %{buildroot}%{_datadir}/gcov/obj/%{name} -install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} +builddir=$(basename $PWD) +gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" +mkdir -p "$gcno_obj_dir" +find . -name '*.gcno' ! -iname '*mptcp*' ! -path '*/test/*' -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/tct-connection-core +} + +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} pushd unittest @@ -102,5 +131,9 @@ popd %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/%{name}/* +%{_datadir}/gcov/obj/* %endif + +%files unittests +%{_bindir}/tct-connection-core +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 53ee932..e42d254 100755 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -43,4 +43,4 @@ TARGET_LINK_LIBRARIES(${UNITTEST_NAME} capi-network-connection ) -# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR}) +INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION bin/) -- 2.7.4