🧪 test(plug_mgr): test case add emptpy toml

This commit is contained in:
yangwei
2024-09-13 16:21:16 +08:00
parent e9825c3988
commit fb32deec1d
4 changed files with 22 additions and 11 deletions

View File

@@ -8,4 +8,4 @@ target_include_directories(plugin_manager PUBLIC ${CMAKE_SOURCE_DIR}/infra/tuple
target_include_directories(plugin_manager PUBLIC ${CMAKE_SOURCE_DIR}/deps/)
target_link_libraries(plugin_manager PUBLIC session_manager bitmap toml exdata ${CMAKE_DL_LIBS})
#add_subdirectory(test)
add_subdirectory(test)

View File

@@ -38,10 +38,11 @@ static struct plugin_specific *plugin_specs_load(const char *toml_conf_path, int
fprintf(stderr, "Error parsing toml: %s\n", errbuf);
return NULL;
}
struct plugin_specific* plugins=NULL;
toml_array_t* plugin_array = toml_array_in(conf, "plugin");
if(plugin_array==NULL)return NULL;
if(plugin_array==NULL)goto PLUGIN_SPEC_LOAD_ERROR;
*spec_num = toml_array_nelem(plugin_array);
struct plugin_specific* plugins = CALLOC(struct plugin_specific, *spec_num);
plugins = CALLOC(struct plugin_specific, *spec_num);
for (int i = 0; i < *spec_num; i++) {
toml_table_t* plugin = toml_table_at(plugin_array, i);
@@ -80,7 +81,7 @@ static struct plugin_specific *plugin_specs_load(const char *toml_conf_path, int
return plugins;
PLUGIN_SPEC_LOAD_ERROR:
toml_free(conf);
FREE(plugins);
if(plugins)FREE(plugins);
return NULL;
}

View File

@@ -1,16 +1,14 @@
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <gtest/gtest.h>
#include "stellar/utils.h"
#include "stellar/stellar_exdata.h"
#include "exdata/exdata_internal.h"
#include "plugin_manager.h"
#include "plugin_manager_gtest_mock.h"
#define STELLAR_INTRINSIC_TOPIC_NUM 0
#define TOPIC_NAME_MAX 512
#if 0
void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct plugin_manager_schema *plug_mgr)
{
SCOPED_TRACE("whitebox test intrisic metadata");
@@ -43,6 +41,8 @@ void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct p
}
}
#endif
/***********************************
* TEST PLUGIN MANAGER INIT & EXIT *
***********************************/
@@ -52,11 +52,21 @@ void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct p
TEST(plugin_manager_init, init_with_null_toml) {
struct stellar st={0};
struct plugin_manager_schema *plug_mgr = plugin_manager_init(&st, NULL, MAX_MSG_PER_STAGE);
whitebox_test_plugin_manager_intrisic_metadata(&st, plug_mgr);
struct plugin_manager_schema *plug_mgr = plugin_manager_init(&st, NULL);
//whitebox_test_plugin_manager_intrisic_metadata(&st, plug_mgr);
plugin_manager_exit(plug_mgr);
}
TEST(plugin_manager_init, init_with_empty_toml) {
struct stellar st={0};
struct plugin_manager_schema *plug_mgr = plugin_manager_init(&st, "/dev/null");
//whitebox_test_plugin_manager_intrisic_metadata(&st, plug_mgr);
plugin_manager_exit(plug_mgr);
}
#if 0
/******************************************
* TEST PLUGIN MANAGER PACKET PLUGIN INIT *
******************************************/
@@ -1630,6 +1640,7 @@ TEST(plugin_manager, basic_polling_plugins) {
}
#endif
/**********************************************
* GTEST MAIN *

View File

@@ -9,7 +9,6 @@ extern "C"
#include "stellar/session.h"
#include "tuple.h"
#include "exdata/exdata.h"
//mock stellar
struct stellar