Apply gcov automation 49/289049/1 accepted/tizen/unified/20230302.131102
authorWootak Jung <wootak.jung@samsung.com>
Tue, 28 Feb 2023 03:07:37 +0000 (12:07 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 28 Feb 2023 03:07:37 +0000 (12:07 +0900)
Change-Id: I4261b30f08f275fcc7ec8aba2fc6e6e3cf285690
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
packaging/capi-network-bluetooth.spec
tests/unittest/CMakeLists.txt

index 489425c..17e95ad 100644 (file)
@@ -44,6 +44,20 @@ Requires: %{name} = %{version}-%{release}
 %description test
 This package is C-API test application.
 
+%if 0%{?gcov:1}
+%package gcov
+Summary: %{name} gcov data
+
+%description gcov
+gcov objects
+%endif
+
+%package unittests
+Summary: %{name} unittests binary
+
+%description unittests
+unittests binary
+
 %prep
 %setup -q
 cp %{SOURCE1001} %{SOURCE1002} .
@@ -53,7 +67,6 @@ cp %{SOURCE1001} %{SOURCE1002} .
 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
 %endif
 
 #export CFLAGS="$CFLAGS -DTIZEN_FEATURE_AUDIO_HF_DISABLE -DTIZEN_FEATURE_OTP_SUPPORT"
@@ -92,23 +105,47 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
 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}
-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' -exec cp --parents '{}' "$gcno_obj_dir" ';'
 %endif
 
 #mkdir -p %{buildroot}%{_unitdir}
 #install -m 0644 tests/test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}/bt_infinite_spp_test_server.service
 
+cat << EOF > run-unittest.sh
+#!/bin/bash
+setup() {
+    echo "setup start"
+}
+
+test_main() {
+    echo "test_main start"
+    LD_PRELOAD=/usr/lib/libbluetooth-mock.so /usr/bin/tct-bluetooth-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
 LD_LIBRARY_PATH=. LD_PRELOAD=tests/unittest/libbluetooth-mock.so tests/unittest/tct-bluetooth-core
 %if 0%{?gcov:1}
@@ -124,7 +161,6 @@ genhtml %{name}.info -o out --legend --show-details
 %manifest %{name}.manifest
 %license LICENSE
 %{_libdir}/libcapi-network-bluetooth.so.*
-%exclude %{_datadir}/gcov/obj/*
 
 %files test
 %manifest %{name}.manifest
@@ -149,3 +185,13 @@ genhtml %{name}.info -o out --legend --show-details
 
 %{_libdir}/pkgconfig/capi-network-bluetooth.pc
 %{_libdir}/libcapi-network-bluetooth.so
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+%endif
+
+%files unittests
+%{_libdir}/libbluetooth-mock.so
+%{_bindir}/tct-bluetooth-core
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
index cc88149..ea66ae9 100644 (file)
@@ -13,9 +13,12 @@ SET(BLUETOOTH_MOCK "bluetooth-mock")
 SET(BLUETOOTH_MOCK_SRCS
        mock/bluetooth-mock.c)
 ADD_LIBRARY(${BLUETOOTH_MOCK} SHARED ${BLUETOOTH_MOCK_SRCS})
+INSTALL(TARGETS ${BLUETOOTH_MOCK} DESTINATION ${LIB_INSTALL_DIR})
 
 ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TEST_SRCS})
 TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
     gtest
     ${fw_name}
 )
+
+INSTALL(TARGETS ${UNITTEST_NAME} DESTINATION bin)