diff --git a/cpp/frameProcessor/test/CMakeLists.txt b/cpp/frameProcessor/test/CMakeLists.txt index 704a3acf..5c7c490e 100644 --- a/cpp/frameProcessor/test/CMakeLists.txt +++ b/cpp/frameProcessor/test/CMakeLists.txt @@ -10,6 +10,7 @@ file(GLOB TEST_SOURCES FrameProcessorTest.cpp GapFillPluginTest.cpp MetaMessageTest.cpp + DummyUDPProcessPluginTest.cpp ) # Add tests for BloscPlugin if Blosc is present if (${BLOSC_FOUND}) @@ -39,6 +40,7 @@ target_link_libraries(frameProcessorTest LiveViewPlugin SumPlugin GapFillPlugin + DummyUDPProcessPlugin ${COMMON_LIBRARY}) # Link for BloscPlugin if Blosc is present diff --git a/cpp/frameProcessor/test/DummyUDPProcessPluginTest.cpp b/cpp/frameProcessor/test/DummyUDPProcessPluginTest.cpp new file mode 100644 index 00000000..6c385a30 --- /dev/null +++ b/cpp/frameProcessor/test/DummyUDPProcessPluginTest.cpp @@ -0,0 +1,61 @@ +/* + * DummyUDPProcessPluginTest.cpp + * + * Created on: 25 Sep 2024 + * Author: Alan Greer + */ + +#include +#include +#include "FrameProcessorDefinitions.h" +#include "DummyUDPProcessPlugin.h" +#include "IpcMessage.h" + +class DummyUDPProcessPluginTestFixture { +public: + DummyUDPProcessPluginTestFixture() { + set_debug_level(3); + + dummy_plugin.set_name("dummy"); + } + + ~DummyUDPProcessPluginTestFixture() {} + + FrameProcessor::DummyUDPProcessPlugin dummy_plugin; +}; + +BOOST_FIXTURE_TEST_SUITE(DummyUDPProcessPluginUnitTest, DummyUDPProcessPluginTestFixture); + +BOOST_AUTO_TEST_CASE( DummyUDPProcessPlugin_commands ) +{ + OdinData::IpcMessage command_reply; + OdinData::IpcMessage command_execute; + OdinData::IpcMessage bad_command_execute; + + // Request the command set of the DummyUDPProcessPlugin + BOOST_REQUIRE_NO_THROW(dummy_plugin.requestCommands(command_reply)); + + OdinData::IpcMessage sub_reply(command_reply.get_param(std::string("dummy")), + command_reply.get_msg_type(), + command_reply.get_msg_val()); + + // Verify that the command set includes the command to execute a print statement + BOOST_CHECK_EQUAL(sub_reply.has_param(std::string("print")), true); + + OdinData::IpcMessage param_reply(sub_reply.get_param(std::string("print")), + sub_reply.get_msg_type(), + sub_reply.get_msg_val()); + + // Verify that the command has the parameter name, which names the configuration item to print + BOOST_CHECK_EQUAL(param_reply.has_param(std::string("name")), true); + + // Verify that an incorrect commmand request is rejected + BOOST_CHECK_THROW(dummy_plugin.execute(bad_command_execute, command_reply), std::runtime_error); + + BOOST_REQUIRE_NO_THROW(command_execute.set_param(std::string("print/name"), std::string("width"))); + + // Verify that a supported commmand request is accepted + BOOST_REQUIRE_NO_THROW(dummy_plugin.execute(command_execute, command_reply)); +}; + +BOOST_AUTO_TEST_SUITE_END(); //DummyUDPProcessPluginUnitTest