From: InHong Han Date: Tue, 15 Dec 2020 10:10:58 +0000 (+0900) Subject: Add a build option for enabling or disabling unittest X-Git-Tag: accepted/tizen/unified/20201220.221656~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F249674%2F1;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Add a build option for enabling or disabling unittest --define "_ctest_enable true" Change-Id: I113abf03964403ccdd2a4643edb11d8c12d40103 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8aa49..916ce15 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,11 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") SET(VERSION 0.2.56) +IF("${TEST_ENABLE}" STREQUAL "true") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_ENABLE=${TEST_ENABLE}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_ENABLE=${TEST_ENABLE}") +ENDIF() + ADD_DEFINITIONS("-Werror") ## Include common directory ## @@ -48,14 +53,13 @@ ADD_SUBDIRECTORY(receiver) ENDIF() ## Test -IF(NOT DEFINED MINIMUM_BUILD) +IF("${TEST_ENABLE}" STREQUAL "true") ENABLE_TESTING() SET(UTC_STICKER sticker_unittests) ADD_TEST(NAME ${UTC_STICKER} COMMAND ${UTC_STICKER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) - ADD_SUBDIRECTORY(tests) -ENDIF(NOT DEFINED MINIMUM_BUILD) +ENDIF() ## config ## INSTALL(FILES ${CMAKE_SOURCE_DIR}/capi-ui-sticker.info DESTINATION ${TZ_SYS_RO_SHARE}/parser-plugins) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 1acfa91..c1203a1 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -85,6 +85,7 @@ Group: Graphics & UI Framework/Input Sticker client library and daemon (gcov) %endif +%if %{defined _ctest_enable} %package unittests Summary: Sticker tests Group: Development/Libraries @@ -92,6 +93,7 @@ Requires: %{name} = %{version}-%{release} %description unittests GTest for sticker +%endif %prep %setup -q -n %{name}-%{version} @@ -115,7 +117,13 @@ export FFLAGS+=" -DTIZEN_DEBUG_ENABLE -fvisibility=hidden" %endif -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_USER_SHARE=%TZ_USER_SHARE \ - -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES + -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \ +%if %{defined _ctest_enable} + -DTEST_ENABLE="%{_ctest_enable}" \ +%else + -DTEST_ENABLE="false" \ +%endif + make %{?jobs:-j%jobs} %if 0%{?gcov:1} @@ -152,7 +160,10 @@ tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj %endif %check +%if "%{_ctest_enable}" == "true" ctest --output-on-failure %{?_smp_mflags} +%endif + %if 0%{?gcov:1} lcov -c --ignore-errors graph --no-external -q -d . -o gcov.info genhtml gcov.info @@ -203,8 +214,10 @@ chsmack -a "User::App::Shared" /opt/usr/share/sticker-data %{TZ_SYS_RO_APP}/%{_companion_app_name}/* %endif +%if %{defined _ctest_enable} %files unittests %{_bindir}/* +%endif %if 0%{?gcov:1} %files gcov diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 032be6a..eea11f2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,19 +16,13 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/mock) AUX_SOURCE_DIRECTORY(src SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../common STICKER_COMMON_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client/src STICKER_CLIENT_SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../consumer STICKER_CONSUMER_SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../provider STICKER_PROVIDER_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock MOCK_SRCS) ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"") ADD_EXECUTABLE(${UTC_STICKER} - ${STICKER_COMMON_SOURCES} ${STICKER_CLIENT_SOURCES} - ${STICKER_CONSUMER_SOURCES} - ${STICKER_PROVIDER_SOURCES} ${MOCK_SRCS} ${SOURCES} )