Requires(postun): /sbin/ldconfig
%if 0%{?gcov:1}
+BuildRequires: gtest-devel
BuildRequires: lcov
BuildRequires: tar
%endif
%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}
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}'`
%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
%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