From: Jihoon Jung Date: Sun, 13 Oct 2024 23:43:50 +0000 (+0900) Subject: Fix build error for gcov X-Git-Tag: accepted/tizen/unified/20241017.114711^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_toolchain;p=platform%2Fcore%2Fapi%2Fmtp.git Fix build error for gcov - Revert auto coverage related content Change-Id: I7a9b732049f99bf3467aff62f3091818cfbf8531 Signed-off-by: Jihoon Jung --- diff --git a/packaging/capi-network-mtp.spec b/packaging/capi-network-mtp.spec index faada0a..622b46c 100644 --- a/packaging/capi-network-mtp.spec +++ b/packaging/capi-network-mtp.spec @@ -16,7 +16,6 @@ BuildRequires: pkgconfig(sqlite3) Buildrequires: pkgconfig(libtzplatform-config) BuildRequires: python Buildrequires: python-xml -BuildRequires: python3-setuptools %if 0%{?gcov:1} BuildRequires: gtest-devel @@ -35,28 +34,13 @@ Requires: %{name} = %{version}-%{release} %description devel -%if 0%{?gcov:1} -%package gcov -Summary: %{name} gcov data - -%description gcov -gcov objects - -%package unittests -Summary: %{name} unittests binary - -%description unittests -unittests binary -%endif - %prep %setup -q %build + %if 0%{?gcov:1} -export CFLAGS+=" -fprofile-arcs -ftest-coverage" -export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" -export FFLAGS+=" -fprofile-arcs -ftest-coverage" +export LDFLAGS+=" -lgcov" %endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` @@ -69,51 +53,21 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ make %{?jobs:-j%jobs} +%if 0%{?gcov:1} +mkdir -p gcov-obj +find . -name '*.gcno' -exec cp '{}' gcov-obj ';' +%endif + %install rm -rf %{buildroot} %make_install -%if 0%{?gcov:1} -builddir=$(basename $PWD) -gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" -mkdir -p "$gcno_obj_dir" -find . -name '*.gcno' -exec cp '{}' "$gcno_obj_dir" ';' - -cat << EOF > run-unittest.sh -#!/bin/bash -setup() { - echo "setup start" -} - -test_main() { - echo "test_main start" - LD_PRELOAD=/usr/lib/libmtp-mock.so /usr/bin/tct-mtp-core -} - -teardown() { - echo "teardown start" -} - -main() { - setup - test_main - teardown -} - -main "$@" -EOF - -mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name} -install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name} -%endif - %check %if 0%{?gcov:1} -LD_LIBRARY_PATH=. LD_PRELOAD=unittest/libmtp-mock.so unittest/tct-mtp-core -lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.total.info -lcov --remove %{name}.total.info -o %{name}.info '*unittest/*' '*mtp_gdbuslib.c' -genhtml %{name}.info -o out --legend --show-details +pushd unittest +./run_coverage.sh +popd %endif %post -p /sbin/ldconfig @@ -131,13 +85,3 @@ genhtml %{name}.info -o out --legend --show-details %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-network-mtp.so %{_bindir}/mtp_unit_test - -%if 0%{?gcov:1} -%files gcov -%{_datadir}/gcov/obj/* - -%files unittests -%{_libdir}/libmtp-mock.so -%{_bindir}/tct-mtp-core -%{_bindir}/tizen-unittests/%{name}/run-unittest.sh -%endif diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index e02df30..47e421d 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -42,7 +42,6 @@ ADD_LIBRARY(${MTP_MOCK} SHARED ${MTP_MOCK_SRCS}) SET_TARGET_PROPERTIES(${MTP_MOCK} PROPERTIES COMPILE_FLAGS ${MTP_MOCK_CFLAGS} ) -INSTALL(TARGETS ${MTP_MOCK} DESTINATION ${LIB_INSTALL_LIB}) ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TC_SOURCES} ) TARGET_LINK_LIBRARIES(${UNITTEST_NAME} @@ -53,4 +52,4 @@ TARGET_LINK_LIBRARIES(${UNITTEST_NAME} capi-network-mtp ) -INSTALL(TARGETS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR}) +# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR}) diff --git a/unittest/run_coverage.sh b/unittest/run_coverage.sh new file mode 100755 index 0000000..6b97bf3 --- /dev/null +++ b/unittest/run_coverage.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=..:.:$LD_LIBRARY_PATH +pushd ../ +RootDir=$PWD +popd + +unitTestFile=tct-mtp-core +if [ ! -x "./$unitTestFile" ] +then + echo "$unitTestFile file does not exist!" + exit -1 +fi + +LD_PRELOAD=./libmtp-mock.so ./$unitTestFile + +CMakeDir=${RootDir}/CMakeFiles/capi-network-mtp.dir/src +CoverageDir=${RootDir}/coverage + +pushd $CMakeDir + + for obj in `ls *.o` + do + gcov -b -c $obj + done + + if [ -f /usr/bin/lcov ] + then + lcov -c -d . --exclude "/home/abuild/rpmbuild/BUILD/capi-network-mtp-1.3.19/src/mtp_gdbuslib.c" -o cov.info +# lcov -c -d . -o cov.info + genhtml cov.info -o ${CoverageDir} + echo "Coverage test result created! [${CoverageDir}]" + else + echo "lcov does not exist!" + fi +popd