Browse Source

seperate test folder

Qiuyang 2 months ago
parent
commit
9974483cf5

+ 4 - 0
CMakeLists.txt

@@ -14,6 +14,7 @@ add_compile_options(-DRELEASE)
 option(build_modules "build modules" ON)
 option(build_source "build source programs" ON)
 option(build_plugins "build plugins programs" ON)
+option(build_test "build test programs" OFF)
 
 add_subdirectory(framework)
 if(build_modules)
@@ -25,6 +26,9 @@ endif()
 if(build_source)
   add_subdirectory(source)
 endif()
+if(build_test)
+  add_subdirectory(test)
+endif()
 
 # ---[ install
 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")  #set runtime path

BIN
lib/libgsd_core.so


BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 7 - 7
source/CMakeLists.txt

@@ -71,7 +71,7 @@ include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
-include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
+#include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
 include_directories(${CNSTREAM_ROOT_DIR}/source/UserApp/include)
 include_directories(${CNSTREAM_ROOT_DIR}/source/TestApp/include)
 include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
@@ -82,18 +82,18 @@ include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
-include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
+#include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
 
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
-aux_source_directory(${CNSTREAM_ROOT_DIR}/source/test tests)
+#aux_source_directory(${CNSTREAM_ROOT_DIR}/source/test tests)
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/TestApp/src testApps)
 
 # ---[ add targets
 # set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
 
-#add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
-#target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
+add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
+target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
 
-add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
-target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
+#add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
+#target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)

+ 96 - 0
test/CMakeLists.txt

@@ -0,0 +1,96 @@
+cmake_minimum_required(VERSION 2.8.7)
+
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+if(NOT COMPILER_SUPPORTS_CXX11)
+  message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+endif()
+
+if(USE_libstdcpp)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
+  message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
+endif()
+
+set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)
+set(TEST_ROOT_DIR ${CNSTREAM_ROOT_DIR}/test)
+message(STATUS "SOURCE: CNSTREAM_ROOT_DIR = ${CNSTREAM_ROOT_DIR}")
+message(STATUS "SOURCE: TEST_ROOT_DIR = ${TEST_ROOT_DIR}")
+# # compile flags
+# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
+# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
+# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
+
+option(build_kafka "build model kafka" ON)
+
+# ---[ 3rdparty
+set(3RDPARTY_LIBS "")
+
+# ---[ kafka
+if(build_kafka)
+  find_package(RDKafka REQUIRED)
+  include_directories(${RDKAFKA_INCLUDE_DIR})
+  list(APPEND 3RDPARTY_LIBS ${RDKAFKA_LIBRARIES}) 
+  #link_directories(${RDKAFKA_LINK_DIR})
+  message(STATUS "Test: RDKafka include: ${RDKAFKA_INCLUDE_DIR}")
+  message(STATUS "Test: RDKafka libraries: ${RDKAFKA_LIBRARIES}")
+endif()
+
+set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
+#查找mysql是否安装
+find_package(MYSQL QUIET)
+if(MYSQL_FOUND AND ENABLE_MYSQL)
+    message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
+    include_directories(${MYSQL_INCLUDE_DIR})
+    include_directories(${MYSQL_INCLUDE_DIR}/mysql)
+    add_definitions(-DENABLE_MYSQL)
+    list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
+endif()
+
+
+set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_ROOT_DIR}/cmake)
+
+# ---[ ZLToolKit
+find_package(ZLToolKit REQUIRED)
+#link_directories(${ZLTOOLKIT_LINK_DIR})
+include_directories(${ZLTOOLKIT_INCLUDE_DIR})
+list(APPEND 3RDPARTY_LIBS ${ZLTOOLKIT_LIBRARIES})
+message(STATUS "Test: ZLToolKit include: ${ZLTOOLKIT_INCLUDE_DIR}")
+message(STATUS "Test: ZLToolKit libraries: ${ZLTOOLKIT_LIBRARIES}")
+
+# ---[ rapidjson
+include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/)
+
+# ---[ httplib
+include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/httplib/)
+
+# ---[ modules include dirs
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/Expel/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpClient/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpServer/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
+include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
+include_directories(${CNSTREAM_ROOT_DIR}/test/TestApp/include)
+include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
+include_directories(${CNSTREAM_ROOT_DIR}/framework/request/include)
+
+# include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
+# include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
+include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
+
+aux_source_directory(${CNSTREAM_ROOT_DIR}/test/src tests)
+aux_source_directory(${CNSTREAM_ROOT_DIR}/test/TestApp/src testApps)
+
+# ---[ add targets
+set(EXECUTABLE_OUTPUT_PATH ${TEST_ROOT_DIR}/bin)
+
+#add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
+#target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
+
+add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
+target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)

+ 0 - 0
source/TestApp/include/TestApp.hpp → test/TestApp/include/TestApp.hpp


+ 0 - 0
source/TestApp/src/TestApp.cpp → test/TestApp/src/TestApp.cpp


+ 0 - 0
source/test/test.cpp → test/src/main.cpp