From: jusung Date: Tue, 31 May 2022 05:04:17 +0000 (+0900) Subject: Fix spec file for coverage measurement X-Git-Tag: submit/tizen/20220531.054818~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F275728%2F1;p=platform%2Fcore%2Fappfw%2Fmessage-port.git Fix spec file for coverage measurement To measure code coverages automatically, a run-unittest.sh is needed. Change-Id: I769e57aeff0239ac4d7d178a314efc1ba32a94bc Signed-off-by: jusung --- diff --git a/packaging/message-port.spec b/packaging/message-port.spec index 0cbbb5f..80f0b55 100644 --- a/packaging/message-port.spec +++ b/packaging/message-port.spec @@ -48,6 +48,12 @@ Group: Application Framework/Libraries gcov objects of a message port library %endif +%package unittests +Summary: %{name} unittests binary + +%description unittests +unittests binary + %prep %setup -q cp %{SOURCE1001} . @@ -65,19 +71,16 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` # Call make instruction with smp support %__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/%{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 %check @@ -85,12 +88,40 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}%{_libdir}/ ctest -V %if 0%{?gcov:1} -lcov -c --ignore-errors graph --no-external -q -d . -o message-port.info -genhtml message-port.info -o message-port.out -zip -r message-port.zip message-port.out -install -m 0644 message-port.zip %{buildroot}%{_datadir}/gcov/ +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 +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" + %{_aulresdir}/tpk/install.sh +} + +test_main() { + echo "test_main start" + /usr/bin/message-port-unit-tests +} + +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}/ + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -107,6 +138,10 @@ install -m 0644 message-port.zip %{buildroot}%{_datadir}/gcov/ %{_libdir}/pkgconfig/*.pc %{_libdir}/lib%{name}.so +%files unittests +%attr(0755,root,root) %{_bindir}/message-port-unit-test +%attr(0755,root,root) %{_bindir}/tizen-unittests/%{name}/run-unittest.sh + %if 0%{?gcov:1} %files gcov %{_datadir}/gcov/* diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 9d7a190..c524504 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -21,6 +21,8 @@ TARGET_LINK_LIBRARIES(${TARGET_MESSAGE_PORT_UNIT_TEST} PUBLIC ${TARGET_MESSAGE_P SET_TARGET_PROPERTIES(${TARGET_MESSAGE_PORT_UNIT_TEST} PROPERTIES COMPILE_FLAGS "-fPIE") SET_TARGET_PROPERTIES(${TARGET_MESSAGE_PORT_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie") +INSTALL(TARGETS ${TARGET_MESSAGE_PORT_UNIT_TEST} DESTINATION bin) + ADD_TEST( NAME ${TARGET_MESSAGE_PORT_UNIT_TEST} COMMAND ${TARGET_MESSAGE_PORT_UNIT_TEST}