From: tho Date: Mon, 11 May 2009 11:40:42 +0000 (+0000) Subject: added test for connect on runtime problem X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3ebdf2d95eee32c49a019a5e93b201aa177f5530;p=senf.git added test for connect on runtime problem git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1202 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/Route.test.cc b/PPI/Route.test.cc index 24892bf..233fab1 100644 --- a/PPI/Route.test.cc +++ b/PPI/Route.test.cc @@ -32,6 +32,10 @@ #include "DebugModules.hh" #include "Module.hh" #include "Setup.hh" +#include "CloneSource.hh" +#include "Joins.hh" +#include "PassiveQueue.hh" +#include "../Utils/membind.hh" #include "../Utils/auto_unit_test.hh" #include @@ -172,6 +176,67 @@ BOOST_AUTO_UNIT_TEST(route) BOOST_CHECK( activeSink ); } +/////////////////////////////////////////////////// +// test connection new modules on runtime + +namespace { + void timeout() { + senf::scheduler::terminate(); + } + + // just a helper class for the test + struct ModuleConnector { + module::PriorityJoin & join_; + ModuleConnector( module::PriorityJoin & join) + : join_( join) {}; + void connect() { + module::PassiveQueue * queue = new module::PassiveQueue; + ppi::connect( *queue, join_, 0); + } + }; + + class TestSink : public module::Module + { + SENF_PPI_MODULE(TestSink); + public: + connector::PassiveInput<> input; + TestSink() { + noroute(input); + input.onRequest(&TestSink::request); + } + private: + void request() { + (void) input.read().data(); + } + }; +} + +BOOST_AUTO_UNIT_TEST(connect_runtime) +{ + TestSink sink; + module::ActiveFeeder feeder; + module::PriorityJoin join; + module::CloneSource source1 (senf::DataPacket::create()); + module::PassiveQueue queue; + + ppi::connect( feeder, sink); + ppi::connect( join, feeder); + ppi::connect( source1, join); + + ModuleConnector moduleConnector ( join); + senf::scheduler::TimerEvent timer ( "connect_runtime timer", + senf::membind(&ModuleConnector::connect, moduleConnector), + senf::ClockService::now() + senf::ClockService::milliseconds(25)); + + senf::scheduler::TimerEvent timeoutTimer ( + "connect_runtime test timeoutTimer", &timeout, + senf::ClockService::now() + senf::ClockService::milliseconds(50)); + +// senf::ppi::run(); +} + + + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_