From d2c301fce64ed4981a0b203eb5d93886442eba52 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 26 May 2022 07:43:06 +0900 Subject: [PATCH] Fix spec file for coverage measurement To measure code coverages automatically, a run-unittest.sh is needed. Change-Id: I2882a61191a206b3c4fd2f37837f8d7e9ba4f5c9 Signed-off-by: Hwankyu Jhun --- packaging/bundle.spec | 75 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/packaging/bundle.spec b/packaging/bundle.spec index 8f7599c..c6ea371 100644 --- a/packaging/bundle.spec +++ b/packaging/bundle.spec @@ -96,28 +96,77 @@ export LDFLAGS+=" -lgcov" %cmake -DVERSION=%{version} . %__make %{?_smp_mflags} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -exec cp '{}' gcov-obj ';' -%endif - %check ctest --verbose %{?_smp_mflags} %if 0%{?gcov:1} -lcov -c --ignore-errors graph --no-external -q -d . -o bundle.info -genhtml bundle.info -o bundle.out -zip -r bundle.zip bundle.out bundle.info -install -m 0644 bundle.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 %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/bundle_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}/ + +cat << EOF > run-parcel-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/parcel_unittests +} + +teardown() { + echo "teardown start" +} + +main() { + setup + test_main + teardown +} + +main "\$*" +EOF + +mkdir -p %{buildroot}%{_bindir}/tizen-unittests/parcel +install -m 0755 run-parcel-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/parcel/run-unittest.sh + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -151,13 +200,14 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} ################################################# %files unittests %{_bindir}/bundle_unittests +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh ################################################# # bundle-gcov ################################################# %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/* +%{_datadir}/gcov/obj/* %endif ################################################# @@ -176,3 +226,4 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} %files -n parcel-unittests %{_bindir}/parcel_unittests +%{_bindir}/tizen-unittests/parcel/run-unittest.sh -- 2.7.4