Skip to content

Commit 40e92d7

Browse files
gichan-jangjaeyun-jung
authored andcommitted
[gcov] Fix error invalid gcda files
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>
1 parent 47a7437 commit 40e92d7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packaging/mlops-agent.spec

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ meson compile -C %{builddir} %{?_smp_mflags}
178178
export MLAGENT_SOURCE_ROOT_PATH=$(pwd)
179179
export MLAGENT_BUILD_ROOT_PATH=$(pwd)/%{builddir}
180180

181-
# Run test
181+
%if 0%{?testcoverage}
182+
# Capture initial zero coverage data. This will be merged with actual coverage data later.
183+
# This is to prevent null gcda file error if the test is not performed (in case of gcov package generation mode).
184+
pushd %{builddir}
185+
lcov -i -c -o unittest_base.info -d . -b $(pwd) --ignore-errors mismatch
186+
popd
187+
%endif # testcoverage
188+
182189
# If gcov package generation is enabled, pass the test from GBS.
183190
%if 0%{?unit_test} && !0%{?gcov}
184191
bash %{test_script} ./tests/daemon/unittest_ml_agent
@@ -200,19 +207,15 @@ TZ='Asia/Seoul'; export TZ
200207
VCS=`cat ${RPM_SOURCE_DIR}/mlops-agent.spec | grep "^VCS:" | sed "s|VCS:\\W*\\(.*\\)|\\1|"`
201208

202209
# Create human readable coverage report web page.
203-
# Create null gcda files if gcov didn't create it because there is completely no unit test for them.
204-
find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
205-
# Remove gcda for meaningless file (CMake's autogenerated)
206-
find . -name "CMakeCCompilerId*.gcda" -delete
207-
find . -name "CMakeCXXCompilerId*.gcda" -delete
208210
# Generate report and exclude files which are generated by gdbus-codegen and external files in /usr/*.
209211
# TODO: the --no-external option is removed to include machine-learning-agent related source files.
210212
# Restore this option when there is proper way to include those source files.
211213
pushd %{builddir}
212214
# Set different lcov options for Tizen/lcov versions.
213215
%if 0%{tizen_version_major} >= 9
214-
lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd) --ignore-errors mismatch
215-
lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info --ignore-errors graph,unused
216+
lcov -t 'ML-Agent unittest coverage' -o unittest_test.info -c -d . -b $(pwd) --ignore-errors mismatch,empty
217+
lcov -a unittest_base.info -a unittest_test.info -o unittest_total.info --ignore-errors empty
218+
lcov -r unittest_total.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info --ignore-errors graph,unused
216219
%else
217220
lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd)
218221
lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info

0 commit comments

Comments
 (0)