CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(hal-api-bluetooth C)
+PROJECT(hal-api-bluetooth C CXX)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
SET(PKG_MODULES
dlog
hal-api-common
+ libtzplatform-config
+ gmock
)
INCLUDE(FindPkgConfig)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIC")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt")
-SET(CMAKE_EXE_LINKER_FLAGS "-pie")
ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_BLUETOOTH\"")
src/hal-api-bluetooth.c)
ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
-TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm -Wl,-z,nodelete,--no-undefined,--rpath=${LIBDIR}/hal)
+TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lgcov -lm -Wl,-z,nodelete,--no-undefined,--rpath=${LIBDIR}/hal)
SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-bluetooth.h DESTINATION ${INCLUDEDIR}/hal)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-bluetooth-interface.h DESTINATION ${INCLUDEDIR}/hal)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(hal-api-common)
%description
%description -n %{devel_name}
%{name} Interface for product vendor developer
+### test package #########
+%package -n bluetooth-haltests
+Summary: Test package for BT HAL interface
+Group: TO_BE/FILLED
+Requires: %{name} = %{version}-%{release}
+
+%description -n bluetooth-haltests
+This package is C-API test application.
+
### build and install #########
%prep
%setup -q
%license LICENSE
%{_includedir}/hal/*.h
%{_libdir}/pkgconfig/%{name}.pc
+
+%files -n bluetooth-haltests
+%manifest %{name}.manifest
+%{_bindir}/hal/bluetooth-haltests
--- /dev/null
+SET(TARGET_GTEST_TESTS "bluetooth-haltests")
+
+INCLUDE_DIRECTORIES(/usr/include)
+#INCLUDE_DIRECTORIES(/usr/include/db-util)
+INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
+INCLUDE_DIRECTORIES(/usr/include/system)
+INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/)
+INCLUDE_DIRECTORIES(/usr/lib64/glib-2.0/include/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(INCLUDEDIR "/usr/include")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(testpkgs REQUIRED glib-2.0 gmock)
+
+SET(GTEST_TESTS_SOURCES
+bluetooth_hal_tc.cpp
+)
+
+ADD_EXECUTABLE(${TARGET_GTEST_TESTS}
+ ${GTEST_TESTS_SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_GTEST_TESTS}
+ ${testpkgs_LDFLAGS}
+ ${testpkgs_LIBRARIES}
+ gmock
+ hal-api-bluetooth
+)
+
+INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin/hal)
--- /dev/null
+/*
+ * 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.
+ */
+/**
+ * @file bluetooth_hal_tc.cpp
+ * @author abc
+ * @version 1.0
+ * @brief BT hal tests
+ */
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "hal-bluetooth-interface.h"
+#include "hal-bluetooth.h"
+
+using ::testing::EmptyTestEventListener;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+using ::testing::TestEventListeners;
+using ::testing::TestInfo;
+using ::testing::TestPartResult;
+using ::testing::UnitTest;
+
+TEST(BluetoothHALtest, bluetooth_get_put_backend_p) {
+ int ret = HAL_BACKEND_ERROR_NONE;
+
+ ret = hal_bluetooth_get_backend();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+
+ ret = hal_bluetooth_put_backend();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+}
+
+TEST(BluetoothHALtest, bluetooth_start_p) {
+ int ret = HAL_BACKEND_ERROR_NONE;
+
+ ret = hal_bluetooth_get_backend();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+
+ ret = hal_bluetooth_start();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+}
+
+TEST(BluetoothHALtest, bluetooth_stop_p) {
+ int ret = HAL_BACKEND_ERROR_NONE;
+
+ ret = hal_bluetooth_get_backend();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+
+ ret = hal_bluetooth_stop();
+ ASSERT_TRUE(ret == HAL_BACKEND_ERROR_NONE);
+}
+
+int main(int argc, char **argv) {
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}