X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FRoute.test.cc;h=08e5125758e1377e07e2c614596240d03ca98be8;hb=394a298567543441521439ad15f7016cd569c449;hp=45b45cac15af87dd62833407f86cfcf5d235a926;hpb=7465ea4f6d3d54622bd783106cf8b60d5f133343;p=senf.git diff --git a/PPI/Route.test.cc b/PPI/Route.test.cc index 45b45ca..08e5125 100644 --- a/PPI/Route.test.cc +++ b/PPI/Route.test.cc @@ -47,6 +47,8 @@ namespace debug = module::debug; namespace { class RouteTester : public module::Module { + SENF_PPI_MODULE(RouteTester); + public: connector::ActiveInput activeIn; connector::PassiveInput passiveIn; @@ -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////////////////////////////////////////