X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FRoute.test.cc;h=68e7ffdafc6d1c62bb92f1a8902211608a6d8d03;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=1db8183bfad6bf44d21e83868b68e3bae88e6f68;hpb=416cdd1c85cdf2669785e93a71426a3206166758;p=senf.git diff --git a/PPI/Route.test.cc b/PPI/Route.test.cc index 1db8183..68e7ffd 100644 --- a/PPI/Route.test.cc +++ b/PPI/Route.test.cc @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -21,17 +21,23 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Route.test unit tests */ + \brief Route unit tests */ //#include "Route.test.hh" //#include "Route.test.ih" // Custom includes +#include #include "Route.hh" #include "DebugEvent.hh" #include "DebugModules.hh" #include "Module.hh" #include "Setup.hh" +#include "CloneSource.hh" +#include "Joins.hh" +#include "PassiveQueue.hh" +#include "../Utils/membind.hh" +#include "../Utils/senfassert.hh" #include "../Utils/auto_unit_test.hh" #include @@ -172,6 +178,66 @@ 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() { + queue.reset(new module::PassiveQueue); + ppi::connect( *queue, join_, 0); + } + boost::scoped_ptr queue; + }; + + class TestSink : public module::Module + { + SENF_PPI_MODULE(TestSink); + public: + connector::PassiveInput<> input; + TestSink() { + noroute(input); + input.onRequest(&TestSink::request); + } + private: + void request() { + SENF_ASSERT(input()); + } + }; +} + +BOOST_AUTO_UNIT_TEST(connect_runtime) +{ + TestSink sink; + module::ActiveFeeder feeder; + module::PriorityJoin join; + module::CloneSource source1 (senf::DataPacket::create()); + + ppi::connect( source1, join); + ppi::connect( join, feeder); + ppi::connect( feeder, sink); + + ModuleConnector moduleConnector ( join); + senf::scheduler::TimerEvent timer ( + "connect_runtime timer", + senf::membind(&ModuleConnector::connect, &moduleConnector), + senf::ClockService::now() + senf::ClockService::milliseconds(250)); + + senf::scheduler::TimerEvent timeoutTimer ( + "connect_runtime test timeoutTimer", &timeout, + senf::ClockService::now() + senf::ClockService::milliseconds(500)); + + senf::ppi::run(); +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_