Add the base code for Bluetooth HAL testcases 18/184118/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 16 Jul 2018 00:46:20 +0000 (09:46 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 16 Jul 2018 00:46:20 +0000 (09:46 +0900)
Change-Id: I936551aad88dada2f4da3d2dd2cee24466f0c16e
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-oal/CMakeLists.txt
bt-oal/haltest/CMakeLists.txt [new file with mode: 0644]
bt-oal/haltest/bluetooth_hal_tc.cpp [new file with mode: 0644]
packaging/bluetooth-frwk.spec

index a007bc8..ff1b5d0 100755 (executable)
@@ -1,5 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bt-oal C)
+PROJECT(bt-oal C CXX)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/hardware/)
@@ -49,7 +49,8 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib)
 LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/bt-oal)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(oal_pkgs REQUIRED vconf aul vconf alarm-service gio-unix-2.0 dlog gio-2.0 glib-2.0 libtzplatform-config)
+pkg_check_modules(oal_pkgs REQUIRED vconf aul vconf alarm-service gio-unix-2.0 dlog
+gio-2.0 glib-2.0 libtzplatform-config gmock)
 
 #pkg_check_modules(oal_pkgs REQUIRED vconf aul vconf libudev dbus-glib-1
 #alarm-service gio-unix-2.0 systemd dlog gio-2.0 glib-2.0 libtzplatform-config)
@@ -60,7 +61,7 @@ ENDFOREACH(flag)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g ")
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -fprofile-arcs -ftest-coverage")
 
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
@@ -78,8 +79,10 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
 
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${packages_LDFLAGS} -ldl)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${packages_LDFLAGS} -ldl -lgcov)
 
 FOREACH(hfile ${HEADERS})
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/${hfile} DESTINATION include/bt-oal)
 ENDFOREACH(hfile)
+
+ADD_SUBDIRECTORY(haltest)
diff --git a/bt-oal/haltest/CMakeLists.txt b/bt-oal/haltest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..43936cd
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright (c) 2014-2017 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        CMakeLists.txt
+# @author
+# @brief       Cmake for tests
+#
+SET(TARGET_GTEST_TESTS "bluetooth_hal_tc")
+
+INCLUDE_DIRECTORIES(/usr/include)
+INCLUDE_DIRECTORIES(/usr/include/db-util)
+INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
+INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/hardware)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
+
+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}
+       ${oal_pkgs_LDFLAGS}
+       ${oal_pkgs_LIBRARIES}
+       gmock
+       -L${CMAKE_SOURCE_DIR}/bt-oal
+       -lbt-oal
+)
+
+INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin)
diff --git a/bt-oal/haltest/bluetooth_hal_tc.cpp b/bt-oal/haltest/bluetooth_hal_tc.cpp
new file mode 100644 (file)
index 0000000..3d57953
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 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-share_test.cpp
+ * @author      abc
+ * @version     1.0
+ * @brief       Unit-tests setup
+ */
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.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;
+
+int main(int argc, char **argv) {
+  InitGoogleTest(&argc, argv);
+
+  return RUN_ALL_TESTS();
+}
index 86d9b7d..21a5e90 100644 (file)
@@ -40,6 +40,7 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(storage)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(capi-appfw-app-control)
+BuildRequires:  pkgconfig(gmock)
 
 Requires(post): /usr/bin/vconftool
 Requires(post): /sbin/ldconfig
@@ -173,6 +174,14 @@ Requires:   %{name} = %{version}-%{release}
 %description oal
 This package is BT stack common interface.
 
+%package oal-haltests
+Summary: HAL Test package for bluetooth OAL
+Group:   TO_BE/FILLED
+Requires: %{name} = %{version}-%{release}
+
+%description oal-haltests
+This package is C-API test application.
+
 %package plugin-headed
 Summary:    Bluetooth plugin Headed
 Group:      Network & Connectivity/Bluetooth
@@ -587,3 +596,7 @@ popd
 %if %{bt_bluez_hal} == ENABLED
 %{_libdir}/libbluetooth.default.so*
 %endif
+
+%files oal-haltests
+%manifest %{name}.manifest
+%{_bindir}/bluetooth_hal_tc