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\"")
# 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
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)
--- /dev/null
+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)
#include <tcore.h>
#include <server.h>
-static Server *tcore_running_server;
-
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
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);
}
+++ /dev/null
-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)
%define major 0
%define minor 3
-%define patchlevel 25
+%define patchlevel 26
Name: libtcore
Version: %{major}.%{minor}.%{patchlevel}
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
%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
%else
-DARCH_EMUL=1 \
%endif
+ -DBUILD_GTESTS=%{?gtest:1}%{!?gtest:0}
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