rename config -> options

This commit is contained in:
luwenpeng
2024-03-08 14:51:21 +08:00
parent d0914483bb
commit 734f6a5135
32 changed files with 336 additions and 336 deletions

View File

@@ -9,7 +9,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SYN_DUP)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -61,7 +61,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, S2C_DUP)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet
@@ -116,7 +116,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SKIP_FILTER)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -178,13 +178,13 @@ TEST(TCP_DUPKT_FILTER_DISABLE, C2S_DUPKT)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_dupkt_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_dupkt_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -233,13 +233,13 @@ TEST(TCP_DUPKT_FILTER_DISABLE, S2C_DUP)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_dupkt_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_dupkt_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet

View File

@@ -9,7 +9,7 @@ TEST(UDP_EVICTION_FILTER_ENABLE, HIT_FILTER_THEN_EVICT_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -43,13 +43,13 @@ TEST(UDP_EVICTION_FILTER_ENABLE, MISS_FILTER_THEN_NEW_SESS)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_eviction_filter_timeout = 2;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_eviction_filter_timeout = 2;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -66,7 +66,7 @@ TEST(UDP_EVICTION_FILTER_ENABLE, MISS_FILTER_THEN_NEW_SESS)
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// wait udp eviction filter timeout
sleep(_config.udp_eviction_filter_timeout);
sleep(_opts.udp_eviction_filter_timeout);
timestamp_update();
// C2S REQ Packet
@@ -91,13 +91,13 @@ TEST(UDP_EVICTION_FILTER_DISABLE, MISS_FILTER_THEN_NEW_SESS)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_eviction_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_eviction_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet

View File

@@ -19,10 +19,10 @@ TEST(OVERLOAD, EVICT_TCP_OLD_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i < config.max_tcp_session_num; i++)
for (uint64_t i = 0; i < opts.max_tcp_session_num; i++)
{
// C2S SYN Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -37,7 +37,7 @@ TEST(OVERLOAD, EVICT_TCP_OLD_SESS)
__session_dispatch(sess);
session_manager_print_stat(mgr);
if (i == config.max_tcp_session_num - 1)
if (i == opts.max_tcp_session_num - 1)
{
__session_manager_check_counter(mgr,
i, 0, 1, // tcp_opening_sess_num, tcp_active_sess_num, tcp_closing_sess_num,
@@ -91,16 +91,16 @@ TEST(OVERLOAD, EVICT_TCP_NEW_SESS)
struct session *sess = NULL;
struct session_manager *mgr = NULL;
char buffer[1500] = {0};
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_overload_evict_old_sess = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_overload_evict_old_sess = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i <= _config.max_tcp_session_num; i++)
for (uint64_t i = 0; i <= _opts.max_tcp_session_num; i++)
{
// C2S SYN Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -111,7 +111,7 @@ TEST(OVERLOAD, EVICT_TCP_NEW_SESS)
printf("<= packet parse\n\n");
sess = session_manager_update_session(mgr, &pkt);
if (i == _config.max_tcp_session_num)
if (i == _opts.max_tcp_session_num)
{
EXPECT_TRUE(sess == NULL);
__session_manager_check_counter(mgr,

View File

@@ -19,10 +19,10 @@ TEST(OVERLOAD, EVICT_UDP_OLD_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i < config.max_udp_session_num; i++)
for (uint64_t i = 0; i < opts.max_udp_session_num; i++)
{
// C2S REQ Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -37,7 +37,7 @@ TEST(OVERLOAD, EVICT_UDP_OLD_SESS)
__session_dispatch(sess);
session_manager_print_stat(mgr);
if (i == config.max_udp_session_num - 1)
if (i == opts.max_udp_session_num - 1)
{
__session_manager_check_counter(mgr,
0, 0, 0, // tcp_opening_sess_num, tcp_active_sess_num, tcp_closing_sess_num,
@@ -91,16 +91,16 @@ TEST(OVERLOAD, EVICT_UDP_NEW_SESS)
struct session *sess = NULL;
struct session_manager *mgr = NULL;
char buffer[1500] = {0};
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_overload_evict_old_sess = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_overload_evict_old_sess = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i <= _config.max_udp_session_num; i++)
for (uint64_t i = 0; i <= _opts.max_udp_session_num; i++)
{
// C2S REQ Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -111,7 +111,7 @@ TEST(OVERLOAD, EVICT_UDP_NEW_SESS)
printf("<= packet parse\n\n");
sess = session_manager_update_session(mgr, &pkt);
if (i == _config.max_udp_session_num)
if (i == _opts.max_udp_session_num)
{
EXPECT_TRUE(sess == NULL);
__session_manager_check_counter(mgr,

View File

@@ -91,7 +91,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_FIN_FIN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -182,7 +182,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -246,7 +246,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -308,7 +308,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_DATA_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -336,7 +336,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -393,7 +393,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet

View File

@@ -16,7 +16,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -71,7 +71,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -126,7 +126,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -216,7 +216,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK_ACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -342,7 +342,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_RETRANSMISSION)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -440,7 +440,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK_RETRANSMISSION)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -536,7 +536,7 @@ TEST(TCP_INIT_TO_OPENING, BY_C2S_ASMMETRIC)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -626,7 +626,7 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet

View File

@@ -12,7 +12,7 @@ TEST(TCP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING_TO_CLOSED, TEST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet

View File

@@ -16,7 +16,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYN_C2S_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -105,7 +105,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet

View File

@@ -57,7 +57,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_FIN_FIN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -148,7 +148,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -212,7 +212,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -274,7 +274,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_INIT_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -302,7 +302,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_HANDSHAKE_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -360,7 +360,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_DATA_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -452,7 +452,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -509,7 +509,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet

View File

@@ -20,7 +20,7 @@ TEST(UDP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING, TEST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet

View File

@@ -18,7 +18,7 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_C2S)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -75,7 +75,7 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_S2C)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C RESP Packet

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -28,8 +28,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_data(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_data(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -28,8 +28,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED1)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_half_closed(mgr, &config, SESSION_STATE_OPENING);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_half_closed(mgr, &opts, SESSION_STATE_OPENING);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -46,7 +46,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -72,8 +72,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED2)
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_half_closed(mgr, &config, SESSION_STATE_ACTIVE);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_half_closed(mgr, &opts, SESSION_STATE_ACTIVE);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -21,8 +21,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_handshake(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_handshake(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -21,8 +21,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT1)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_init(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_init(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -39,7 +39,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet
@@ -51,8 +51,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT2)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_init(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_init(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -21,7 +21,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA1)
__session_manager_check_counter(mgr, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);
__session_manager_check_udp_timeout_data(mgr, &config, SESSION_STATE_OPENING);
__session_manager_check_udp_timeout_data(mgr, &opts, SESSION_STATE_OPENING);
EXPECT_TRUE(session_manager_get_expired_session(mgr) == NULL);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -39,7 +39,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -58,7 +58,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA2)
__session_manager_check_counter(mgr, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0);
__session_manager_check_udp_timeout_data(mgr, &config, SESSION_STATE_ACTIVE);
__session_manager_check_udp_timeout_data(mgr, &opts, SESSION_STATE_ACTIVE);
EXPECT_TRUE(session_manager_get_expired_session(mgr) == NULL);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -15,7 +15,7 @@ extern "C"
#include "ipv4_utils.h"
#include "test_packets.h"
struct session_manager_config config = {
struct session_manager_options opts = {
// max session number
.max_tcp_session_num = 3,
.max_udp_session_num = 3,
@@ -112,20 +112,20 @@ __attribute__((unused)) static void __session_manager_check_counter(struct sessi
EXPECT_TRUE(counter.udp_overload_evict_old_sess_num == udp_overload_evict_old_sess_num);
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_init(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_init(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_init;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_init;
printf("\n=> tcp_timeout_init\n");
for (uint64_t i = 0; i <= config->tcp_timeout_init; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_init; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_init)
if (i == opts->tcp_timeout_init)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -139,7 +139,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_init(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_init);
EXPECT_TRUE(interval <= opts->tcp_timeout_init);
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -148,20 +148,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_init(str
printf("<= tcp_timeout_init\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_handshake(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_handshake(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_handshake;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_handshake;
printf("\n=> tcp_timeout_handshake\n");
for (uint64_t i = 0; i <= config->tcp_timeout_handshake; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_handshake; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_handshake)
if (i == opts->tcp_timeout_handshake)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -175,7 +175,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_handshak
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_handshake);
EXPECT_TRUE(interval <= opts->tcp_timeout_handshake);
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -184,20 +184,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_handshak
printf("<= tcp_timeout_handshake\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_data(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_data(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_data;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_data;
printf("\n=> tcp_timeout_data\n");
for (uint64_t i = 0; i <= config->tcp_timeout_data; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_data; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_data)
if (i == opts->tcp_timeout_data)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -211,7 +211,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_data(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_data);
EXPECT_TRUE(interval <= opts->tcp_timeout_data);
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -220,22 +220,22 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_data(str
printf("<= tcp_timeout_data\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_half_closed(struct session_manager *mgr, struct session_manager_config *config, enum session_state curr_state)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_half_closed(struct session_manager *mgr, struct session_manager_options *opts, enum session_state curr_state)
{
EXPECT_TRUE(curr_state == SESSION_STATE_OPENING || curr_state == SESSION_STATE_ACTIVE);
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_half_closed;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_half_closed;
printf("\n=> tcp_timeout_half_closed\n");
for (uint64_t i = 0; i <= config->tcp_timeout_half_closed; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_half_closed; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_half_closed)
if (i == opts->tcp_timeout_half_closed)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -249,7 +249,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_half_clo
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_half_closed);
EXPECT_TRUE(interval <= opts->tcp_timeout_half_closed);
if (curr_state == SESSION_STATE_OPENING)
{
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -265,20 +265,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_half_clo
printf("<= tcp_timeout_half_closed\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wait(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wait(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_time_wait;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_time_wait;
printf("\n=> tcp_timeout_time_wait\n");
for (uint64_t i = 0; i <= config->tcp_timeout_time_wait; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_time_wait; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_time_wait)
if (i == opts->tcp_timeout_time_wait)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -292,7 +292,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wai
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_init);
EXPECT_TRUE(interval <= opts->tcp_timeout_init);
__session_manager_check_counter(mgr, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -301,22 +301,22 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wai
printf("<= tcp_timeout_time_wait\n\n");
}
__attribute__((unused)) static void __session_manager_check_udp_timeout_data(struct session_manager *mgr, struct session_manager_config *config, enum session_state curr_state)
__attribute__((unused)) static void __session_manager_check_udp_timeout_data(struct session_manager *mgr, struct session_manager_options *opts, enum session_state curr_state)
{
EXPECT_TRUE(curr_state == SESSION_STATE_OPENING || curr_state == SESSION_STATE_ACTIVE);
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->udp_timeout_data;
uint64_t timeout_time = timestamp_get_sec() + opts->udp_timeout_data;
printf("\n=> udp_timeout_data\n");
for (uint64_t i = 0; i <= config->udp_timeout_data; i++)
for (uint64_t i = 0; i <= opts->udp_timeout_data; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->udp_timeout_data)
if (i == opts->udp_timeout_data)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -330,7 +330,7 @@ __attribute__((unused)) static void __session_manager_check_udp_timeout_data(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->udp_timeout_data);
EXPECT_TRUE(interval <= opts->udp_timeout_data);
if (curr_state == SESSION_STATE_OPENING)
{
__session_manager_check_counter(mgr, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);