From c4a092e35fdb044a523cb3b54df9aa82008a06b3 Mon Sep 17 00:00:00 2001 From: sinikang Date: Thu, 19 Jul 2018 16:31:09 +0900 Subject: [PATCH] Change test package name Change-Id: Ida1ae7df3fa901f036fcf352bfe71f304b14c3ef --- CMakeLists.txt | 24 +++++++++++++++++++----- gtest/CMakeLists.txt | 26 ++++++++++++++++++++++++++ haltest/tcore_hal_tc.cpp => gtest/unittest.cpp | 3 +-- haltest/CMakeLists.txt | 21 --------------------- packaging/libtcore.spec | 25 ++++++++++++++++--------- 5 files changed, 62 insertions(+), 37 deletions(-) create mode 100644 gtest/CMakeLists.txt rename haltest/tcore_hal_tc.cpp => gtest/unittest.cpp (97%) delete mode 100644 haltest/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 72243c6..ac14d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,11 @@ INCLUDE_DIRECTORIES( SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}/include ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -O2 -Wall -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-variable") -# -fvisibility option should be "default" to call internal functions +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions for gtest SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default -fPIC -Wno-unused-function -fprofile-arcs -ftest-coverage") ADD_DEFINITIONS("-DTCORE_HAL_TEST") +ENDIF (BUILD_GTESTS) ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG") ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TCORE\"") @@ -73,7 +75,13 @@ SET(SRCS # library build ADD_LIBRARY(tcore SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(tcore ${pkgs_LDFLAGS} -ldl -lgcov) + +IF (BUILD_GTESTS) + TARGET_LINK_LIBRARIES(tcore ${pkgs_LDFLAGS} -ldl -lgcov) +ELSE (BUILD_GTESTS) + TARGET_LINK_LIBRARIES(tcore ${pkgs_LDFLAGS}) +ENDIF (BUILD_GTESTS) + SET_TARGET_PROPERTIES(tcore PROPERTIES VERSION 0.0.0 SOVERSION 0 OUTPUT_NAME tcore) # pkgconfig file @@ -85,11 +93,17 @@ CONFIGURE_FILE(tcore.pc.in tcore.pc @ONLY) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/tcore) INSTALL(TARGETS tcore LIBRARY DESTINATION ${LIBDIR}) + # adding for HAL test support -INSTALL(TARGETS tcore DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries) +IF (BUILD_GTESTS) + INSTALL(TARGETS tcore DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tcore.pc DESTINATION ${LIBDIR}/pkgconfig) -#HAL test pkg build -ADD_SUBDIRECTORY(haltest) +#gtest pkg build +IF (BUILD_GTESTS) + ADD_SUBDIRECTORY(gtest) +ENDIF (BUILD_GTESTS) #ADD_SUBDIRECTORY(unit-test) diff --git a/gtest/CMakeLists.txt b/gtest/CMakeLists.txt new file mode 100644 index 0000000..a8a0ed1 --- /dev/null +++ b/gtest/CMakeLists.txt @@ -0,0 +1,26 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gtest-libtcore C CXX) + +SET(GTEST_TEST "gtest-libtcore") +ADD_DEFINITIONS("-DUSE_DLOG") + +INCLUDE(FindPkgConfig) +pkg_check_modules(gtest_pkgs REQUIRED glib-2.0 gmock dlog) + +FOREACH(flag ${gtest_pkgs_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +SET(GTEST_SRCS unittest.cpp) +ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_SRCS} ) +TARGET_LINK_LIBRARIES(${GTEST_TEST} + ${gtest_pkgs_LDFLAGS} + -L${CMAKE_SOURCE_DIR} tcore + ) + +INSTALL(TARGETS ${GTEST_TEST} DESTINATION /usr/bin) diff --git a/haltest/tcore_hal_tc.cpp b/gtest/unittest.cpp similarity index 97% rename from haltest/tcore_hal_tc.cpp rename to gtest/unittest.cpp index 92e1a8d..5725401 100644 --- a/haltest/tcore_hal_tc.cpp +++ b/gtest/unittest.cpp @@ -25,8 +25,6 @@ #include #include -static Server *tcore_running_server; - using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; using ::testing::Test; @@ -43,6 +41,7 @@ void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const TEST(LIBTCORE_COMMON, tcore_server_get_modems_count) { gint modem_count = 1; + //Server *tcore_running_server = NULL; //modem_count = tcore_server_get_modems_count(tcore_running_server); ASSERT_TRUE(modem_count > 0); } diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt deleted file mode 100644 index 37a3fe4..0000000 --- a/haltest/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(tcore_hal_tc C CXX) - -SET(HAL_TEST "tcore_hal_tc") -ADD_DEFINITIONS("-DUSE_DLOG") - -INCLUDE(FindPkgConfig) -pkg_check_modules(hal_test_pkgs REQUIRED glib-2.0 gmock dlog) - -FOREACH(flag ${hal_test_pkgs_CFLAGS}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") -ENDFOREACH(flag) - -SET(HAL_TEST_SRCS tcore_hal_tc.cpp) -ADD_EXECUTABLE(${HAL_TEST} ${HAL_TEST_SRCS} ) -TARGET_LINK_LIBRARIES(${HAL_TEST} - ${hal_test_pkgs_LDFLAGS} - -L${CMAKE_SOURCE_DIR} tcore - ) - -INSTALL(TARGETS ${HAL_TEST} DESTINATION /usr/bin) diff --git a/packaging/libtcore.spec b/packaging/libtcore.spec index ca65543..5934f5b 100644 --- a/packaging/libtcore.spec +++ b/packaging/libtcore.spec @@ -1,6 +1,6 @@ %define major 0 %define minor 3 -%define patchlevel 25 +%define patchlevel 26 Name: libtcore Version: %{major}.%{minor}.%{patchlevel} @@ -13,8 +13,6 @@ BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(gmock) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -29,11 +27,17 @@ Requires: %{name} = %{version} %description devel Telephony-core library (Development) -%package haltests -Summary: libtcore extension for HAL test +%if 0%{?gtest:1} +%package test +Summary: Test package for libtcore +Group: TO_BE/FILLED +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(gmock) Requires: %{name} = %{version}-%{release} -%description haltests -libtcore extension for HAL test. + +%description test +This package is a test application for libtcore +%endif %prep %setup -q @@ -46,6 +50,7 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ %else -DARCH_EMUL=1 \ %endif + -DBUILD_GTESTS=%{?gtest:1}%{!?gtest:0} make %{?_smp_mflags} @@ -68,7 +73,9 @@ make %{?_smp_mflags} %{_libdir}/pkgconfig/tcore.pc %{_libdir}/*.so -%files haltests +%if 0%{?gtest:1} +%files test %manifest libtcore.manifest -%{_bindir}/tcore_hal_tc +%{_bindir}/gtest-libtcore %{_libdir}/*.so +%endif -- 2.7.4