Skip to content
Snippets Groups Projects
Commit 99b70dba authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Add tests for plug-in loading/unloading.

parent 7c6a5986
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) ...@@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
ADD_DEFINITIONS(-DTESTS_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data") ADD_DEFINITIONS(-DTESTS_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
ADD_DEFINITIONS(-DTESTS_PLUGINDIR="${LIBRARY_OUTPUT_PATH}")
# DYNAMIC_GRAPH_TEST(NAME) # DYNAMIC_GRAPH_TEST(NAME)
# ------------------------ # ------------------------
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <sstream> #include <sstream>
#include <dynamic-graph/exception-factory.h> #include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/interpreter.h> #include <dynamic-graph/interpreter.h>
#include <dynamic-graph/plugin-loader.h>
#define BOOST_TEST_MODULE interpreter #define BOOST_TEST_MODULE interpreter
...@@ -187,3 +188,51 @@ BOOST_AUTO_TEST_CASE (cmd_import_push) ...@@ -187,3 +188,51 @@ BOOST_AUTO_TEST_CASE (cmd_import_push)
} }
} }
// Check that plug-in loading/unloading is working.
BOOST_AUTO_TEST_CASE (cmd_loadPlugin)
{
dynamicgraph::PluginLoader pl;
dynamicgraph::Interpreter shell (&pl);
{
RUN_COMMAND ("loadPlugin", "shell-functions.so" " " TESTS_PLUGINDIR);
BOOST_CHECK (output.is_empty ());
}
{
RUN_COMMAND ("loadPlugin", "shell-procedure.so" " " TESTS_PLUGINDIR);
BOOST_CHECK (output.is_empty ());
}
{
RUN_COMMAND ("unloadPlugin", TESTS_PLUGINDIR "/shell-procedure.so");
BOOST_CHECK (output.is_empty ());
}
{
RUN_COMMAND ("unloadPlugin", TESTS_PLUGINDIR "/shell-functions.so");
BOOST_CHECK (output.is_empty ());
}
try
{
RUN_COMMAND ("loadPlugin", "idonotexist .");
BOOST_ERROR ("Should never happen");
}
catch (const dynamicgraph::ExceptionFactory& exception)
{
BOOST_CHECK_EQUAL (exception.getCode (),
dynamicgraph::ExceptionFactory::DYNAMIC_LOADING);
}
try
{
RUN_COMMAND ("unloadPlugin", "idonotexist");
BOOST_ERROR ("Should never happen");
}
catch (const dynamicgraph::ExceptionFactory& exception)
{
BOOST_CHECK_EQUAL (exception.getCode (),
dynamicgraph::ExceptionFactory::OBJECT_CONFLICT);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment