0081fcca894980e209b2f90f128caa1932e74685
[senf.git] / senf / PPI / ActiveFeeder.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
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
10 //
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.
14 //
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.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
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.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief ActiveFeeder unit tests */
30
31 //#include "ActiveFeeder.test.hh"
32 //#include "ActiveFeeder.test.ih"
33
34 // Custom includes
35 #include "ActiveFeeder.hh"
36 #include "DebugModules.hh"
37 #include "Setup.hh"
38 #include "CloneSource.hh"
39 #include <senf/Scheduler/Scheduler.hh>
40
41 #include <senf/Utils/auto_unit_test.hh>
42 #include <boost/test/test_tools.hpp>
43
44 #define prefix_
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 namespace debug = senf::ppi::module::debug;
47 namespace ppi = senf::ppi;
48 namespace module = senf::ppi::module;
49 namespace scheduler = senf::scheduler;
50
51 namespace {
52     void run(senf::ClockService::clock_type t) {
53         scheduler::TimerEvent timeout (
54                 "test-timeout", &scheduler::terminate, scheduler::now() + t);
55         ppi::run();
56     }
57 }
58
59 SENF_AUTO_UNIT_TEST(activeFeeder)
60 {
61     senf::PacketData::byte data[] = { 0xab };
62     senf::Packet p (senf::DataPacket::create(data));
63
64     module::CloneSource source (p);
65     debug::PassiveSink sink;
66     module::ActiveFeeder feeder;
67
68     ppi::connect( source, feeder );
69     ppi::connect( feeder, sink   );
70
71     senf::ClockService::clock_type start (senf::ClockService::now());
72     run( senf::ClockService::seconds(1));
73     std::cerr << "\nActiveFeeder: "
74               << (sink.size()*1e9)/(senf::ClockService::now()-start)
75               << " packets/s" << std::endl;
76     BOOST_CHECK( sink.size() > 0);
77 }
78
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
80 #undef prefix_
81
82 \f
83 // Local Variables:
84 // mode: c++
85 // fill-column: 100
86 // comment-column: 40
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"
91 // End: