Add UWB haltest 05/257705/3 accepted/tizen/unified/20210505.141518 submit/tizen/20210503.080503 submit/tizen/20210503.211553
authorJihoon Jung <jh8801.jung@samsung.com>
Fri, 30 Apr 2021 01:17:46 +0000 (10:17 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 3 May 2021 06:51:56 +0000 (15:51 +0900)
Change-Id: I43c9735dc8667faf7d2b2285870bd0ec5108276f
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
CMakeLists.txt [changed mode: 0644->0755]
haltests/CMakeLists.txt [new file with mode: 0755]
haltests/uwb-haltests.cpp [new file with mode: 0755]
packaging/uwb-manager.spec [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e8e9071..9bd5f1d
@@ -32,3 +32,4 @@ ADD_DEFINITIONS("-DUSE_DLOG")
 
 ADD_SUBDIRECTORY(interface)
 ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(haltests)
diff --git a/haltests/CMakeLists.txt b/haltests/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..9a6b198
--- /dev/null
@@ -0,0 +1,40 @@
+########################## search for packages ################################
+
+SET(TARGET_UWB_HALTESTS "uwb-haltests")
+
+PKG_CHECK_MODULES(TARGET_UWB_HALTESTS_REQ_PKGS REQUIRED ${GTEST_DEPS} ${COMMON_DEPS} gmock)
+
+############################# compiler flags ##################################
+
+SET(EXTRA_FLAGS "-Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS} ${CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+########################  directory configuration  ############################
+
+INCLUDE_DIRECTORIES(${TARGET_UWB_HALTESTS_REQ_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${TARGET_UWB_HALTESTS_REQ_PKGS_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/interface)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+
+FILE(GLOB GTEST_SRCS
+       *.cpp
+       ${CMAKE_SOURCE_DIR}/src/UwbHal.cpp)
+LIST(REMOVE_ITEM GTEST_SRCS ${CMAKE_SOURCE_DIR}/src/main.cpp)
+SET(GTEST_SRCS ${GTEST_SRCS} ${CMAKE_SOURCE_DIR}/interface/generated-code.c)
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/interface/generated-code.c PROPERTIES GENERATED TRUE)
+
+# Build
+ADD_EXECUTABLE(${TARGET_UWB_HALTESTS} ${GTEST_SRCS})
+ADD_DEPENDENCIES(${TARGET_UWB_HALTESTS} GENERATED_DBUS_CODE)
+
+MESSAGE("${TARGET_UWB_HALTESTS_REQ_PKGS_LIBRARIES}")
+TARGET_LINK_LIBRARIES(${TARGET_UWB_HALTESTS}
+       ${TARGET_UWB_HALTESTS_REQ_PKGS_LIBRARIES} -ldl -lpaho-mqtt3a -lpthread)
+
+SET_TARGET_PROPERTIES(${TARGET_UWB_HALTESTS} PROPERTIES
+       COMPILE_FLAGS "-fPIE")
+
+INSTALL(TARGETS ${TARGET_UWB_HALTESTS} DESTINATION ${BIN_DIR}/hal)
diff --git a/haltests/uwb-haltests.cpp b/haltests/uwb-haltests.cpp
new file mode 100755 (executable)
index 0000000..770d650
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * uwb-manager-gtest.cpp
+ *
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jihoon Jung <jh8801.jung@samsung.com>, Jiung Yu <jiung.yu@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <stdio.h>
+#include <memory>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+#include <gtest/gtest.h>
+
+/*****************************************************************************
+ *  Local headers
+ *****************************************************************************/
+#include <UwbHal.h>
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+class UwbHalTest : public ::testing::Test {
+
+protected:
+       void SetUp() override
+       {
+               this->_uwb_hal = std::make_shared<UwbManagerNamespace::UwbHal>();
+               this->_uwb_hal->init();
+               this->_uwb_hal->enableNetwork();
+       }
+
+       void TearDown() override
+       {
+               this->_uwb_hal->disableNetwork();
+               this->_uwb_hal->deinit();
+       }
+
+       std::shared_ptr<UwbManagerNamespace::UwbHal> _uwb_hal;
+       int ret;
+};
+
+TEST_F(UwbHalTest, uwb_hal_start)
+{
+       ret = _uwb_hal->start();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_stop)
+{
+       ret = _uwb_hal->stop();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_test)
+{
+       ret = _uwb_hal->test();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_reset)
+{
+       ret = _uwb_hal->reset();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_factory_reset)
+{
+       ret = _uwb_hal->factoryReset();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_enable_network)
+{
+       _uwb_hal->disableNetwork();
+
+       ret = _uwb_hal->enableNetwork();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_disable_network)
+{
+       ret = _uwb_hal->disableNetwork();
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_get_own_node)
+{
+       uwb_node_s *own_node = NULL;
+
+       ret = _uwb_hal->getOwnNode(&own_node);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_get_network_info)
+{
+       uwb_network_s *network_info;
+
+       ret = _uwb_hal->getNetworkInfo(&network_info);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_set_configurations)
+{
+       GVariant *configurations = NULL;
+       GVariantBuilder *builder;
+       int ret = 0;
+
+       _uwb_hal->disableNetwork();
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       configurations = g_variant_new("a{sv}", builder);
+
+       ret = _uwb_hal->setConfigurations(0, configurations);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_get_configurations)
+{
+       GVariant *configurations;
+
+       ret = _uwb_hal->getConfigurations(0, &configurations);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_send_message)
+{
+       ret = _uwb_hal->sendMessage((const unsigned char *)"HELLO", 5);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+TEST_F(UwbHalTest, uwb_hal_send_message_to)
+{
+       ret = _uwb_hal->sendMessageTo(0, (const unsigned char *)"HELLO", 5);
+
+       if (ret == -ENOTSUP)
+               ASSERT_TRUE(true);
+       else
+               ASSERT_EQ(0, ret);
+}
+
+int main(int argc, char **argv)
+{
+       ::testing::InitGoogleTest(&argc, argv);
+       return RUN_ALL_TESTS();
+}
old mode 100644 (file)
new mode 100755 (executable)
index 7cc969e..5aa1266
@@ -27,6 +27,13 @@ Requires(postun): /sbin/ldconfig
 %description
 Manager for handling UWB functionalities
 
+%package haltests
+Summary: uwb-manager extension for HAL test
+BuildRequires: pkgconfig(gmock)
+Requires: %{name} = %{version}-%{release}
+%description haltests
+TIZEN uwb-manager extension for HAL test.
+
 %prep
 %setup -q
 
@@ -88,3 +95,7 @@ cp uwb-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/uwb-manager.conf
 
 #DBus DAC
 %attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/uwb-manager.conf
+
+%files haltests
+%manifest %{name}.manifest
+%{_bindir}/hal/*haltests