Fix spec file for coverage measurement 91/275591/1
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 27 May 2022 00:18:48 +0000 (09:18 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 27 May 2022 00:32:03 +0000 (09:32 +0900)
To measure code coverages automatically, a run-unittest.sh is needed

Change-Id: I4f6e5882c4146351692f2605afc6f4e572f10469
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
packaging/tpk-manifest-handlers.spec
test/unit_tests/CMakeLists.txt

index dd5da07..4e995c3 100644 (file)
@@ -29,6 +29,12 @@ Requires:   boost-devel
 %description devel
 This package contains necessaary files for manifest-parser development
 
+%package unittests
+Summary:    %{name} unittests binary
+
+%description unittests
+unittest binary
+
 %prep
 %setup -q
 cp %{SOURCE100} .
@@ -56,29 +62,55 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
 make %{?_smp_mflags}
 
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' ! -path './gcov-obj/*' -exec cp '{}' gcov-obj ';'
-%endif
-
 %check
 export LD_LIBRARY_PATH=../../src/tpk_manifest_handlers
 ctest -V
 %if 0%{?gcov:1}
-lcov -c --ignore-errors graph --no-external -q -d . -o tpk-manifest-handlers.info
-genhtml tpk-manifest-handlers.info -o tpk-manifest-handlers.out
-zip -r tpk-manifest-handlers.zip tpk-manifest-handlers.out
-install -m 0644 tpk-manifest-handlers.zip %{buildroot}%{_datadir}/gcov/
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
 %endif
 
 %install
 %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"
+    CUR_DIR=$(pwd)
+    cd /usr/bin
+    /usr/bin/tpk-manifest-handlers-unit-test
+    cd $CUR_DIR
+}
+
+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}/
+
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
@@ -110,5 +142,10 @@ Simple string key-val dictionary ADT gcov objects
 %if 0%{?gcov:1}
 %files gcov
 %defattr(-,root,root,-)
-%{_datadir}/gcov/*
+%{_datadir}/gcov/obj/*
 %endif
+
+%files unittests
+%{_bindir}/tpk-manifest-handlers-unit-test
+%{_bindir}/test_samples
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
index 4742a42..b66a42e 100644 (file)
@@ -24,3 +24,6 @@ ADD_TEST(
   NAME ${TARGET_TPK_MANIFEST_HANDLERS_UNIT_TEST}
   COMMAND ${TARGET_TPK_MANIFEST_HANDLERS_UNIT_TEST}
 )
+
+INSTALL(TARGETS ${TARGET_TPK_MANIFEST_HANDLERS_UNIT_TEST} DESTINATION bin)
+INSTALL(DIRECTORY test_samples/ DESTINATION bin/test_samples)