Fix build error for gcov 26/319026/1 accepted/tizen_unified_toolchain accepted/tizen/9.0/unified/20241030.235239 accepted/tizen/unified/20241017.114711 accepted/tizen/unified/toolchain/20241022.122723 accepted/tizen/unified/toolchain/20241022.123120 accepted/tizen/unified/x/20241017.170420 accepted/tizen/unified/x/asan/20241022.113612 tizen_9.0_m2_release
authorJihoon Jung <jh8801.jung@samsung.com>
Sun, 13 Oct 2024 23:43:50 +0000 (08:43 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Sun, 13 Oct 2024 23:45:24 +0000 (08:45 +0900)
- Revert auto coverage related content

Change-Id: I7a9b732049f99bf3467aff62f3091818cfbf8531
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
packaging/capi-network-mtp.spec
unittest/CMakeLists.txt
unittest/run_coverage.sh [new file with mode: 0755]

index faada0a0ae095c492764d2f8cb3a6088d24d9211..622b46ce4a7fe8445d48ca64cc3d68e9b124f09f 100644 (file)
@@ -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
index e02df30236cc29e942c772510f7cb9bab2696a2f..47e421d926516c187cefd85a65cb3458653afe2e 100644 (file)
@@ -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 (executable)
index 0000000..6b97bf3
--- /dev/null
@@ -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