From d11cf301e902384869e674a518613942d391caa5 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 16 May 2023 21:00:19 +0900 Subject: [PATCH] Apply gcov automation Change-Id: I7cfb9b4cdbfb1e32e9cc942fcc7cbd4fa10eca15 Signed-off-by: Jaehyun Kim --- packaging/capi-web-url-download.spec | 41 ++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 2 ++ 2 files changed, 43 insertions(+) diff --git a/packaging/capi-web-url-download.spec b/packaging/capi-web-url-download.spec index 8883b5b..d822a7a 100755 --- a/packaging/capi-web-url-download.spec +++ b/packaging/capi-web-url-download.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(gmock) BuildRequires: cmake %if 0%{?gcov:1} +BuildRequires: gtest-devel BuildRequires: lcov BuildRequires: tar %endif @@ -37,6 +38,11 @@ Group: Network/Testing gcov objects for coverage test %endif +%package unittests +Summary: %{name} unittests binary +%description unittests +unittests binary + %prep %setup -q @@ -53,6 +59,8 @@ export LDFLAGS+=" -lgcov" make %{?jobs:-j%jobs} %install +rm -rf %{buildroot} + %make_install %if 0%{?gcov:1} @@ -62,6 +70,34 @@ mkdir -p "$gcno_obj_dir" find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + LD_LIBRARY_PATH=%{_bindir}/tizen-unittests/%{name} /usr/bin/url-download-gtest +} + +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}/ +cp tests/libdp-interface-mock.so %{buildroot}%{_bindir}/tizen-unittests/%{name}/ + %check %if 0%{?gcov:1} export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:tests @@ -95,3 +131,8 @@ genhtml %{name}.info -o out --legend --show-details %files gcov %{_datadir}/gcov/obj/* %endif + +%files unittests +%{_bindir}/url-download-gtest +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh +%{_bindir}/tizen-unittests/%{name}/*.so \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b81949b..d6761e8 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,3 +27,5 @@ SET_TARGET_PROPERTIES(${DOWNLOAD_GTEST} PROPERTIES COMPILE_FLAGS "-fPIE" LINK_FLAGS "-Wl,\ --wrap=system_info_get_platform_bool") + +INSTALL(TARGETS ${DOWNLOAD_GTEST} DESTINATION bin/) \ No newline at end of file -- 2.7.4