Optimize integration testing

- Add injection package plug-in
- Add libstellar_dynamic.so to facilitate unit testing of upper-level plug-ins
This commit is contained in:
luwenpeng
2024-05-28 10:26:29 +08:00
parent 54385ed08b
commit f82b85c979
86 changed files with 831 additions and 831 deletions

View File

@@ -2,10 +2,6 @@
#include "plugin_manager.h"
#include "session_priv.h"
#include "stellar_priv.h"
#include "plugin_manager.h"
#include "stellar/utils.h"
#include "stellar/session.h"
#include "stellar/session_exdata.h"
@@ -156,18 +152,6 @@ inline static struct session *plugin_manager_scratch_session_get()
return per_thread_scratch_sess;
}
inline struct plugin_manager_schema * stellar_plugin_manager_schema_get(struct stellar *st)
{
return st->st_rt->plug_mgr;
}
inline int stellar_plugin_manager_schema_set(struct stellar *st, struct plugin_manager_schema *pm)
{
if(st->st_rt->plug_mgr)return -1;
st->st_rt->plug_mgr=pm;
return 0;
}
UT_icd plugin_specs_icd = {sizeof(struct plugin_specific), NULL, NULL, NULL};
static struct plugin_specific *plugin_specs_load(const char *toml_conf_path, int *spec_num)
@@ -251,9 +235,7 @@ struct plugin_manager_schema *plugin_manager_init(struct stellar *st, const char
}
pm->st = st;
stellar_plugin_manager_schema_set(st, pm);
stellar_set_plugin_manger(st, pm);
pm->tcp_topic_id=stellar_session_mq_create_topic(st, TOPIC_TCP, NULL, NULL);
pm->tcp_stream_topic_id=stellar_session_mq_create_topic(st, TOPIC_TCP_STREAM, tcp_stream_msg_free_fn, NULL);
pm->udp_topic_id=stellar_session_mq_create_topic(st, TOPIC_UDP, NULL, NULL);
@@ -334,7 +316,7 @@ UT_icd session_exdata_meta_icd = {sizeof(struct session_exdata_schema), NULL, se
int stellar_session_exdata_new_index(struct stellar *st, const char *name, session_exdata_free *free_func,void *free_arg)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->session_exdata_schema_array == NULL)
{
utarray_new(plug_mgr->session_exdata_schema_array, &session_exdata_meta_icd);
@@ -423,7 +405,7 @@ void session_mq_free(struct session_message *head)
int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);;
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);;
if(topic_name == NULL || plug_mgr == NULL || plug_mgr->session_mq_schema_array == NULL)return -1;
unsigned int len = utarray_len(plug_mgr->session_mq_schema_array);
struct session_mq_topic_schema *t_schema;
@@ -440,7 +422,7 @@ int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
int stellar_session_mq_update_topic(struct stellar *st, int topic_id, msg_free_cb_func *msg_free_cb, void *msg_free_arg)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->session_mq_schema_array == NULL)return -1;
unsigned int len = utarray_len(plug_mgr->session_mq_schema_array);
if(len < (unsigned int)topic_id)return -1;
@@ -453,7 +435,7 @@ int stellar_session_mq_update_topic(struct stellar *st, int topic_id, msg_free_c
int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name, msg_free_cb_func *msg_free_cb, void *msg_free_arg)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->session_mq_schema_array == NULL)
{
utarray_new(plug_mgr->session_mq_schema_array, &session_mq_topic_schema_icd);
@@ -478,7 +460,7 @@ int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name,
int stellar_session_mq_destroy_topic(struct stellar *st, int topic_id)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->session_mq_schema_array==NULL)return 0;
unsigned int len = utarray_len(plug_mgr->session_mq_schema_array);
if (len <= (unsigned int)topic_id)
@@ -559,7 +541,7 @@ UT_icd session_mq_subscriber_info_icd = {sizeof(struct session_mq_subscriber_inf
int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *plugin_on_msg_cb, int plugin_id)
{
if(plugin_id >= PACKET_PULGIN_ID_BASE)return -1;// ignore packet plugin
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->session_mq_schema_array==NULL)return -1;
unsigned int len = utarray_len(plug_mgr->session_mq_schema_array);
if (len <= (unsigned int)topic_id)return -1;
@@ -743,7 +725,7 @@ UT_icd registered_packet_plugin_array_icd = {sizeof(struct registered_packet_plu
int stellar_packet_plugin_register(struct stellar *st, unsigned char ip_protocol, plugin_on_packet_func on_packet, void *plugin_env)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->registered_packet_plugin_array == NULL)
{
utarray_new(plug_mgr->registered_packet_plugin_array, &registered_packet_plugin_array_icd);
@@ -783,7 +765,7 @@ UT_icd registered_polling_plugin_array_icd = {sizeof(struct registered_polling_p
int stellar_polling_plugin_register(struct stellar *st, plugin_on_polling_func on_polling, void *plugin_env)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->registered_polling_plugin_array == NULL)
{
utarray_new(plug_mgr->registered_polling_plugin_array, &registered_polling_plugin_array_icd);
@@ -828,7 +810,7 @@ int stellar_session_plugin_register(struct stellar *st,
session_ctx_free_func session_ctx_free,
void *plugin_env)
{
struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st);
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->registered_session_plugin_array == NULL)
{
utarray_new(plug_mgr->registered_session_plugin_array, &registered_session_plugin_schema_icd);