This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar-2022/src/plugin_manager/test/gtest_pm_session_dettach_me.cpp

55 lines
1.6 KiB
C++
Raw Normal View History

#include <gtest/gtest.h>
#include "plugin_manager.h"
#include "session_internal_types.h"
TEST(PLUGIN_MANAGER_TEST, pm_session_dettach_me)
{
/*
* ./plugins_config/simple_plugin.inf
* ./plugins_config/dettach_me_plugin.inf
*
* dettach_me_plugin_entry() call pm_session_dettach_me() on SESSION_STATE_ACTIVE
*/
struct session_ctx
{
char data[64];
};
struct session_ctx *ctx = NULL;
struct stellar_session session = {0};
char session_name[] = "TEST";
char file_path[] = "./plugins_config/config_list1.inf";
session.name = session_name;
struct plugin_manager *plug_mgr = plugin_manager_create(1);
EXPECT_TRUE(plug_mgr != nullptr);
EXPECT_TRUE(plugin_manager_load(plug_mgr, file_path) == 0);
session.state = SESSION_STATE_OPENING;
plugin_manager_dispatch(plug_mgr, &session, 1);
ctx = (struct session_ctx *)pm_session_get_last_plugin_ctx(&session);
EXPECT_STREQ(ctx->data, "dettach_me_plugin_entry");
session.state = SESSION_STATE_ACTIVE;
plugin_manager_dispatch(plug_mgr, &session, 1);
ctx = (struct session_ctx *)pm_session_get_last_plugin_ctx(&session);
EXPECT_STREQ(ctx->data, NULL);
session.state = SESSION_STATE_ACTIVE;
plugin_manager_dispatch(plug_mgr, &session, 1);
ctx = (struct session_ctx *)pm_session_get_last_plugin_ctx(&session);
EXPECT_STREQ(ctx->data, "simple_plugin_entry");
session.state = SESSION_STATE_CLOSING;
plugin_manager_dispatch(plug_mgr, &session, 1);
plugin_manager_unload(plug_mgr);
plugin_manager_destory(plug_mgr);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}