fieldstat增加health check功能的计数

This commit is contained in:
luwenpeng
2023-02-24 14:43:47 +08:00
parent 57cd21ae53
commit 7dd877cea8
7 changed files with 77 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
#include <gtest/gtest.h>
#include "sce.h"
#include "policy.h"
#include "raw_packet.h"
#include "global_metrics.h"
unsigned char data1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xa4, 0xc6, 0x4f, 0x3b, 0xb3, 0x9a, 0x81, 0x00, 0x66, 0x58, 0x81, 0x00, 0x61, 0xf9, 0x08, 0x00, 0x45, 0xb8, 0x00, 0x94,
@@ -24,6 +26,13 @@ TEST(POLICY, SELECTED_CHAINING_LIFE_CYCLE)
TEST(POLICY, POLICY_ENFORCER_LIFE_CYCLE)
{
struct global_metrics g_metrics;
struct thread_ctx t_ctx;
struct session_ctx s_ctx;
t_ctx.ref_metrics = &g_metrics;
s_ctx.ref_thread_ctx = &t_ctx;
struct raw_pkt_parser handler;
raw_packet_parser_init(&handler, 0, LAYER_TYPE_ALL, 8);
@@ -39,10 +48,10 @@ TEST(POLICY, POLICY_ENFORCER_LIFE_CYCLE)
int dir_is_internal = 1;
struct selected_chaining *chaining = selected_chaining_create(64);
EXPECT_TRUE(chaining != nullptr);
policy_enforce_select_chaining(chaining, enforcer, &handler, 1, dir_is_internal);
policy_enforce_select_chaining(chaining, enforcer, &handler, 2, dir_is_internal);
policy_enforce_select_chaining(chaining, enforcer, &handler, 11, dir_is_internal);
policy_enforce_select_chaining(chaining, enforcer, &handler, 12, dir_is_internal);
policy_enforce_select_chaining(chaining, enforcer, &handler, 1, dir_is_internal, &s_ctx);
policy_enforce_select_chaining(chaining, enforcer, &handler, 2, dir_is_internal, &s_ctx);
policy_enforce_select_chaining(chaining, enforcer, &handler, 11, dir_is_internal, &s_ctx);
policy_enforce_select_chaining(chaining, enforcer, &handler, 12, dir_is_internal, &s_ctx);
selected_chaining_dump(chaining);
selected_chaining_bref(chaining);
selected_chaining_destory(chaining);