Addition of location-haltests 97/254497/4 submit/tizen/20210319.064859
authorchakradhar pogiri <v.pogiri@samsung.com>
Wed, 3 Mar 2021 17:18:47 +0000 (22:48 +0530)
committerchakradhar pogiri <v.pogiri@samsung.com>
Wed, 17 Mar 2021 07:40:56 +0000 (13:10 +0530)
Change-Id: Ie29684464f222c62211b8d1ab321ed0a5f1d0ef3

CMakeLists.txt
haltests/CMakeLists.txt [new file with mode: 0644]
haltests/haltest.h [new file with mode: 0644]
haltests/location-haltests.cpp [new file with mode: 0644]
lbs-server/src/lbs_server.c
packaging/lbs-server.spec

index 31cb9a0bda927446bf089331a3cba4d0101e7fcc..6edfeff9f8b4f892555f548385b49bef4a8f20c4 100755 (executable)
@@ -10,6 +10,7 @@ SET(BIN_DIR "${PREFIX}/bin")
 SET(common_dp "glib-2.0 lbs-dbus dlog gio-2.0 lbs-location libsyscommon hal-api-common hal-api-location")
 SET(server_dp "${common_dp} tapi vconf vconf-internal-keys gthread-2.0  gio-unix-2.0 capi-network-connection capi-network-wifi-manager capi-system-info libtzplatform-config")
 SET(module_dp "${common_dp} gmodule-2.0")
+SET(haltests_dp "${server_dp} capi-system-info vconf")
 
 # Set required packages
 INCLUDE(FindPkgConfig)
