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 Queueing unit tests */
31 //#include "Queueing.test.hh"
32 //#include "Queueing.test.ih"
35 #include "Queueing.hh"
37 #include "Connectors.hh"
38 #include "DebugModules.hh"
39 #include <senf/Packets/Packets.hh>
42 #include <senf/Utils/auto_unit_test.hh>
43 #include <boost/test/test_tools.hpp>
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 namespace ppi = senf::ppi;
49 namespace connector = ppi::connector;
50 namespace module = ppi::module;
51 namespace debug = module::debug;
54 class QueueTester : public module::Module
56 SENF_PPI_MODULE(QueueTester);
58 connector::PassiveInput<> input;
59 connector::ActiveOutput<> output;
63 input.qdisc(ppi::ThresholdQueueing(2,1));
64 input.onRequest(&QueueTester::nop);
67 void nop() { /* no operation */ }
77 SENF_AUTO_UNIT_TEST(PPI_Queueing)
79 debug::ActiveSource source;
81 debug::PassiveSink sink;
83 ppi::connect(source, tester);
84 ppi::connect(tester, sink);
87 senf::Packet p (senf::DataPacket::create());
89 BOOST_CHECK( source );
91 BOOST_CHECK( source );
93 BOOST_CHECK( ! source );
94 BOOST_CHECK_EQUAL( tester.input.queueSize(), 2u );
96 BOOST_CHECK_EQUAL( tester.input.queueSize(), 1u );
97 BOOST_CHECK( source );
99 BOOST_CHECK_EQUAL( tester.input.queueSize(), 0u );
100 BOOST_CHECK( source );
101 BOOST_CHECK_EQUAL( sink.size(), 2u);
105 tester.input.qdisc(ppi::QueueingDiscipline::NONE);
106 BOOST_CHECK( source );
108 BOOST_CHECK( source );
110 BOOST_CHECK( source );
111 BOOST_CHECK_EQUAL( tester.input.queueSize(), 2u );
114 BOOST_CHECK( source );
115 BOOST_CHECK_EQUAL( tester.input.queueSize(), 0u );
116 BOOST_CHECK_EQUAL( sink.size(), 2u);
120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
127 // comment-column: 40
128 // c-file-style: "senf"
129 // indent-tabs-mode: nil
130 // ispell-local-dictionary: "american"
131 // compile-command: "scons -u test"