From: Hwankyu Jhun Date: Wed, 25 May 2022 22:21:51 +0000 (+0900) Subject: Fix spec file for coverage measurement X-Git-Tag: accepted/tizen/unified/20220530.140715~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F275478%2F1;p=platform%2Fcore%2Fappfw%2Fappcore-agent.git Fix spec file for coverage measurement To measure code coverages automatically, a run-unittest.sh is needed. Change-Id: I00d7683e45bbb1d9b8012cdc90ee46b553747a60 Signed-off-by: Hwankyu Jhun --- diff --git a/packaging/appcore-agent.spec b/packaging/appcore-agent.spec index c478eca..a18e1fd 100644 --- a/packaging/appcore-agent.spec +++ b/packaging/appcore-agent.spec @@ -18,6 +18,10 @@ BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(vconf-internal-keys) +%if 0%{?gcov:1} +BuildRequires: lcov +%endif + %description Service Application basic @@ -46,6 +50,12 @@ Group: System/API gcov objects of a service application library %endif +%package unittests +Summary: %{name} unittests binary + +%description unittests +unittests binary + %prep %setup -q cp %{SOURCE1001} . @@ -64,23 +74,53 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` . %__make %{?_smp_mflags} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -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' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif +## To run unittest +cat << EOF > run-unittest.sh +#!/bin/bash +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/appcore-agent-test +} + +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 cd unittests LD_LIBRARY_PATH=../ ctest -V +%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 + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -110,3 +150,7 @@ LD_LIBRARY_PATH=../ ctest -V %files gcov %{_datadir}/gcov/obj/* %endif + +%files unittests +%{_bindir}/appcore-agent-test +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index c8fc391..bc193b0 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -36,3 +36,5 @@ ADD_EXECUTABLE(${TARGET_TEST} ${MOCK_SRCS} ${TEST_SRCS} ${LIB_SRCS}) TARGET_LINK_LIBRARIES(${TARGET_TEST} ${test_LDFLAGS} ${gtest_pkgs_LIBRARIES}) ADD_TEST(${TARGET_TEST} ${TARGET_TEST}) + +INSTALL(TARGETS ${TARGET_TEST} DESTINATION bin)