Add option to execute unittest in building package
[platform/core/uifw/capi-ui-sticker.git] / packaging / capi-ui-sticker.spec
index e833da7..86bd5c3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-ui-sticker
 Summary:    Sticker client library and daemon
-Version:    0.1.68
+Version:    1.2.11
 Release:    1
 Group:      Graphics & UI Framework/Input
 License:    Apache-2.0
@@ -85,7 +85,6 @@ Group:      Graphics & UI Framework/Input
 Sticker client library and daemon (gcov)
 %endif
 
-%if %{defined _ctest_enable}
 %package unittests
 Summary:    Sticker tests
 Group:      Development/Libraries
@@ -93,7 +92,6 @@ Requires:   %{name} = %{version}-%{release}
 
 %description unittests
 GTest for sticker
-%endif
 
 %prep
 %setup -q -n %{name}-%{version}
@@ -117,23 +115,52 @@ export FFLAGS+=" -DTIZEN_DEBUG_ENABLE -fvisibility=hidden"
 %endif
          -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \
          -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_USER_SHARE=%TZ_USER_SHARE \
-         -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
-%if %{defined _ctest_enable}
-    -DTEST_ENABLE="%{_ctest_enable}" \
-%else
-    -DTEST_ENABLE="false" \
-%endif
+         -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES
 
 make %{?jobs:-j%jobs}
 
-%if 0%{?gcov:1}
-find . -name '*.gcno' | tar cf %{name}-gcov.tar -T -
-%endif
 
 %install
 rm -rf %{buildroot}
 %make_install
 
+%if 0%{?gcov:1}
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find ./server/ -name '*.gcno' -exec rm {} \;
+find ./tests/ -name '*.gcno' -not -path "*/client/*" -exec rm {} \;
+find . -name '*_dbus*.gcno' -exec rm {} \;
+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-ui-sticker-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}
+
 mkdir -p %{buildroot}/%{TZ_SYS_ETC}/dump.d/module.d
 cp -af dump/sticker_log_dump.sh %{buildroot}/%{TZ_SYS_ETC}/dump.d/module.d
 
@@ -146,11 +173,6 @@ install -m 0644 %SOURCE2 %{buildroot}%{_datadir}/dbus-1/system-services/org.tize
 mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
 install -m 0644 %SOURCE3 %{buildroot}%{_sysconfdir}/dbus-1/system.d/capi-ui-sticker.conf
 
-%if 0%{?gcov:1}
-install -d -m 755 %{buildroot}%{_datadir}/gcov/obj
-tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
-%endif
-
 %if 0%{?sec_product_feature_profile_wearable}
 %define tizen_sign 1
 %define tizen_sign_base %{TZ_SYS_RO_APP}/%{_companion_app_name}
@@ -160,13 +182,14 @@ tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
 %endif
 
 %check
-%if "%{_ctest_enable}" == "true"
+%if 0%{?gcov:1}
+%if 0%{?run_unittest:1}
 ctest --output-on-failure %{?_smp_mflags}
+lcov -c --ignore-errors graph --no-external -q -d . -o capi-ui-sticker.info
+genhtml capi-ui-sticker.info -o capi-ui-sticker.out
+zip -r capi-ui-sticker.zip capi-ui-sticker.out capi-ui-sticker.info
+install -m 0644 capi-ui-sticker.zip %{buildroot}%{_datadir}/gcov
 %endif
-
-%if 0%{?gcov:1}
-lcov -c --ignore-errors graph --no-external -q -d . -o gcov.info
-genhtml gcov.info
 %endif
 
 %post
@@ -214,10 +237,10 @@ chsmack -a "User::App::Shared" /opt/usr/share/sticker-data
 %{TZ_SYS_RO_APP}/%{_companion_app_name}/*
 %endif
 
-%if %{defined _ctest_enable}
 %files unittests
-%{_bindir}/*
-%endif
+%license LICENSE
+%{_bindir}/capi-ui-sticker-unittest
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
 
 %if 0%{?gcov:1}
 %files gcov