From 1db32d22b5e541324aebe35c987527069237a5e7 Mon Sep 17 00:00:00 2001 From: Gichan Jang Date: Thu, 7 Nov 2024 14:46:33 +0900 Subject: [gcov] Fix invalid gcda files 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 error. Change to merge the initialized info and test result info. Signed-off-by: Gichan Jang Signed-off-by: Sangjung Woo --- packaging/machine-learning-api.spec | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packaging/machine-learning-api.spec b/packaging/machine-learning-api.spec index d473da3..b6cf21d 100644 --- a/packaging/machine-learning-api.spec +++ b/packaging/machine-learning-api.spec @@ -414,6 +414,14 @@ ninja -C build %{?_smp_mflags} export MLAPI_SOURCE_ROOT_PATH=$(pwd) export MLAPI_BUILD_ROOT_PATH=$(pwd)/build +%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 +lcov -i -c -o unittest_base.info -d . -b $(pwd) --ignore-errors mismatch +popd +%endif # testcoverage + # Run test # If gcov package generation is enabled, pass the test from GBS. %if 0%{?unit_test} && !0%{?gcov} @@ -451,19 +459,15 @@ TZ='Asia/Seoul'; export TZ VCS=`cat ${RPM_SOURCE_DIR}/machine-learning-api.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 build # Set different lcov options for Tizen/lcov versions. %if 0%{tizen_version_major} >= 9 -lcov -t 'ML API 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 API 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 API 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 -- cgit v1.2.3