Apply gcov automation 61/276061/2 accepted/tizen/unified/20220614.134810 submit/tizen/20220610.003743
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 9 Jun 2022 05:39:26 +0000 (14:39 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 9 Jun 2022 05:46:36 +0000 (14:46 +0900)
Change-Id: I956470ed08a0c4283e0983d8c8b7860f6f490601

CMakeLists.txt
packaging/capi-network-connection.spec
unittest/CMakeLists.txt

index 05cbe34..bc2e7c1 100755 (executable)
@@ -76,12 +76,10 @@ CONFIGURE_FILE(
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
 
 ADD_SUBDIRECTORY(test)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
 
 ADD_SUBDIRECTORY(test)
-IF(BUILD_GCOV)
 IF(DEBUG_GCOV)
        ADD_DEFINITIONS(-DDEBUG_GCOV)
 ENDIF(DEBUG_GCOV)
 IF(DEBUG_GCOV)
        ADD_DEFINITIONS(-DDEBUG_GCOV)
 ENDIF(DEBUG_GCOV)
-       ADD_SUBDIRECTORY(unittest)
-ENDIF(BUILD_GCOV)
+ADD_SUBDIRECTORY(unittest)
 
 IF(UNIX)
 
 
 IF(UNIX)
 
index f308107..edbac22 100755 (executable)
@@ -12,8 +12,8 @@ BuildRequires:        pkgconfig(network)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(capi-system-info)
-%if 0%{?gcov:1}
 BuildRequires:  gtest-devel
 BuildRequires:  gtest-devel
+%if 0%{?gcov:1}
 BuildRequires: lcov
 %endif
 
 BuildRequires: lcov
 %endif
 
@@ -40,6 +40,12 @@ Group:               Network/Testing
 gcov objects for coverage test
 %endif
 
 gcov objects for coverage test
 %endif
 
+%package unittests
+Summary:    %{name} unittests binary
+
+%description unittests
+unittests binary
+
 %prep
 %setup -q
 
 %prep
 %setup -q
 
@@ -49,14 +55,12 @@ gcov objects for coverage test
 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
 %endif
 
 export CFLAGS+=' -Wno-unused-local-typedefs'
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
 %endif
 
 export CFLAGS+=' -Wno-unused-local-typedefs'
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-       -DLIB_PATH=%{_lib} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
-       -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \
+       -DLIB_PATH=%{_lib} -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \
 %if 0%{?model_build_feature_network_dsds} == 1
        -DTIZEN_DUALSIM_ENABLE=1 \
 %endif
 %if 0%{?model_build_feature_network_dsds} == 1
        -DTIZEN_DUALSIM_ENABLE=1 \
 %endif
@@ -64,19 +68,44 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
 
 make %{?_smp_mflags}
 
 
 make %{?_smp_mflags}
 
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' ! -iname "*mptcp*" -exec cp '{}' gcov-obj ';'
-%endif
-
 %install
 %make_install
 
 %if 0%{?gcov:1}
 %install
 %make_install
 
 %if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj/%{name}
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name}
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find . -name '*.gcno' ! -iname '*mptcp*' ! -path '*/test/*' -exec cp --parents '{}' "$gcno_obj_dir" ';'
 %endif
 
 %endif
 
+cat << EOF > run-unittest.sh
+#!/bin/sh
+setup() {
+    echo "setup start"
+}
+
+test_main() {
+    echo "test_main start"
+    /usr/bin/tct-connection-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}/
+
+
 %check
 %if 0%{?gcov:1}
 pushd unittest
 %check
 %if 0%{?gcov:1}
 pushd unittest
@@ -102,5 +131,9 @@ popd
 
 %if 0%{?gcov:1}
 %files gcov
 
 %if 0%{?gcov:1}
 %files gcov
-%{_datadir}/gcov/obj/%{name}/*
+%{_datadir}/gcov/obj/*
 %endif
 %endif
+
+%files unittests
+%{_bindir}/tct-connection-core
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
index 53ee932..e42d254 100755 (executable)
@@ -43,4 +43,4 @@ TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
     capi-network-connection
 )
 
     capi-network-connection
 )
 
-# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
+INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION bin/)