%make_install
popd
+%if 0%{?testcoverage}
+# Capture initial zero coverage data. This will be merged with actual coverage data later.
+# This is to prevent null gcda file error if the test is not performed (in case of gcov package generation mode).
+pushd build
+rm -r CMakeFiles
+lcov -i -c -o unittest_base.info -d . -b $(pwd) --ignore-errors mismatch
+popd
+%endif # testcoverage
+
%if 0%{?unit_test}
LD_LIBRARY_PATH=./src bash %{test_script} ./tests/unittest_nnstreamer-edge
LD_LIBRARY_PATH=./src:./tests bash %{test_script} ./tests/unittest_nnstreamer-edge-custom
VCS=`cat ${RPM_SOURCE_DIR}/nnstreamer-edge.spec | grep "^VCS:" | sed "s|VCS:\\W*\\(.*\\)|\\1|"`
# Create human readable coverage report web page.
-# Create null gcda files if gcov didn't create it because there is completely no unit test for them.
-find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
-# Remove gcda for meaningless file (CMake's autogenerated)
-find . -name "CMakeCCompilerId*.gcda" -delete
-find . -name "CMakeCXXCompilerId*.gcda" -delete
# Generate report and exclude test files.
# Set different lcov options for Tizen/lcov versions.
+pushd build
%if 0%{tizen_version_major} >= 9
-lcov -t 'NNStreamer-edge unittest coverage' -o unittest.info -c -d . -b $(pwd) --no-external --ignore-errors mismatch
-lcov -r unittest.info "*/tests/*" -o unittest-filtered.info --ignore-errors graph,unused
+lcov -t 'NNStreamer-edge unittest coverage' -o unittest_test.info -c -d . -b %{builddir} --no-external --ignore-errors mismatch,empty
+lcov -a unittest_base.info -a unittest_test.info -o unittest_total.info --ignore-errors mismatch,empty
+lcov -r unittest_total.info "*/tests/*" -o unittest-filtered.info --ignore-errors graph,unused
%else
lcov -t 'NNStreamer-edge unittest coverage' -o unittest.info -c -d . -b $(pwd) --no-external
lcov -r unittest.info "*/tests/*" -o unittest-filtered.info
mkdir -p %{buildroot}%{_datadir}/nnstreamer-edge/unittest/
cp -r result %{buildroot}%{_datadir}/nnstreamer-edge/unittest/
+popd
%endif # testcoverage
%endif # unittest