@@ -26,6 +27,12 @@ FOREACH(flag ${module_pkgs_CFLAGS})
        SET(MODULE_EXTRA_CFLAGS "${MODULE_EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
+## HALTESTS
+pkg_check_modules(haltests_pkgs REQUIRED ${haltests_dp})
+FOREACH(flag ${haltests_pkgs_CFLAGS})
+       SET(HALTESTS_EXTRA_CFLAGS "${HALTESTS_EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS}  -Wl,-zdefs -fvisibility=hidden ")
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
@@ -42,3 +49,4 @@ MESSAGE("C Flags: ${CMAKE_C_FLAGS}")
 
 ADD_SUBDIRECTORY(module)
 ADD_SUBDIRECTORY(lbs-server)
+ADD_SUBDIRECTORY(haltests)
diff --git a/haltests/CMakeLists.txt b/haltests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3926593
--- /dev/null
@@ -0,0 +1,53 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(location-haltests C CXX)
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(server_pkgs_LDFLAGS "${server_pkgs_LDFLAGS} -ldl -Wl,-z,noexecstack")
+
+SET(SRCS ${CMAKE_SOURCE_DIR}/lbs-server/src/server.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/lbs_server.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/data_connection.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/nmea_logger.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/gps_plugin_module.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/last_position.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/setting.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/dump_log.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/nps_plugin_module.c
+       ${CMAKE_SOURCE_DIR}/lbs-server/src/fused.c
+)
+
+FILE(GLOB_RECURSE FUSED_SRCS ${CMAKE_SOURCE_DIR}/lbs-server/src/fused/*.c)
+FILE(GLOB_RECURSE BM_SRCS ${CMAKE_SOURCE_DIR}/lbs-server/src/battery-monitor/*.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lbs-server/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lbs-server/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/haltests)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${INC_DIR})
+
+SET(HALTESTS_EXTRA_CFLAGS "${HALTESTS_EXTRA_CFLAGS} -D_GNU_SOURCE")
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+       gmock
+)
+
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(gtest_pkgs REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${gtest_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(HALTESTS_EXTRA_CFLAGS "${HALTESTS_EXTRA_CFLAGS} ${EXTRA_CFLAGS} -Wall -fPIE -DHALTESTS -Wno-unused-function")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HALTESTS_EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HALTESTS_EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(src ${CMAKE_SOURCE_DIR}/haltests/location-haltests.cpp)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${src} ${SRCS} ${FUSED_SRCS} ${BM_SRCS} )
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${HALTESTS_EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${server_pkgs_LDFLAGS} -lm ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR}/hal)
diff --git a/haltests/haltest.h b/haltests/haltest.h
new file mode 100644 (file)
index 0000000..9e45e79
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __HALTEST_H__
+#define __HALTEST_H__
+
+#include <glib.h>
+
+#define FEATURE_LOCATION "http://tizen.org/feature/location"
+#define FEATURE_GPS "http://tizen.org/feature/location.gps"
+#define FEATURE_GPS_SATELLITE "http://tizen.org/feature/location.gps.satellite"
+
+bool supported;
+
+#endif /* __HALTEST_H__ */
diff --git a/haltests/location-haltests.cpp b/haltests/location-haltests.cpp
new file mode 100644 (file)
index 0000000..5f900cb
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <gtest/gtest.h>
+#include <system_info.h>
+#include "haltest.h"
+#include "hal-location.h"
+
+extern "C" {
+#include "server.h"
+}
+
+class LocationHaltest : public testing::Test
+{
+       public:
+               virtual void SetUp()
+               {
+                       int ret;
+
+                       ret = system_info_get_platform_bool(FEATURE_LOCATION, &supported);
+                       ASSERT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
+
+               }
+
+               virtual void TearDown()
+               {
+
+               }
+};
+
+TEST_F(LocationHaltest, InitP)
+{
+       int ret = 0;
+       int argc = 0;
+       char **argv = NULL;
+       ret = initialize_server(argc,argv);
+       ASSERT_EQ(ret, 0) << "Fail to initialize_server (" << ret << ")";
+}
+
+TEST_F(LocationHaltest, StartSessionP)
+{
+       int ret = 0;
+       int argc = 0;
+       char **argv = NULL;
+       int interval = 10;
+       ret = initialize_server(argc,argv);
+       ASSERT_EQ(ret, 0) << "Fail to initialize_server (" << ret << ")";
+       ret = request_start_session(interval);
+       ASSERT_EQ(ret, 1) << "Fail to start_session (" << ret << ")";
+}
+
+TEST_F(LocationHaltest, StopSessionP)
+{
+       int ret = 0;
+       ret = request_stop_session();
+       ASSERT_EQ(ret, 1) << "Fail to stop_session (" << ret << ")";
+}
+
+TEST_F(LocationHaltest, DeInitP)
+{
+       int ret = 0;
+       ret = deinitialize_server();
+       ASSERT_EQ(ret, 0) << "Fail to deinitialize_server (" << ret << ")";
+}
+
+#ifdef HALTESTS
+int main(int argc, char **argv)
+{
+       int ret = -1;
+
+       try {
+               testing::InitGoogleTest(&argc, argv);
+       } catch(...) {
+               std::cout << "Exception occurred." << std::endl;
+       }
+
+       try {
+               ret = RUN_ALL_TESTS();
+       } catch (const ::testing::internal::GoogleTestFailureException& e) {
+               ret = -1;
+               std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+       }
+
+       return ret;
+}
+#endif
index 45428c2a07118787ca8857ee9ab08c49ad9e6365..d152cdc8aa33981721384290ce32feaaf110ea6c 100755 (executable)
@@ -1798,6 +1798,7 @@ static void _glib_log(const gchar *log_domain, GLogLevelFlags log_level,
        LOG_NPS(DBG_ERR, "GLIB[%d] : %s", log_level, msg);
 }
 
+#ifndef HALTESTS
 int main(int argc, char **argv)
 {
        lbs_server_s *lbs_server = NULL;
@@ -1905,7 +1906,7 @@ int main(int argc, char **argv)
 
        return 0;
 }
-
+#endif
 
 /* Tizen 3.0 */
 
index e67c5e3d602ebd9d21e449c9a95f3c6267ff7c12..1bc6d7bbbd8a68243a1e17cdbd1942528734ebf4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:    lbs-server
 Summary: LBS Server for Tizen
-Version: 1.3.6
+Version: 1.3.7
 Release: 1
 Group:   Location/Service
 License: Apache-2.0
@@ -28,6 +28,7 @@ BuildRequires: pkgconfig(capi-network-connection)
 BuildRequires:  pkgconfig(hal-api-common)
 BuildRequires:  pkgconfig(hal-api-location)
 BuildRequires: pkgconfig(libsyscommon)
+BuildRequires: pkgconfig(gmock)
 
 
 %description
@@ -54,6 +55,13 @@ Requires:   %{name} = %{version}-%{release}
 LBS Server plugin for Tizen (Development)
 This package provides header files and pkgconfig file for LBS Server plugin
 
+%package -n location-haltests
+Summary:        Location HAL(Hardware Abstraction Layer) Test Cases
+Requires:       %{name} = %{version}-%{release}
+
+%description -n location-haltests
+Location HAL(Hardware Abstraction Layer) Test Cases
+
 %prep
 %setup -q
 cp %{SOURCE1} .
@@ -144,3 +152,7 @@ rm -rf %{buildroot}
 %files -n lbs-server-plugin-devel
 %{_libdir}/pkgconfig/lbs-server-plugin.pc
 %{_includedir}/lbs-server-plugin/*.h
+
+%files -n location-haltests
+%manifest %{name}.manifest
+%{_bindir}/hal/location-haltests