Modify gcov installation directory 36/285836/1
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 21 Dec 2022 04:54:04 +0000 (13:54 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 21 Dec 2022 04:54:04 +0000 (13:54 +0900)
Change-Id: Ie342a3058bf6b4c125bfa7f2d0b29df027e6ee96
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
CMakeLists.txt
packaging/appcore-watch.spec
test/unit_tests/CMakeLists.txt

index 395eb1b2eb8dd1e2fe0b626fadada828c4742408..5b12274dad1902fd3d68b753a3b9c2e4c555e1d9 100644 (file)
@@ -20,7 +20,7 @@ SET(TARGET_WATCH_BASE "appcore-watch-base")
 SET(TARGET_WATCH_APPLICATION "appcore-watch")
 
 ENABLE_TESTING()
-SET(TARGET_WATCH_APPLICATION_UNIT_TEST "appcore-watch-unit-test")
+SET(TARGET_WATCH_APPLICATION_UNIT_TEST "appcore-watch-unittest")
 
 INCLUDE(FindPkgConfig)
 INCLUDE(ApplyPkgConfig)
index 25349aec3d2b8940205238f8a6c543e50f4dd349..6f1f25609b00e91e436571b72ef15f3d6e82740b 100644 (file)
@@ -73,6 +73,11 @@ Requires:   %{name} = %{version}-%{release}
 %description -n appcore-watch-base-devel
 Watch base library (development files)
 
+%package unittests
+Summary:    %{name} unittests binary
+
+%description unittests
+unittests binary
 
 %prep
 %setup -q
@@ -96,24 +101,49 @@ export CFLAGS+=" -DEFL_BETA_API_SUPPORT "
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake -DFULLVER=%{version} \
        -DMAJORVER=${MAJORVER} \
+       -DBIN_INSTALL_DIR:PATH=%{_bindir} \
        .
 
 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
 
 %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/appcore-watch-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}%{_libdir}/pkgconfig
 cp capi-appfw-watch-application.pc %{buildroot}%{_libdir}/pkgconfig
 
@@ -124,7 +154,7 @@ ctest -V
 lcov -c --ignore-errors graph --no-external -q -d . -o appcore-watch.info
 genhtml appcore-watch.info -o appcore-watch.out
 zip -r appcore-watch.zip appcore-watch.out
-install -m 0644 appcore-watch.zip %{buildroot}%{_datadir}/gcov/
+install -m 0644 appcore-watch.zip %{buildroot}%{_datadir}/gcov/obj/
 %endif
 
 %post -p /sbin/ldconfig
@@ -163,7 +193,11 @@ install -m 0644 appcore-watch.zip %{buildroot}%{_datadir}/gcov/
 %{_libdir}/pkgconfig/appcore-watch-base.pc
 %{_libdir}/libappcore-watch-base.so
 
+%files unittests
+%{_bindir}/appcore-watch-unittest
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
+
 %if 0%{?gcov:1}
 %files gcov
-%{_datadir}/gcov/*
+%{_datadir}/gcov/obj/*
 %endif
index 0821456ce335bc6ed934e6bb8491d60d4dcd5b85..5325ac677df4ab97f20376260abf080e0f805b60 100644 (file)
@@ -26,3 +26,5 @@ ADD_TEST(
   NAME ${TARGET_WATCH_APPLICATION_UNIT_TEST}
   COMMAND ${TARGET_WATCH_APPLICATION_UNIT_TEST}
 )
+
+INSTALL (PROGRAMS ${TARGET_WATCH_APPLICATION_UNIT_TEST} DESTINATION ${BIN_INSTALL_DIR})