From 90a0226aa98f03c10daba70bb89e3b9faec37a27 Mon Sep 17 00:00:00 2001 From: Gichan Jang Date: Fri, 20 Dec 2024 11:08:54 +0900 Subject: [PATCH] [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 Change to merge the initialized info and test result info. Signed-off-by: Gichan Jang --- packaging/nnstreamer-edge.spec | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packaging/nnstreamer-edge.spec b/packaging/nnstreamer-edge.spec index 42c0477..b7ef8f5 100644 --- a/packaging/nnstreamer-edge.spec +++ b/packaging/nnstreamer-edge.spec @@ -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 -- 2.34.1