Apply gcov automation 44/276944/1 accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix accepted/tizen_8.0_unified tizen_7.0 tizen_7.0_hotfix tizen_8.0 accepted/tizen/7.0/unified/20221110.060152 accepted/tizen/7.0/unified/hotfix/20221116.104902 accepted/tizen/8.0/unified/20231005.092917 accepted/tizen/unified/20220704.212937 submit/tizen/20220630.042443 tizen_7.0_m2_release tizen_8.0_m2_release
authorjiung-yu <jiung.yu@samsung.com>
Tue, 28 Jun 2022 06:38:31 +0000 (15:38 +0900)
committerjiung-yu <jiung.yu@samsung.com>
Tue, 28 Jun 2022 06:40:13 +0000 (15:40 +0900)
Change-Id: I19b229b1251e9b046fb8ac11dc7444a8b41c3972
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
packaging/capi-network-uwb.spec

index 477ccb9..15399dd 100644 (file)
@@ -18,6 +18,7 @@ Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
 %if 0%{?gcov:1}
+BuildRequires:  gtest-devel
 BuildRequires:  lcov
 BuildRequires:  tar
 %endif
@@ -44,13 +45,19 @@ Test Application for UWB Framework
 
 %if 0%{?gcov:1}
 %package gcov
-Summary:    A UWB gcov Tool
+Summary:    ${name} gcov data
 Group:      Network & Connectivity/Development
 
 %description gcov
 UWB gcov objects
 %endif
 
+%package unittests
+Summary:    %{name} unittests binary
+
+%description unittests
+unittests binary
+
 %prep
 %setup -q
 chmod 644 %{SOURCE0}
@@ -66,7 +73,6 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 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}'`
@@ -86,11 +92,39 @@ make %{?_smp_mflags}
 %make_install
 
 %if 0%{?gcov:1}
-find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T -
-install -d -m 755 %{buildroot}%{_datadir}/gcov/obj/%{name}
-tar xf %{name}-gcov.tar -C %{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/capi-network-uwb-gtest
+}
+
+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}
 LD_PRELOAD=./tests/libuwb-mock.so tests/%{name}-gtest
@@ -122,5 +156,9 @@ genhtml %{name}.info -o out --legend --show-details
 
 %if 0%{?gcov:1}
 %files gcov
-%{_datadir}/gcov/obj/%{name}/*
+%{_datadir}/gcov/obj*
 %endif
+
+%files unittests
+%{_bindir}/capi-network-uwb-gtest
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh