[gcov] Fix invalid gcda files
authorGichan Jang <gichan2.jang@samsung.com>
Fri, 20 Dec 2024 02:08:54 +0000 (11:08 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 20 Dec 2024 06:06:49 +0000 (15:06 +0900)
Previously, a null file was created to cover cases where tests were not performed.
From the latest gcov version (gcov14), this is treated as an invalid gcda file, resulting in an
Change to merge the initialized info and test result info.

Signed-off-by: Gichan Jang <gichan2.jang@samsung.com>
packaging/nnstreamer-edge.spec

index 42c04776b3c13da9f458b65541639bc1afda1529..b7ef8f5df9ee7e8e06a61c5e9c53958474e298cd 100644 (file)
@@ -124,6 +124,15 @@ pushd build
 %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
@@ -141,16 +150,13 @@ TZ='Asia/Seoul'; export TZ
 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
@@ -160,6 +166,7 @@ genhtml -o result unittest-filtered.info -t "NNStreamer-edge %{version}-%{releas
 
 mkdir -p %{buildroot}%{_datadir}/nnstreamer-edge/unittest/
 cp -r result %{buildroot}%{_datadir}/nnstreamer-edge/unittest/
+popd
 %endif # testcoverage
 %endif # unittest