[gcov] Fix error invalid gcda files accepted/tizen_9.0_unified tizen_9.0 accepted/tizen/9.0/unified/20241114.015946
authorGichan Jang <gichan2.jang@samsung.com>
Wed, 6 Nov 2024 08:59:36 +0000 (17:59 +0900)
committerSangjung Woo <again4you@gmail.com>
Tue, 12 Nov 2024 05:18:51 +0000 (14:18 +0900)
Previously, a null file was created to cover cases where tests were not performed.
From the latest gcov version, this is treated as an invalid gcda file, resulting in an error.
Change to merge the initialized info and test result info.

Signed-off-by: Gichan Jang <gichan2.jang@samsung.com>
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
packaging/mlops-agent.spec

index dba7d9c3410b757d0f00a5ab807eb39fdcfaaf11..121bbf45ef89d392be95792e1aac7b883a9efa79 100644 (file)
@@ -178,7 +178,14 @@ meson compile -C %{builddir} %{?_smp_mflags}
 export MLAGENT_SOURCE_ROOT_PATH=$(pwd)
 export MLAGENT_BUILD_ROOT_PATH=$(pwd)/%{builddir}
 
-# Run test
+%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 %{builddir}
+lcov -i -c -o unittest_base.info -d . -b $(pwd) --ignore-errors mismatch
+popd
+%endif # testcoverage
+
 # If gcov package generation is enabled, pass the test from GBS.
 %if 0%{?unit_test} && !0%{?gcov}
 bash %{test_script} ./tests/daemon/unittest_ml_agent
@@ -200,19 +207,15 @@ TZ='Asia/Seoul'; export TZ
 VCS=`cat ${RPM_SOURCE_DIR}/mlops-agent.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 files which are generated by gdbus-codegen and external files in /usr/*.
 # TODO: the --no-external option is removed to include machine-learning-agent related source files.
 # Restore this option when there is proper way to include those source files.
 pushd %{builddir}
 # Set different lcov options for Tizen/lcov versions.
 %if 0%{tizen_version_major} >= 9
-lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd) --ignore-errors mismatch
-lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info --ignore-errors graph,unused
+lcov -t 'ML-Agent unittest coverage' -o unittest_test.info -c -d . -b $(pwd) --ignore-errors mismatch,empty
+lcov -a unittest_base.info -a unittest_test.info -o unittest_total.info --ignore-errors empty
+lcov -r unittest_total.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info --ignore-errors graph,unused
 %else
 lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd)
 lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info