Add:TCP server module.
This commit is contained in:
parent
daa873e32a
commit
0b976c4619
4
external/libhv/libhv-1.3.2/CMakeLists.txt
vendored
4
external/libhv/libhv-1.3.2/CMakeLists.txt
vendored
|
@ -99,8 +99,8 @@ set(SRCDIR src)
|
||||||
set(LIBDIR lib)
|
set(LIBDIR lib)
|
||||||
set(BINDIR bin)
|
set(BINDIR bin)
|
||||||
# ================== added by xiao ================== #
|
# ================== added by xiao ================== #
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBS_OUTPUT_PATH})
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${EXTERNAL_LIBS_OUTPUT_PATH})
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBS_OUTPUT_PATH})
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIBS_OUTPUT_PATH})
|
||||||
# ================== added by xiao ================== #
|
# ================== added by xiao ================== #
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BINDIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BINDIR})
|
||||||
message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||||
|
|
|
@ -8,5 +8,4 @@ add_subdirectory(LinuxApiMock)
|
||||||
add_subdirectory(McuProtocol)
|
add_subdirectory(McuProtocol)
|
||||||
add_subdirectory(FxHttpServer)
|
add_subdirectory(FxHttpServer)
|
||||||
add_subdirectory(TestManager)
|
add_subdirectory(TestManager)
|
||||||
|
add_subdirectory(TcpModule)
|
||||||
|
|
68
test/utils/TcpModule/CMakeLists.txt
Normal file
68
test/utils/TcpModule/CMakeLists.txt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# include(${CMAKE_SOURCE_DIR}/build/independent_source.cmake)
|
||||||
|
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${TEST_OUTPUT_PATH}/bin)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
./tool/include
|
||||||
|
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||||
|
${UTILS_SOURCE_PATH}/Log/include
|
||||||
|
${UTILS_SOURCE_PATH}/TcpModule/include
|
||||||
|
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
||||||
|
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
|
||||||
|
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
|
||||||
|
)
|
||||||
|
|
||||||
|
link_directories(
|
||||||
|
${LIBS_OUTPUT_PATH}
|
||||||
|
${EXTERNAL_LIBS_OUTPUT_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
|
aux_source_directory(. SRC_FILES)
|
||||||
|
aux_source_directory(./src SRC_FILES)
|
||||||
|
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||||
|
aux_source_directory(./src_mock SRC_FILES)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(TARGET_NAME TcpModuleTest)
|
||||||
|
add_executable(${TARGET_NAME} ${SRC_FILES})
|
||||||
|
target_link_libraries(${TARGET_NAME} TcpModule gtest gmock pthread Log)
|
||||||
|
if(${TEST_COVERAGE} MATCHES "true")
|
||||||
|
target_link_libraries(${TARGET_NAME} gcov)
|
||||||
|
endif()
|
||||||
|
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||||
|
target_link_libraries(${TARGET_NAME} LinuxApiMock)
|
||||||
|
endif()
|
||||||
|
# if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||||
|
add_custom_target(
|
||||||
|
TcpModuleTest_code_check
|
||||||
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
-checks='${CLANG_TIDY_CHECKS}'
|
||||||
|
--header-filter=.*
|
||||||
|
--system-headers=false
|
||||||
|
${SRC_FILES}
|
||||||
|
${CLANG_TIDY_CONFIG}
|
||||||
|
# --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/gtest.h\"}]'
|
||||||
|
--line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]'
|
||||||
|
-p ${PLATFORM_PATH}/cmake-shell
|
||||||
|
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/utils/TcpModule
|
||||||
|
)
|
||||||
|
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||||
|
add_custom_target(
|
||||||
|
TcpModuleTest_code_format
|
||||||
|
COMMAND ${CLANG_FORMAT_EXE}
|
||||||
|
-style=file
|
||||||
|
-i ${SRC_FILES} ${HEADER_FILES}
|
||||||
|
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/utils/TcpModule
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET_NAME}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND make TcpModuleTest_code_check
|
||||||
|
COMMAND make TcpModuleTest_code_format
|
||||||
|
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||||
|
)
|
||||||
|
# endif()
|
||||||
|
|
||||||
|
define_file_name(${TARGET_NAME})
|
||||||
|
|
||||||
|
# add_subdirectory(tool)
|
23
test/utils/TcpModule/mainTest.cpp
Normal file
23
test/utils/TcpModule/mainTest.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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 <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <unistd.h>
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
31
test/utils/TcpModule/src/TcpModule_Test.cpp
Normal file
31
test/utils/TcpModule/src/TcpModule_Test.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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 "ILog.h"
|
||||||
|
#include "TcpModule.h"
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
namespace TcpModuleTest
|
||||||
|
{
|
||||||
|
// ../output_files/test/bin/TcpModuleTest --gtest_filter=TcpModuleTest.UNIT_TcpModule_AUTO_IllegalObject
|
||||||
|
/**
|
||||||
|
* TcpModule module api will not crash when object is illegal.
|
||||||
|
*/
|
||||||
|
TEST(TcpModuleTest, UNIT_TcpModule_AUTO_IllegalObject)
|
||||||
|
{
|
||||||
|
CreateLogModule();
|
||||||
|
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||||
|
ILogUnInit();
|
||||||
|
}
|
||||||
|
} // namespace TcpModuleTest
|
|
@ -17,8 +17,6 @@ link_directories(
|
||||||
${EXTERNAL_LIBS_OUTPUT_PATH}
|
${EXTERNAL_LIBS_OUTPUT_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
aux_source_directory(. SRC_FILES)
|
aux_source_directory(. SRC_FILES)
|
||||||
aux_source_directory(./src SRC_FILES)
|
aux_source_directory(./src SRC_FILES)
|
||||||
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||||
|
|
|
@ -19,7 +19,7 @@ set(TARGET_NAME TcpModule)
|
||||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||||
target_link_libraries(${TARGET_NAME} LinuxApi StatusCode Log)
|
target_link_libraries(${TARGET_NAME} LinuxApi StatusCode Log)
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
# if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
TcpModule_code_check
|
TcpModule_code_check
|
||||||
COMMAND ${CLANG_TIDY_EXE}
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
@ -46,7 +46,7 @@ add_custom_command(
|
||||||
COMMAND make TcpModule_code_format
|
COMMAND make TcpModule_code_format
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||||
)
|
)
|
||||||
endif()
|
# endif()
|
||||||
|
|
||||||
define_file_name(${TARGET_NAME})
|
define_file_name(${TARGET_NAME})
|
||||||
|
|
||||||
|
|
14
utils/TcpModule/src/TcpClient.cpp
Normal file
14
utils/TcpModule/src/TcpClient.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
14
utils/TcpModule/src/TcpClient.h
Normal file
14
utils/TcpModule/src/TcpClient.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
|
@ -18,7 +18,7 @@
|
||||||
#include "TcpModule.h"
|
#include "TcpModule.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#define TCP_MODULE_INIT_NAME "UART"
|
#define TCP_MODULE_INIT_NAME "UART"
|
||||||
typedef struct uart_device_header
|
typedef struct tcp_module_header
|
||||||
{
|
{
|
||||||
const char *mCheckName;
|
const char *mCheckName;
|
||||||
} TcpModuleHeader;
|
} TcpModuleHeader;
|
||||||
|
|
14
utils/TcpModule/src/TcpServer.cpp
Normal file
14
utils/TcpModule/src/TcpServer.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
14
utils/TcpModule/src/TcpServer.h
Normal file
14
utils/TcpModule/src/TcpServer.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
Loading…
Reference in New Issue
Block a user