From: tho Date: Tue, 27 Oct 2009 09:40:50 +0000 (+0000) Subject: Packets/DefaultBundle: made length field in IPv6HopByHopOptionsPacketParser read... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=22f72ccea5685d22d33f8c38b5ffb12dcf51928d;p=senf.git Packets/DefaultBundle: made length field in IPv6HopByHopOptionsPacketParser read only PPI: run ActiveFeeder unit test one second git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1507 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/ActiveFeeder.test.cc b/senf/PPI/ActiveFeeder.test.cc index 90d3722..fca6880 100644 --- a/senf/PPI/ActiveFeeder.test.cc +++ b/senf/PPI/ActiveFeeder.test.cc @@ -30,37 +30,49 @@ #include "ActiveFeeder.hh" #include "DebugModules.hh" #include "Setup.hh" +#include "CloneSource.hh" +#include +#include #include #include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// - namespace debug = senf::ppi::module::debug; namespace ppi = senf::ppi; namespace module = senf::ppi::module; +namespace scheduler = senf::scheduler; + +namespace { + void timeout() { + scheduler::terminate(); + } + + void run(senf::ClockService::clock_type t) { + scheduler::TimerEvent timeoutTimer ("timeoutTimer", &timeout, + senf::ClockService::now() + t); + ppi::run(); + } +} BOOST_AUTO_UNIT_TEST(activeFeeder) { - debug::PassiveSource source; + senf::PacketData::byte data[] = { 0xab }; + senf::Packet p (senf::DataPacket::create(data)); + + module::CloneSource source (p); debug::PassiveSink sink; module::ActiveFeeder feeder; - ppi::connect(source,feeder); - ppi::connect(feeder,sink); - - for (unsigned i (0); i < 500; ++i) - source.submit(senf::DataPacket::create()); + ppi::connect( source, feeder ); + ppi::connect( feeder, sink ); - senf::ClockService::clock_type start (senf::ClockService::now()); - ppi::run(); - std::cerr << "ActiveFeeder: " - << (500*1e9)/(senf::ClockService::now()-start) + senf::ClockService::clock_type start (senf::ClockService::now()); + run( senf::ClockService::seconds(1)); + std::cerr << "\nActiveFeeder: " + << (sink.size()*1e9)/(senf::ClockService::now()-start) << " packets/s" << std::endl; - - BOOST_CHECK_EQUAL( source.size(), 0u ); - BOOST_CHECK_EQUAL( sink.size(), 500u ); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/senf/PPI/AnnotationRouter.test.cc b/senf/PPI/AnnotationRouter.test.cc index 25fac4c..d862bd3 100644 --- a/senf/PPI/AnnotationRouter.test.cc +++ b/senf/PPI/AnnotationRouter.test.cc @@ -35,6 +35,10 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// +namespace ppi = senf::ppi; +namespace connector = ppi::connector; +namespace module = ppi::module; +namespace debug = module::debug; namespace { struct IntAnnotation { @@ -50,28 +54,28 @@ namespace { std::ostream & operator<<(std::ostream & os, IntAnnotation const & value) { os << value.value; return os; } - struct AnnotationRouter : public senf::ppi::module::AnnotationRouter + struct AnnotationRouter : public module::AnnotationRouter { - using senf::ppi::module::AnnotationRouter::connectors; + using module::AnnotationRouter::connectors; }; } BOOST_AUTO_UNIT_TEST(annotationRouter) { - senf::ppi::module::debug::ActiveSource source; - senf::ppi::module::debug::PassiveSink sink1; - senf::ppi::module::debug::PassiveSink sink2; + debug::ActiveSource source; + debug::PassiveSink sink1; + debug::PassiveSink sink2; AnnotationRouter router; - senf::ppi::connect(source, router); - senf::ppi::connect(router, 1, sink1); - senf::ppi::connect(router, 2, sink2); + ppi::connect(source, router); + ppi::connect(router, 1, sink1); + ppi::connect(router, 2, sink2); - BOOST_CHECK_THROW( senf::ppi::connect(router, 2, sink2), - senf::ppi::module::AnnotationRouter::DuplicateKeyException); + BOOST_CHECK_THROW( connect(router, 2, sink2), + module::AnnotationRouter::DuplicateKeyException); - senf::ppi::init(); + ppi::init(); senf::Packet p1 (senf::DataPacket::create()); p1.annotation() = 1; @@ -86,9 +90,23 @@ BOOST_AUTO_UNIT_TEST(annotationRouter) BOOST_CHECK_EQUAL( sink2.size(), 1u ); BOOST_CHECK( sink1.front() == p1 ); BOOST_CHECK( sink2.front() == p2 ); - BOOST_CHECK_EQUAL(router.connectors().size(), 2u); + sink1.input.disconnect(); + BOOST_CHECK_EQUAL(router.connectors().size(), 1u); + + source.submit(p1); + source.submit(p2); + BOOST_CHECK_EQUAL( sink1.size(), 1u ); + BOOST_CHECK_EQUAL( sink2.size(), 2u ); + +// ppi::connect(router, 1, sink1); +// ppi::init(); +// +// source.submit(p1); +// source.submit(p2); +// BOOST_CHECK_EQUAL( sink1.size(), 2u ); +// BOOST_CHECK_EQUAL( sink2.size(), 3u ); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/senf/PPI/Joins.test.cc b/senf/PPI/Joins.test.cc index d84a98a..772a761 100644 --- a/senf/PPI/Joins.test.cc +++ b/senf/PPI/Joins.test.cc @@ -84,6 +84,9 @@ BOOST_AUTO_UNIT_TEST(passiveJoin) BOOST_CHECK_EQUAL( join.connectors().size(), 2u); source1.output.disconnect(); BOOST_CHECK_EQUAL( join.connectors().size(), 1u); + ppi::connect(source1, join); + ppi::init(); + BOOST_CHECK_EQUAL( join.connectors().size(), 2u); } BOOST_AUTO_UNIT_TEST(priorityJoin) diff --git a/senf/PPI/MultiConnectorMixin.test.cc b/senf/PPI/MultiConnectorMixin.test.cc index 498ce00..b4d307e 100644 --- a/senf/PPI/MultiConnectorMixin.test.cc +++ b/senf/PPI/MultiConnectorMixin.test.cc @@ -34,7 +34,6 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// - namespace ppi = senf::ppi; namespace connector = ppi::connector; namespace module = ppi::module; diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.hh b/senf/Packets/DefaultBundle/IPv6Extensions.hh index a7294e0..34f2e83 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.hh +++ b/senf/Packets/DefaultBundle/IPv6Extensions.hh @@ -229,8 +229,8 @@ namespace senf { { # include SENF_PARSER() - SENF_PARSER_FIELD ( nextHeader, UInt8Parser ); - SENF_PARSER_FIELD ( headerLength, UInt8Parser ); + SENF_PARSER_FIELD ( nextHeader, UInt8Parser ); + SENF_PARSER_FIELD_RO ( headerLength, UInt8Parser ); typedef detail::FixedAuxParserPolicy ListOptionTypeAuxPolicy; typedef detail::ListOptionTypeParser_Policy< diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc index b0ef3cf..c25f389 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc +++ b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc @@ -277,7 +277,6 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create) senf::IPv6HopByHopOptionsPacket pext (senf::IPv6HopByHopOptionsPacket::createAfter(ip) ); pext->nextHeader() = 58u; - pext->headerLength() = 0u; { senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC(pext->options() ); {