Apply gcov automation
[platform/core/api/vine.git] / packaging / capi-network-vine.spec
index 0ea5551..9401778 100755 (executable)
@@ -3,7 +3,7 @@
 %bcond_without use_glib_event_loop
 Name:    capi-network-vine
 Summary: An service discovery framework
-Version: 1.2.8
+Version: 1.2.9
 Release: 0
 Group:   Network & Connectivity/API
 License: Apache-2.0
@@ -37,6 +37,7 @@ BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gmock)
 
 %if 0%{?gcov:1}
+BuildRequires: gtest-devel
 BuildRequires: lcov
 %endif
 
@@ -63,12 +64,18 @@ Test Application for Vine
 
 %if 0%{?gcov:1}
 %package gcov
-Summary:       Coverage Data of %{name}
+Summary: Coverage Data of %{name}
 
 %description gcov
 The %{name}-gcov package contains gcov objects
 %endif
 
+%package unittests
+Summary: %{name} unittests binary
+
+%description unittests
+unittests binary
+
 %prep
 %setup -q
 chmod 644 %{SOURCE0}
@@ -85,7 +92,6 @@ export ARCH=i586
 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
 %endif
 
 %cmake . \
@@ -123,11 +129,6 @@ export LDFLAGS+=" -lgcov"
 
 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
@@ -137,14 +138,43 @@ rm -rf %{buildroot}%{_libdir}/cmake/libwebsockets
 %endif
 
 %if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find . -name '*.gcno' ! -path '*/verifier/*' ! -path '*/vine-test/*' ! -path '*/tool/*' -exec cp --parents '{}' "$gcno_obj_dir" ';'
 %endif
 
-%check
-LD_LIBRARY_PATH=%{buildroot}%{_libdir} ./tests/unittest/vine-unittest
+cat << EOF > run-unittest.sh
+#!/bin/sh
+setup() {
+    echo "setup start"
+}
+
+test_main() {
+    echo "test_main start"
+    /usr/bin/vine-unittest
+}
 
+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_LIBRARY_PATH=%{buildroot}%{_libdir} tests/unittest/vine-unittest
 lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
 genhtml %{name}.info -o out --legend --show-details
 %endif
@@ -183,3 +213,7 @@ genhtml %{name}.info -o out --legend --show-details
 %files gcov
 %{_datadir}/gcov/obj/*
 %endif
+
+%files unittests
+%{_bindir}/vine-unittest
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh