X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FRoute.test.cc;h=24892bf8f7ba8270e02d4128d43f59931d5ff792;hb=f2f5d59e83863f3b513950173baee1b6da2aee3c;hp=45b45cac15af87dd62833407f86cfcf5d235a926;hpb=7465ea4f6d3d54622bd783106cf8b60d5f133343;p=senf.git diff --git a/PPI/Route.test.cc b/PPI/Route.test.cc index 45b45ca..24892bf 100644 --- a/PPI/Route.test.cc +++ b/PPI/Route.test.cc @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// 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,7 +21,7 @@ // 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" @@ -33,7 +33,7 @@ #include "Module.hh" #include "Setup.hh" -#include +#include "../Utils/auto_unit_test.hh" #include #define prefix_ @@ -47,12 +47,14 @@ namespace debug = module::debug; namespace { class RouteTester : public module::Module { + SENF_PPI_MODULE(RouteTester); + public: - connector::ActiveInput activeIn; - connector::PassiveInput passiveIn; + connector::ActiveInput<> activeIn; + connector::PassiveInput<> passiveIn; - connector::ActiveOutput activeOut; - connector::PassiveOutput passiveOut; + connector::ActiveOutput<> activeOut; + connector::PassiveOutput<> passiveOut; ppi::DebugEvent event; @@ -68,7 +70,7 @@ namespace { passiveIn.onRequest(&RouteTester::inputRequest); passiveOut.onRequest(&RouteTester::outputRequest); - registerEvent(&RouteTester::onEvent, event); + registerEvent(event, &RouteTester::onEvent); activeIn.onThrottle(&RouteTester::throttleRequest); activeIn.onUnthrottle(&RouteTester::unthrottleRequest); @@ -103,16 +105,16 @@ namespace { BOOST_AUTO_UNIT_TEST(route) { - debug::PassivePacketSource passiveSource; - debug::ActivePacketSource activeSource; - debug::PassivePacketSink passiveSink; - debug::ActivePacketSink activeSink; + debug::PassiveSource passiveSource; + debug::ActiveSource activeSource; + debug::PassiveSink passiveSink; + debug::ActiveSink activeSink; RouteTester tester; - ppi::connect(passiveSource.output, tester.activeIn); - ppi::connect(activeSource.output, tester.passiveIn); - ppi::connect(tester.activeOut, passiveSink.input); - ppi::connect(tester.passiveOut, activeSink.input); + ppi::connect(passiveSource, tester.activeIn); + ppi::connect(activeSource, tester.passiveIn); + ppi::connect(tester.activeOut, passiveSink); + ppi::connect(tester.passiveOut, activeSink); ppi::init(); @@ -131,14 +133,13 @@ BOOST_AUTO_UNIT_TEST(route) BOOST_CHECK( ! tester.activeOut ); BOOST_CHECK_EQUAL( tester.throttles, 1 ); BOOST_CHECK( tester.passiveIn.throttled() ); - BOOST_CHECK( ! activeSource.output ); + BOOST_CHECK( ! activeSource ); BOOST_CHECK( ! tester.event.enabled() ); passiveSink.input.unthrottle(); - BOOST_CHECK( activeSource.output ); + BOOST_CHECK( activeSource ); BOOST_CHECK( tester.event.enabled() ); - // Now throttle the passive source by exhausting the queue BOOST_CHECK( p1 == activeSink.request() ); @@ -146,18 +147,29 @@ BOOST_AUTO_UNIT_TEST(route) BOOST_CHECK( ! tester.activeIn ); BOOST_CHECK_EQUAL( tester.throttles, 1 ); BOOST_CHECK( tester.passiveOut.throttled() ); - BOOST_CHECK( ! activeSink.input ); + BOOST_CHECK( ! activeSink ); BOOST_CHECK( ! tester.event.enabled() ); passiveSource.submit(p1); - BOOST_CHECK( activeSink.input ); + BOOST_CHECK( activeSink ); + BOOST_CHECK( tester.event.enabled() ); + + // Check correct combination of multiple throttling events + + activeSink.request(); + BOOST_CHECK( ! tester.event.enabled() ); + passiveSink.input.throttle(); + BOOST_CHECK( ! tester.event.enabled() ); + passiveSource.submit(p1); + BOOST_CHECK( ! tester.event.enabled() ); + passiveSink.input.unthrottle(); BOOST_CHECK( tester.event.enabled() ); tester.rt->autoThrottling(false); BOOST_CHECK( p1 == activeSink.request() ); BOOST_CHECK( passiveSource.output.throttled() ); - BOOST_CHECK( activeSink.input ); + BOOST_CHECK( activeSink ); } ///////////////////////////////cc.e////////////////////////////////////////