#include "ActiveFeeder.hh"
#include "DebugModules.hh"
#include "Setup.hh"
+#include "CloneSource.hh"
+#include <senf/Scheduler/Scheduler.hh>
+#include <senf/Utils/membind.hh>
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
#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////////////////////////////////////////
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
+namespace ppi = senf::ppi;
+namespace connector = ppi::connector;
+namespace module = ppi::module;
+namespace debug = module::debug;
namespace {
struct IntAnnotation {
std::ostream & operator<<(std::ostream & os, IntAnnotation const & value)
{ os << value.value; return os; }
- struct AnnotationRouter : public senf::ppi::module::AnnotationRouter<IntAnnotation>
+ struct AnnotationRouter : public module::AnnotationRouter<IntAnnotation>
{
- using senf::ppi::module::AnnotationRouter<IntAnnotation>::connectors;
+ using module::AnnotationRouter<IntAnnotation>::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<IntAnnotation>::DuplicateKeyException);
+ BOOST_CHECK_THROW( connect(router, 2, sink2),
+ module::AnnotationRouter<IntAnnotation>::DuplicateKeyException);
- senf::ppi::init();
+ ppi::init();
senf::Packet p1 (senf::DataPacket::create());
p1.annotation<IntAnnotation>() = 1;
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////////////////////////////////////////
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)
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-
namespace ppi = senf::ppi;
namespace connector = ppi::connector;
namespace module = ppi::module;
{
# 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<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
typedef detail::ListOptionTypeParser_Policy<
senf::IPv6HopByHopOptionsPacket pext (senf::IPv6HopByHopOptionsPacket::createAfter(ip) );
pext->nextHeader() = 58u;
- pext->headerLength() = 0u;
{
senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC(pext->options() );
{