Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 319f2c8 | 2015-01-07 14:56:53 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2015, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 24 | */ |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 25 | |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 26 | #include "face/unix-stream-factory.hpp" |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 27 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 28 | #include "tests/test-common.hpp" |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 29 | #include "tests/limited-io.hpp" |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 30 | #include "dummy-stream-sender.hpp" |
| 31 | #include "packet-datasets.hpp" |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 32 | |
| 33 | namespace nfd { |
| 34 | namespace tests { |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 35 | |
| 36 | using namespace boost::asio::local; |
| 37 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 38 | #define CHANNEL_PATH1 "unix-stream-test.1.sock" |
| 39 | #define CHANNEL_PATH2 "unix-stream-test.2.sock" |
| 40 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 41 | BOOST_FIXTURE_TEST_SUITE(FaceUnixStream, BaseFixture) |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 42 | |
| 43 | BOOST_AUTO_TEST_CASE(ChannelMap) |
| 44 | { |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 45 | UnixStreamFactory factory; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 46 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 47 | shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1); |
| 48 | shared_ptr<UnixStreamChannel> channel1a = factory.createChannel(CHANNEL_PATH1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 49 | BOOST_CHECK_EQUAL(channel1, channel1a); |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 50 | std::string channel1uri = channel1->getUri().toString(); |
| 51 | BOOST_CHECK_EQUAL(channel1uri.find("unix:///"), 0); // third '/' is the path separator |
| 52 | BOOST_CHECK_EQUAL(channel1uri.rfind(CHANNEL_PATH1), |
| 53 | channel1uri.size() - std::string(CHANNEL_PATH1).size()); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 54 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 55 | shared_ptr<UnixStreamChannel> channel2 = factory.createChannel(CHANNEL_PATH2); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 56 | BOOST_CHECK_NE(channel1, channel2); |
| 57 | } |
| 58 | |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 59 | BOOST_AUTO_TEST_CASE(GetChannels) |
| 60 | { |
| 61 | UnixStreamFactory factory; |
| 62 | BOOST_REQUIRE_EQUAL(factory.getChannels().empty(), true); |
| 63 | |
| 64 | std::vector<shared_ptr<const Channel> > expectedChannels; |
| 65 | |
| 66 | expectedChannels.push_back(factory.createChannel(CHANNEL_PATH1)); |
| 67 | expectedChannels.push_back(factory.createChannel(CHANNEL_PATH2)); |
| 68 | |
| 69 | std::list<shared_ptr<const Channel> > channels = factory.getChannels(); |
| 70 | for (std::list<shared_ptr<const Channel> >::const_iterator i = channels.begin(); |
| 71 | i != channels.end(); ++i) |
| 72 | { |
| 73 | std::vector<shared_ptr<const Channel> >::iterator pos = |
| 74 | std::find(expectedChannels.begin(), expectedChannels.end(), *i); |
| 75 | |
| 76 | BOOST_REQUIRE(pos != expectedChannels.end()); |
| 77 | expectedChannels.erase(pos); |
| 78 | } |
| 79 | |
| 80 | BOOST_CHECK_EQUAL(expectedChannels.size(), 0); |
| 81 | } |
| 82 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 83 | class EndToEndFixture : protected BaseFixture |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 84 | { |
| 85 | public: |
| 86 | void |
| 87 | client_onConnect(const boost::system::error_code& error) |
| 88 | { |
| 89 | BOOST_CHECK_MESSAGE(!error, error.message()); |
| 90 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 91 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 95 | channel1_onFaceCreated(const shared_ptr<Face>& newFace) |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 96 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 97 | BOOST_CHECK(!static_cast<bool>(face1)); |
| 98 | face1 = static_pointer_cast<UnixStreamFace>(newFace); |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 99 | face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1)); |
| 100 | face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 101 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 102 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | void |
| 106 | channel1_onConnectFailed(const std::string& reason) |
| 107 | { |
| 108 | BOOST_CHECK_MESSAGE(false, reason); |
| 109 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 110 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 111 | } |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 112 | |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 113 | void |
| 114 | face1_onReceiveInterest(const Interest& interest) |
| 115 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 116 | face1_receivedInterests.push_back(interest); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 117 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 118 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 119 | } |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 120 | |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 121 | void |
| 122 | face1_onReceiveData(const Data& data) |
| 123 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 124 | face1_receivedDatas.push_back(data); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 125 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 126 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | void |
| 130 | face2_onReceiveInterest(const Interest& interest) |
| 131 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 132 | face2_receivedInterests.push_back(interest); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 133 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 134 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 135 | } |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 136 | |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 137 | void |
| 138 | face2_onReceiveData(const Data& data) |
| 139 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 140 | face2_receivedDatas.push_back(data); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 141 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 142 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | void |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 146 | channel_onFaceCreated(const shared_ptr<Face>& newFace) |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 147 | { |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 148 | faces.push_back(static_pointer_cast<UnixStreamFace>(newFace)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 149 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 150 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | void |
| 154 | channel_onConnectFailed(const std::string& reason) |
| 155 | { |
| 156 | BOOST_CHECK_MESSAGE(false, reason); |
| 157 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 158 | limitedIo.afterOp(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | protected: |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 162 | LimitedIo limitedIo; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 163 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 164 | shared_ptr<UnixStreamFace> face1; |
| 165 | std::vector<Interest> face1_receivedInterests; |
| 166 | std::vector<Data> face1_receivedDatas; |
| 167 | shared_ptr<UnixStreamFace> face2; |
| 168 | std::vector<Interest> face2_receivedInterests; |
| 169 | std::vector<Data> face2_receivedDatas; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 170 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 171 | std::list< shared_ptr<UnixStreamFace> > faces; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | |
| 175 | BOOST_FIXTURE_TEST_CASE(EndToEnd, EndToEndFixture) |
| 176 | { |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 177 | UnixStreamFactory factory; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 178 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 179 | shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 180 | channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 181 | bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
| 182 | |
Alexander Afanasyev | f698028 | 2014-05-13 18:28:40 -0700 | [diff] [blame] | 183 | shared_ptr<stream_protocol::socket> client = make_shared<stream_protocol::socket>(ref(g_io)); |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 184 | client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1), |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 185 | bind(&EndToEndFixture::client_onConnect, this, _1)); |
| 186 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 187 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 188 | "UnixStreamChannel error: cannot connect or cannot accept connection"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 189 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 190 | BOOST_REQUIRE(static_cast<bool>(face1)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 191 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 192 | BOOST_CHECK_EQUAL(face1->getRemoteUri().getScheme(), "fd"); |
| 193 | BOOST_CHECK_NO_THROW(boost::lexical_cast<int>(face1->getRemoteUri().getHost())); |
| 194 | std::string face1localUri = face1->getLocalUri().toString(); |
| 195 | BOOST_CHECK_EQUAL(face1localUri.find("unix:///"), 0); // third '/' is the path separator |
| 196 | BOOST_CHECK_EQUAL(face1localUri.rfind(CHANNEL_PATH1), |
| 197 | face1localUri.size() - std::string(CHANNEL_PATH1).size()); |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 198 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 199 | face2 = make_shared<UnixStreamFace>(client); |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 200 | face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1)); |
| 201 | face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 202 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 203 | shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R"); |
| 204 | shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix"); |
| 205 | shared_ptr<Interest> interest2 = makeInterest("ndn:/QWiIMfj5sL"); |
| 206 | shared_ptr<Data> data2 = makeData("ndn:/XNBV796f"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 207 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 208 | face1->sendInterest(*interest1); |
| 209 | face1->sendInterest(*interest1); |
| 210 | face1->sendInterest(*interest1); |
| 211 | face1->sendData (*data1 ); |
Junxiao Shi | 5dd26c3 | 2014-07-20 23:15:14 -0700 | [diff] [blame] | 212 | size_t nBytesSent1 = interest1->wireEncode().size() * 3 + data1->wireEncode().size(); |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 213 | face2->sendInterest(*interest2); |
| 214 | face2->sendData (*data2 ); |
| 215 | face2->sendData (*data2 ); |
| 216 | face2->sendData (*data2 ); |
Junxiao Shi | 5dd26c3 | 2014-07-20 23:15:14 -0700 | [diff] [blame] | 217 | size_t nBytesSent2 = interest2->wireEncode().size() + data2->wireEncode().size() * 3; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 218 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 219 | BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 220 | "UnixStreamChannel error: cannot send or receive Interest/Data packets"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 221 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 222 | BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1); |
| 223 | BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 3); |
| 224 | BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3); |
| 225 | BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 226 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 227 | BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2->getName()); |
| 228 | BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2->getName()); |
| 229 | BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1->getName()); |
| 230 | BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1->getName()); |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame] | 231 | |
Junxiao Shi | 5dd26c3 | 2014-07-20 23:15:14 -0700 | [diff] [blame] | 232 | // needed to ensure NOutBytes counters are accurate |
| 233 | limitedIo.run(LimitedIo::UNLIMITED_OPS, time::seconds(1)); |
| 234 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 235 | const FaceCounters& counters1 = face1->getCounters(); |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 236 | BOOST_CHECK_EQUAL(counters1.getNInInterests() , 1); |
| 237 | BOOST_CHECK_EQUAL(counters1.getNInDatas() , 3); |
| 238 | BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3); |
| 239 | BOOST_CHECK_EQUAL(counters1.getNOutDatas() , 1); |
Junxiao Shi | 5dd26c3 | 2014-07-20 23:15:14 -0700 | [diff] [blame] | 240 | BOOST_CHECK_EQUAL(counters1.getNInBytes(), nBytesSent2); |
| 241 | BOOST_CHECK_EQUAL(counters1.getNOutBytes(), nBytesSent1); |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame] | 242 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 243 | const FaceCounters& counters2 = face2->getCounters(); |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 244 | BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3); |
| 245 | BOOST_CHECK_EQUAL(counters2.getNInDatas() , 1); |
| 246 | BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 1); |
| 247 | BOOST_CHECK_EQUAL(counters2.getNOutDatas() , 3); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture) |
| 251 | { |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 252 | UnixStreamFactory factory; |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 253 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 254 | shared_ptr<UnixStreamChannel> channel = factory.createChannel(CHANNEL_PATH1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 255 | channel->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1), |
| 256 | bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
| 257 | |
Alexander Afanasyev | f698028 | 2014-05-13 18:28:40 -0700 | [diff] [blame] | 258 | shared_ptr<stream_protocol::socket> client1 = make_shared<stream_protocol::socket>(ref(g_io)); |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 259 | client1->async_connect(stream_protocol::endpoint(CHANNEL_PATH1), |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 260 | bind(&EndToEndFixture::client_onConnect, this, _1)); |
| 261 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 262 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 263 | "UnixStreamChannel error: cannot connect or cannot accept connection"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 264 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 265 | BOOST_CHECK_EQUAL(faces.size(), 1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 266 | |
Alexander Afanasyev | f698028 | 2014-05-13 18:28:40 -0700 | [diff] [blame] | 267 | shared_ptr<stream_protocol::socket> client2 = make_shared<stream_protocol::socket>(ref(g_io)); |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 268 | client2->async_connect(stream_protocol::endpoint(CHANNEL_PATH1), |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 269 | bind(&EndToEndFixture::client_onConnect, this, _1)); |
| 270 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 271 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 272 | "UnixStreamChannel error: cannot accept multiple connections"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 273 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 274 | BOOST_CHECK_EQUAL(faces.size(), 2); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 275 | |
| 276 | // now close one of the faces |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 277 | faces.front()->close(); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 278 | |
| 279 | // we should still be able to send/receive with the other one |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 280 | face1 = faces.back(); |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 281 | face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1)); |
| 282 | face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 283 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 284 | face2 = make_shared<UnixStreamFace>(client2); |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 285 | face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1)); |
| 286 | face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1)); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 287 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 288 | shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R"); |
| 289 | shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix"); |
| 290 | shared_ptr<Interest> interest2 = makeInterest("ndn:/QWiIMfj5sL"); |
| 291 | shared_ptr<Data> data2 = makeData("ndn:/XNBV796f"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 292 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 293 | face1->sendInterest(*interest1); |
| 294 | face1->sendData (*data1 ); |
| 295 | face2->sendInterest(*interest2); |
| 296 | face2->sendData (*data2 ); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 297 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 298 | BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 299 | "UnixStreamChannel error: cannot send or receive Interest/Data packets"); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 300 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 301 | BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1); |
| 302 | BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1); |
| 303 | BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1); |
| 304 | BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 305 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 306 | BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2->getName()); |
| 307 | BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2->getName()); |
| 308 | BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1->getName()); |
| 309 | BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1->getName()); |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 310 | } |
| 311 | |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 312 | static inline void |
| 313 | noOp() |
| 314 | { |
| 315 | } |
| 316 | |
| 317 | BOOST_FIXTURE_TEST_CASE(UnixStreamFaceLocalControlHeader, EndToEndFixture) |
| 318 | { |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 319 | UnixStreamFactory factory; |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 320 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 321 | shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 322 | channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 323 | bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
| 324 | |
Alexander Afanasyev | f698028 | 2014-05-13 18:28:40 -0700 | [diff] [blame] | 325 | shared_ptr<stream_protocol::socket> client = make_shared<stream_protocol::socket>(ref(g_io)); |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 326 | client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1), |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 327 | bind(&EndToEndFixture::client_onConnect, this, _1)); |
| 328 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 329 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 330 | "UnixStreamChannel error: cannot connect or cannot accept connection"); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 331 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 332 | BOOST_REQUIRE(static_cast<bool>(face1)); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 333 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 334 | face2 = make_shared<UnixStreamFace>(client); |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 335 | face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1)); |
| 336 | face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1)); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 337 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 338 | shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R"); |
| 339 | shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix"); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 340 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 341 | face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 342 | face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 343 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 344 | BOOST_CHECK(face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 345 | BOOST_CHECK(face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 346 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 347 | face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 348 | face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 349 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 350 | BOOST_CHECK(face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 351 | BOOST_CHECK(face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 352 | |
| 353 | //////////////////////////////////////////////////////// |
| 354 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 355 | interest1->setIncomingFaceId(11); |
| 356 | interest1->setNextHopFaceId(111); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 357 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 358 | face1->sendInterest(*interest1); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 359 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 360 | data1->setIncomingFaceId(22); |
| 361 | data1->getLocalControlHeader().setNextHopFaceId(222); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 362 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 363 | face1->sendData(*data1); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 364 | |
| 365 | // |
| 366 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 367 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 368 | "UnixStreamChannel error: cannot send or receive Interest/Data packets"); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 369 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 370 | BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1); |
| 371 | BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 372 | |
| 373 | // sending allows only IncomingFaceId, receiving allows only NextHopFaceId |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 374 | BOOST_CHECK_EQUAL(face2_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false); |
| 375 | BOOST_CHECK_EQUAL(face2_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), false); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 376 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 377 | BOOST_CHECK_EQUAL(face2_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false); |
| 378 | BOOST_CHECK_EQUAL(face2_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 379 | |
| 380 | //////////////////////////////////////////////////////// |
| 381 | |
| 382 | using namespace boost::asio; |
| 383 | |
| 384 | std::vector<const_buffer> interestWithHeader; |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 385 | Block iHeader = interest1->getLocalControlHeader().wireEncode(*interest1, true, true); |
| 386 | Block iPayload = interest1->wireEncode(); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 387 | interestWithHeader.push_back(buffer(iHeader.wire(), iHeader.size())); |
| 388 | interestWithHeader.push_back(buffer(iPayload.wire(), iPayload.size())); |
| 389 | |
| 390 | std::vector<const_buffer> dataWithHeader; |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 391 | Block dHeader = data1->getLocalControlHeader().wireEncode(*data1, true, true); |
| 392 | Block dPayload = data1->wireEncode(); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 393 | dataWithHeader.push_back(buffer(dHeader.wire(), dHeader.size())); |
| 394 | dataWithHeader.push_back(buffer(dPayload.wire(), dPayload.size())); |
| 395 | |
| 396 | // |
| 397 | |
| 398 | client->async_send(interestWithHeader, bind(&noOp)); |
| 399 | client->async_send(dataWithHeader, bind(&noOp)); |
| 400 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 401 | BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 402 | "UnixStreamChannel error: cannot send or receive Interest/Data packets"); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 403 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 404 | BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1); |
| 405 | BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 406 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 407 | BOOST_CHECK_EQUAL(face1_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false); |
| 408 | BOOST_CHECK_EQUAL(face1_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), true); |
| 409 | BOOST_CHECK_EQUAL(face1_receivedInterests[0].getNextHopFaceId(), 111); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 410 | |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 411 | BOOST_CHECK_EQUAL(face1_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false); |
| 412 | BOOST_CHECK_EQUAL(face1_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false); |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 415 | |
| 416 | class SimpleEndToEndFixture : protected BaseFixture |
| 417 | { |
| 418 | public: |
| 419 | void |
| 420 | onFaceCreated(const shared_ptr<Face>& face) |
| 421 | { |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 422 | face->onReceiveInterest.connect(bind(&SimpleEndToEndFixture::onReceiveInterest, this, _1)); |
| 423 | face->onReceiveData.connect(bind(&SimpleEndToEndFixture::onReceiveData, this, _1)); |
| 424 | face->onFail.connect(bind(&SimpleEndToEndFixture::onFail, this, face)); |
Alexander Afanasyev | 650028d | 2014-04-25 18:39:10 -0700 | [diff] [blame] | 425 | |
| 426 | if (static_cast<bool>(dynamic_pointer_cast<LocalFace>(face))) { |
| 427 | static_pointer_cast<LocalFace>(face)->setLocalControlHeaderFeature( |
| 428 | LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 429 | |
| 430 | static_pointer_cast<LocalFace>(face)->setLocalControlHeaderFeature( |
| 431 | LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
| 432 | } |
| 433 | |
| 434 | limitedIo.afterOp(); |
| 435 | } |
| 436 | |
| 437 | void |
| 438 | onConnectFailed(const std::string& reason) |
| 439 | { |
| 440 | BOOST_CHECK_MESSAGE(false, reason); |
| 441 | |
| 442 | limitedIo.afterOp(); |
| 443 | } |
| 444 | |
| 445 | void |
| 446 | onReceiveInterest(const Interest& interest) |
| 447 | { |
| 448 | receivedInterests.push_back(interest); |
| 449 | |
| 450 | limitedIo.afterOp(); |
| 451 | } |
| 452 | |
| 453 | void |
| 454 | onReceiveData(const Data& data) |
| 455 | { |
| 456 | receivedDatas.push_back(data); |
| 457 | |
| 458 | limitedIo.afterOp(); |
| 459 | } |
| 460 | |
| 461 | void |
| 462 | onFail(const shared_ptr<Face>& face) |
| 463 | { |
| 464 | limitedIo.afterOp(); |
| 465 | } |
| 466 | |
| 467 | public: |
| 468 | LimitedIo limitedIo; |
| 469 | |
| 470 | std::vector<Interest> receivedInterests; |
| 471 | std::vector<Data> receivedDatas; |
| 472 | }; |
| 473 | |
| 474 | |
| 475 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(CorruptedInput, Dataset, |
| 476 | CorruptedPackets, SimpleEndToEndFixture) |
| 477 | { |
| 478 | UnixStreamFactory factory; |
| 479 | |
| 480 | shared_ptr<UnixStreamChannel> channel = factory.createChannel(CHANNEL_PATH1); |
| 481 | channel->listen(bind(&SimpleEndToEndFixture::onFaceCreated, this, _1), |
| 482 | bind(&SimpleEndToEndFixture::onConnectFailed, this, _1)); |
| 483 | |
| 484 | DummyStreamSender<stream_protocol, Dataset> sender; |
| 485 | sender.start(stream_protocol::endpoint(CHANNEL_PATH1)); |
| 486 | |
| 487 | BOOST_CHECK_MESSAGE(limitedIo.run(LimitedIo::UNLIMITED_OPS, |
| 488 | time::seconds(1)) == LimitedIo::EXCEED_TIME, |
| 489 | "Exception thrown for " + Dataset::getName()); |
| 490 | } |
| 491 | |
| 492 | |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 493 | BOOST_AUTO_TEST_SUITE_END() |
| 494 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 495 | } // namespace tests |
Davide Pesavento | bc4dd8c | 2014-02-14 20:01:01 +0100 | [diff] [blame] | 496 | } // namespace nfd |