From ccfeb7899f47c60d18d7412ded3cd352d052fd34 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 26 May 2022 10:34:32 +0900 Subject: [PATCH] Fix spec file for coverage measurement To measure code coverages automatically, a run-unittest.sh is needed. Change-Id: I298bc4d70010af80024374f49e8d5a8682b480e5 Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 57 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index b63021e..73d5c75 100644 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -45,12 +45,12 @@ RPC Port library (Development) package. ################################################# # rpc-port-unittests ################################################# -%package -n rpc-port-unittests +%package unittests Summary: GTest for rpc-port Group: Development/Libraries Requires: %{name} -%description -n rpc-port-unittests +%description unittests GTest for rpc-port ################################################# @@ -82,19 +82,13 @@ 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 - %check export LD_LIBRARY_PATH="../../src" ctest -V %{?_smp_mflags} + %if 0%{?gcov:1} -lcov -c --ignore-errors graph --no-external -q -d . -o rpc-port.info -genhtml rpc-port.info -o rpc-port.out -zip -r rpc-port.zip rpc-port.out rpc-port.info -install -m 0644 rpc-port.zip %{buildroot}%{_datadir}/gcov/ +lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info +genhtml %{name}.info -o out --legend --show-details %endif %install @@ -103,19 +97,43 @@ 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 +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/rpc-port_unittests +} + +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 -%post -n rpc-port-unittests -%if 0%{?gcov:1} -%{_bindir}/rpc-port_unittests -%endif - %files %manifest %{name}.manifest %attr(0644,root,root) %{_libdir}/lib%{name}.so.* @@ -131,8 +149,9 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} ################################################# # rpc-port-unittests ################################################# -%files -n rpc-port-unittests +%files unittests %{_bindir}/rpc-port_unittests +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh ################################################# # rpc-port-gcov -- 2.7.4