Skip to content

Commit

Permalink
[gcov] Fix error invalid gcda files
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gichan-jang committed Nov 6, 2024
1 parent 47a7437 commit 9ee5a74
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packaging/mlops-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9ee5a74

Please sign in to comment.