4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ActiveFeeder unit tests */
31 //#include "ActiveFeeder.test.hh"
32 //#include "ActiveFeeder.test.ih"
35 #include "ActiveFeeder.hh"
36 #include "DebugModules.hh"
38 #include "CloneSource.hh"
39 #include <senf/Scheduler/Scheduler.hh>
41 #include <senf/Utils/auto_unit_test.hh>
42 #include <boost/test/test_tools.hpp>
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 namespace debug = senf::ppi::module::debug;
47 namespace ppi = senf::ppi;
48 namespace module = senf::ppi::module;
49 namespace scheduler = senf::scheduler;
52 void run(senf::ClockService::clock_type t) {
53 scheduler::TimerEvent timeout (
54 "test-timeout", &scheduler::terminate, scheduler::now() + t);
59 SENF_AUTO_UNIT_TEST(activeFeeder)
61 senf::PacketData::byte data[] = { 0xab };
62 senf::Packet p (senf::DataPacket::create(data));
64 module::CloneSource source (p);
65 debug::PassiveSink sink;
66 module::ActiveFeeder feeder;
68 ppi::connect( source, feeder );
69 ppi::connect( feeder, sink );
71 senf::ClockService::clock_type start (senf::ClockService::now());
72 run( senf::ClockService::seconds(1));
73 std::cerr << "\nActiveFeeder: "
74 << (sink.size()*1e9)/ (SENF_CLOCKTYPEVAL(senf::ClockService::now()) - SENF_CLOCKTYPEVAL(start))
75 << " packets/s" << std::endl;
76 BOOST_CHECK( sink.size() > 0);
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"