summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-08-30 14:49:24 +0800
committeryangwei <[email protected]>2024-08-30 15:04:46 +0800
commitaa5c41e4d76cd999238c6a608a27453f88f51031 (patch)
treef4f9f502471d81a6f1db929fd11be9b29b481daa
parent5ccd66db73efa4f49480a439510f421ab08067bc (diff)
🦄 refactor(infra/log & http test case): mv log to deps/logger
trim http test case cmake
-rw-r--r--decoders/http/CMakeLists.txt3
-rw-r--r--deps/CMakeLists.txt3
-rw-r--r--deps/logger/CMakeLists.txt7
-rw-r--r--deps/logger/log.c (renamed from infra/log/log.c)0
-rw-r--r--deps/logger/log_private.h (renamed from infra/log/log_private.h)0
-rw-r--r--deps/logger/test/CMakeLists.txt9
-rw-r--r--deps/logger/test/conf/log_file.toml (renamed from infra/log/test/conf/log_file.toml)0
-rw-r--r--deps/logger/test/conf/log_stderr.toml (renamed from infra/log/test/conf/log_stderr.toml)0
-rw-r--r--deps/logger/test/gtest_log.cpp (renamed from infra/log/test/gtest_log.cpp)0
-rw-r--r--include/stellar/stellar.h19
-rw-r--r--infra/CMakeLists.txt4
-rw-r--r--infra/log/CMakeLists.txt7
-rw-r--r--infra/log/test/CMakeLists.txt8
-rw-r--r--infra/packet_parser/CMakeLists.txt3
-rw-r--r--infra/snowflake/CMakeLists.txt4
-rw-r--r--infra/tcp_reassembly/CMakeLists.txt3
-rw-r--r--test/decoders/http/CMakeLists.txt13
-rw-r--r--test/decoders/http/test_based_on_stellar/CMakeLists.txt5
-rw-r--r--test/lpi_plugin/gtest_lpi_main.cpp2
19 files changed, 42 insertions, 48 deletions
diff --git a/decoders/http/CMakeLists.txt b/decoders/http/CMakeLists.txt
index 9a278d2..bd45e6e 100644
--- a/decoders/http/CMakeLists.txt
+++ b/decoders/http/CMakeLists.txt
@@ -1,6 +1,3 @@
-add_definitions(-fPIC)
-include_directories(${CMAKE_BINARY_DIR}/vendor/llhttp/include)
-include_directories(${CMAKE_BINARY_DIR}/vendor/brotli/include)
include_directories(${CMAKE_SOURCE_DIR}/deps)
set(HTTP_SRC http_decoder.cpp http_decoder_utils.cpp http_decoder_half.cpp
diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt
index 58773e3..69ffeec 100644
--- a/deps/CMakeLists.txt
+++ b/deps/CMakeLists.txt
@@ -4,4 +4,5 @@ add_subdirectory(toml)
add_subdirectory(rbtree)
add_subdirectory(interval_tree)
add_subdirectory(bitmap)
-add_subdirectory(nmx_pool) \ No newline at end of file
+add_subdirectory(nmx_pool)
+add_subdirectory(logger) \ No newline at end of file
diff --git a/deps/logger/CMakeLists.txt b/deps/logger/CMakeLists.txt
new file mode 100644
index 0000000..b23f240
--- /dev/null
+++ b/deps/logger/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(logger log.c)
+target_include_directories(logger PUBLIC ${CMAKE_CURRENT_LIST_DIR})
+target_include_directories(logger PUBLIC ${CMAKE_SOURCE_DIR}/include)
+
+target_link_libraries(logger toml)
+
+add_subdirectory(test) \ No newline at end of file
diff --git a/infra/log/log.c b/deps/logger/log.c
index 3f961fe..3f961fe 100644
--- a/infra/log/log.c
+++ b/deps/logger/log.c
diff --git a/infra/log/log_private.h b/deps/logger/log_private.h
index 844d86b..844d86b 100644
--- a/infra/log/log_private.h
+++ b/deps/logger/log_private.h
diff --git a/deps/logger/test/CMakeLists.txt b/deps/logger/test/CMakeLists.txt
new file mode 100644
index 0000000..6d47222
--- /dev/null
+++ b/deps/logger/test/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_executable(gtest_log gtest_log.cpp)
+target_link_libraries(gtest_log logger gtest)
+target_include_directories(gtest_log PUBLIC ${CMAKE_SOURCE_DIR}/deps/logger)
+
+include(GoogleTest)
+gtest_discover_tests(gtest_log)
+
+file(COPY ./conf/log_file.toml DESTINATION ./conf/)
+file(COPY ./conf/log_stderr.toml DESTINATION ./conf/) \ No newline at end of file
diff --git a/infra/log/test/conf/log_file.toml b/deps/logger/test/conf/log_file.toml
index 43e3621..43e3621 100644
--- a/infra/log/test/conf/log_file.toml
+++ b/deps/logger/test/conf/log_file.toml
diff --git a/infra/log/test/conf/log_stderr.toml b/deps/logger/test/conf/log_stderr.toml
index a2febcc..a2febcc 100644
--- a/infra/log/test/conf/log_stderr.toml
+++ b/deps/logger/test/conf/log_stderr.toml
diff --git a/infra/log/test/gtest_log.cpp b/deps/logger/test/gtest_log.cpp
index 2183109..2183109 100644
--- a/infra/log/test/gtest_log.cpp
+++ b/deps/logger/test/gtest_log.cpp
diff --git a/include/stellar/stellar.h b/include/stellar/stellar.h
index 1e2e899..152beb5 100644
--- a/include/stellar/stellar.h
+++ b/include/stellar/stellar.h
@@ -18,13 +18,18 @@ typedef void plugin_on_unload_func(void *plugin_env);
typedef void *session_ctx_new_func(struct session *sess, void *plugin_env);
typedef void session_ctx_free_func(struct session *sess, void *session_ctx, void *plugin_env);
-#define TOPIC_TCP_STREAM "TCP_STREAM"
-#define TOPIC_CONTROL_PACKET "CONTROL_PACKET"
+// INTRINSIC TOPIC
+// TOPIC_TCP_STREAM on_msg need convert msg to (const struct tcp_segment *)
+// TOPIC_UDP_INPUT/TOPIC_TCP_INPUT/TOPIC_UDP_OUTPUT/TOPIC_TCP_OUTPUT/TOPIC_CONTROL_PACKET on_msg need convert msg to (const struct packet *)
+
+#define TOPIC_TCP_STREAM "TCP_STREAM" //topic message: tcp_segment
+#define TOPIC_CONTROL_PACKET "CONTROL_PACKET" //topic message: packet
-#define TOPIC_TCP_INPUT "TCP_INPUT"
-#define TOPIC_TCP_OUTPUT "TCP_OUTPUT"
-#define TOPIC_UDP_INPUT "UDP_INPUT"
-#define TOPIC_UDP_OUTPUT "UDP_OUTPUT"
+#define TOPIC_TCP_INPUT "TCP_INPUT" //topic message: packet
+#define TOPIC_TCP_OUTPUT "TCP_OUTPUT" //topic message: packet
+#define TOPIC_UDP_INPUT "UDP_INPUT" //topic message: packet
+#define TOPIC_UDP_OUTPUT "UDP_OUTPUT" //topic message: packet
+
//return session plugin_id
int stellar_session_plugin_register(struct stellar *st,
@@ -34,12 +39,10 @@ int stellar_session_plugin_register(struct stellar *st,
void stellar_session_plugin_dettach_current_session(struct session *sess);
-// TOPIC_TCP_STREAM return msg need convert to (const struct tcp_segment *)
struct tcp_segment;
const char *tcp_segment_get_data(const struct tcp_segment *seg);
uint16_t tcp_segment_get_len(const struct tcp_segment *seg);
-// TOPIC_UDP or TOPIC_TCP return msg need convert to (const struct packet *)
struct packet;
typedef void plugin_on_packet_func(struct packet *pkt, unsigned char ip_protocol, void *plugin_env);
diff --git a/infra/CMakeLists.txt b/infra/CMakeLists.txt
index c869555..e8862ad 100644
--- a/infra/CMakeLists.txt
+++ b/infra/CMakeLists.txt
@@ -1,5 +1,5 @@
-set(INFRA log tuple packet_parser packet_io snowflake ip_reassembly tcp_reassembly session_manager plugin_manager core)
-set(DEPS bitmap dablooms interval_tree nmx_pool rbtree timeout toml)
+set(INFRA tuple packet_parser packet_io snowflake ip_reassembly tcp_reassembly session_manager plugin_manager core)
+set(DEPS bitmap dablooms interval_tree logger nmx_pool rbtree timeout toml)
set(DECODERS http lpi)
set(WHOLE_ARCHIVE ${DEPS} ${INFRA} ${DECODERS})
diff --git a/infra/log/CMakeLists.txt b/infra/log/CMakeLists.txt
deleted file mode 100644
index 2a5ae39..0000000
--- a/infra/log/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_library(log log.c)
-target_include_directories(log PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_include_directories(log PUBLIC ${CMAKE_SOURCE_DIR}/include)
-
-target_link_libraries(log toml)
-
-add_subdirectory(test) \ No newline at end of file
diff --git a/infra/log/test/CMakeLists.txt b/infra/log/test/CMakeLists.txt
deleted file mode 100644
index a041d81..0000000
--- a/infra/log/test/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-add_executable(gtest_log gtest_log.cpp)
-target_link_libraries(gtest_log log gtest)
-
-include(GoogleTest)
-gtest_discover_tests(gtest_log)
-
-file(COPY ./conf/log_file.toml DESTINATION ./conf/)
-file(COPY ./conf/log_stderr.toml DESTINATION ./conf/) \ No newline at end of file
diff --git a/infra/packet_parser/CMakeLists.txt b/infra/packet_parser/CMakeLists.txt
index a0ee580..a44fab4 100644
--- a/infra/packet_parser/CMakeLists.txt
+++ b/infra/packet_parser/CMakeLists.txt
@@ -7,8 +7,9 @@ add_library(packet_parser
checksum.c)
target_include_directories(packet_parser PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(packet_parser PUBLIC ${CMAKE_SOURCE_DIR}/deps/uthash)
+target_include_directories(packet_parser PUBLIC ${CMAKE_SOURCE_DIR}/deps/logger)
target_include_directories(packet_parser PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(packet_parser PUBLIC ${CMAKE_SOURCE_DIR}/infra/core)
-target_link_libraries(packet_parser tuple log dablooms)
+target_link_libraries(packet_parser tuple logger dablooms)
add_subdirectory(test) \ No newline at end of file
diff --git a/infra/snowflake/CMakeLists.txt b/infra/snowflake/CMakeLists.txt
index 246367a..1ddb533 100644
--- a/infra/snowflake/CMakeLists.txt
+++ b/infra/snowflake/CMakeLists.txt
@@ -1,5 +1,7 @@
add_library(snowflake snowflake.c)
target_include_directories(snowflake PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(snowflake log)
+target_include_directories(snowflake PUBLIC ${CMAKE_SOURCE_DIR}/deps/logger)
+
+target_link_libraries(snowflake logger)
add_subdirectory(test) \ No newline at end of file
diff --git a/infra/tcp_reassembly/CMakeLists.txt b/infra/tcp_reassembly/CMakeLists.txt
index 95f7c26..e53c383 100644
--- a/infra/tcp_reassembly/CMakeLists.txt
+++ b/infra/tcp_reassembly/CMakeLists.txt
@@ -1,7 +1,8 @@
add_library(tcp_reassembly tcp_reassembly.c)
target_include_directories(tcp_reassembly PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(tcp_reassembly PUBLIC ${CMAKE_SOURCE_DIR}/deps/list)
+target_include_directories(tcp_reassembly PUBLIC ${CMAKE_SOURCE_DIR}/deps/logger)
target_include_directories(tcp_reassembly PUBLIC ${CMAKE_SOURCE_DIR}/include)
-target_link_libraries(tcp_reassembly interval_tree log)
+target_link_libraries(tcp_reassembly interval_tree logger)
add_subdirectory(test) \ No newline at end of file
diff --git a/test/decoders/http/CMakeLists.txt b/test/decoders/http/CMakeLists.txt
index 78467f5..6d3c757 100644
--- a/test/decoders/http/CMakeLists.txt
+++ b/test/decoders/http/CMakeLists.txt
@@ -4,7 +4,7 @@ aux_source_directory(${PROJECT_SOURCE_DIR}/deps/toml DEPS_SRC)
add_library(${DECODER_NAME}_test SHARED http_decoder_test_plug.cpp md5.c ${DEPS_SRC})
add_dependencies(${DECODER_NAME}_test ${DECODER_NAME})
-target_link_libraries(${DECODER_NAME}_test cjson-static)
+target_link_libraries(${DECODER_NAME}_test cjson-static llhttp-static)
set_target_properties(${DECODER_NAME}_test PROPERTIES PREFIX "")
# add_library(${DECODER_NAME}_perf SHARED http_decoder_perf_plug.cpp)
@@ -14,21 +14,14 @@ set_target_properties(${DECODER_NAME}_test PROPERTIES PREFIX "")
set(TEST_RUN_DIR ${CMAKE_BINARY_DIR}/testing)
include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/deps)
-include_directories(/opt/tsg/stellar/include/)
-include_directories(/opt/tsg/framework/include/)
-include_directories(${CMAKE_BINARY_DIR}/vendor/llhttp/include)
-include_directories(${CMAKE_BINARY_DIR}/vendor/cjson/src/cjson/include)
include_directories(${PROJECT_SOURCE_DIR}/decoders/http)
include_directories(${PROJECT_SOURCE_DIR}/include/stellar)
-aux_source_directory(${PROJECT_SOURCE_DIR}/deps/mempool PERF_TEST_DEP_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/deps/toml PERF_TEST_DEP_SRC)
-aux_source_directory(${PROJECT_SOURCE_DIR}/src PERF_TEST_DEP_SRC)
add_executable(gtest_http http_decoder_gtest.cpp ${PROJECT_SOURCE_DIR}/decoders/http/http_decoder_utils.cpp)
-target_link_libraries(gtest_http gtest stellar_devel)
+target_link_libraries(gtest_http gtest stellar_devel llhttp-static)
add_executable(http_test_main plugin_test_main.cpp)
set_target_properties(http_test_main
@@ -42,7 +35,7 @@ set_target_properties(http_test_main
"-rdynamic"
)
set(LINK_FLAGS "-rdynamic")
-target_link_libraries(http_test_main gtest cjson-static stellar_devel)
+target_link_libraries(http_test_main gtest cjson-static stellar_devel llhttp-static)
add_subdirectory(test_based_on_stellar)
diff --git a/test/decoders/http/test_based_on_stellar/CMakeLists.txt b/test/decoders/http/test_based_on_stellar/CMakeLists.txt
index 0d636b6..fcc2c0e 100644
--- a/test/decoders/http/test_based_on_stellar/CMakeLists.txt
+++ b/test/decoders/http/test_based_on_stellar/CMakeLists.txt
@@ -6,14 +6,9 @@ set(TEST_MAIN http_test_main)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/test)
-include_directories(/usr/local/include/cjson)
-include_directories(/opt/tsg/framework/include/stellar)
-include_directories(/opt/MESA/include/MESA)
-include_directories(/opt/tsg/stellar/include/)
#various ways to add -rdynamic for centos7, centos8, and different cmake version
add_definitions(-rdynamic)
-link_directories(${SAPP_DEVEL_DIR})
# assemble test env
add_test(NAME HTTP_MKDIR_METRIC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/metrics; mkdir -p ${TEST_RUN_DIR}/plugin; mkdir -p ${TEST_RUN_DIR}/log; mkdir -p ${TEST_RUN_DIR}/pcap")
diff --git a/test/lpi_plugin/gtest_lpi_main.cpp b/test/lpi_plugin/gtest_lpi_main.cpp
index fa39679..d244fac 100644
--- a/test/lpi_plugin/gtest_lpi_main.cpp
+++ b/test/lpi_plugin/gtest_lpi_main.cpp
@@ -17,7 +17,7 @@
#include "stellar/session.h"
#include "stellar/stellar_mq.h"
-#include "cjson/cJSON.h"
+#include "cJSON.h"
struct gtest_json_result