From: hyunuk.tak Date: Fri, 10 Jun 2022 05:46:41 +0000 (+0900) Subject: Apply gcov automation X-Git-Tag: submit/tizen/20220610.074345^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb34750c6253bfc3c1cd80bf18eaa2abec95d46f;p=platform%2Fcore%2Fapi%2Fsmart-traffic-control.git Apply gcov automation Change-Id: Id89e6ec19cef3642f10e2ad69abed0c20188890f Signed-off-by: hyunuk.tak --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d7f274..f36e1a5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,9 +65,7 @@ ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(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) diff --git a/packaging/capi-network-stc.spec b/packaging/capi-network-stc.spec index c5e871c..4caaa52 100755 --- a/packaging/capi-network-stc.spec +++ b/packaging/capi-network-stc.spec @@ -12,8 +12,8 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) -%if 0%{?gcov:1} BuildRequires: gtest-devel +%if 0%{?gcov:1} BuildRequires: lcov %endif @@ -46,6 +46,12 @@ Group: Network/Testing gcov objects for coverage test %endif +%package unittests +Summary: %{name} unittests binary + +%description unittests +unittests binary + %prep %setup -q chmod 644 %{SOURCE0} @@ -61,7 +67,6 @@ export ARCH=i586 export CFLAGS+=" -fprofile-arcs -ftest-coverage" export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" export FFLAGS+=" -fprofile-arcs -ftest-coverage" -export LDFLAGS+=" -lgcov" %endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` @@ -74,7 +79,6 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -DLOCAL_STATE_DIR:PATH=%{_localstatedir} \ -DDATA_ROOT_DIR:PATH=%{_datadir} \ -DFULLVER=%{version} \ - -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \ -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \ -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} @@ -88,10 +92,39 @@ find . -name '*.gcno' -exec cp '{}' gcov-obj ';' rm -rf %{buildroot} %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' ! -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-stc-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 @@ -123,3 +156,7 @@ popd %files gcov %{_datadir}/gcov/obj/* %endif + +%files unittests +%{_bindir}/tct-stc-core +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index db4c811..cc438fc 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -42,4 +42,4 @@ TARGET_LINK_LIBRARIES(${UNITTEST_NAME} capi-network-stc ) -# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR}) +INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION bin/)