Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California, |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 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. |
| 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/>. |
| 24 | */ |
| 25 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 26 | #include "nfdc/rib-module.hpp" |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 27 | |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 28 | #include "status-fixture.hpp" |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 29 | |
| 30 | namespace nfd { |
| 31 | namespace tools { |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 32 | namespace nfdc { |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 33 | namespace tests { |
| 34 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 35 | BOOST_AUTO_TEST_SUITE(Nfdc) |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 36 | BOOST_FIXTURE_TEST_SUITE(TestRibModule, StatusFixture<RibModule>) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 37 | |
| 38 | const std::string STATUS_XML = stripXmlSpaces(R"XML( |
| 39 | <rib> |
| 40 | <ribEntry> |
| 41 | <prefix>/</prefix> |
| 42 | <routes> |
| 43 | <route> |
| 44 | <faceId>262</faceId> |
| 45 | <origin>255</origin> |
| 46 | <cost>9</cost> |
| 47 | <flags> |
| 48 | <ribCapture/> |
| 49 | </flags> |
| 50 | </route> |
| 51 | <route> |
| 52 | <faceId>272</faceId> |
| 53 | <origin>255</origin> |
| 54 | <cost>50</cost> |
| 55 | <flags/> |
| 56 | </route> |
| 57 | <route> |
| 58 | <faceId>274</faceId> |
| 59 | <origin>255</origin> |
| 60 | <cost>78</cost> |
| 61 | <flags> |
| 62 | <childInherit/> |
| 63 | <ribCapture/> |
| 64 | </flags> |
| 65 | </route> |
| 66 | <route> |
| 67 | <faceId>276</faceId> |
| 68 | <origin>255</origin> |
| 69 | <cost>79</cost> |
| 70 | <flags> |
| 71 | <childInherit/> |
| 72 | </flags> |
| 73 | <expirationPeriod>PT47S</expirationPeriod> |
| 74 | </route> |
| 75 | </routes> |
| 76 | </ribEntry> |
| 77 | <ribEntry> |
| 78 | <prefix>/localhost/nfd</prefix> |
| 79 | <routes> |
| 80 | <route> |
| 81 | <faceId>258</faceId> |
| 82 | <origin>0</origin> |
| 83 | <cost>0</cost> |
| 84 | <flags> |
| 85 | <childInherit/> |
| 86 | </flags> |
| 87 | </route> |
| 88 | </routes> |
| 89 | </ribEntry> |
| 90 | </rib> |
| 91 | )XML"); |
| 92 | |
| 93 | const std::string STATUS_TEXT = |
| 94 | "RIB:\n" |
| 95 | " / route={faceid=262 (origin=255 cost=9 RibCapture), faceid=272 (origin=255 cost=50), " |
| 96 | "faceid=274 (origin=255 cost=78 ChildInherit RibCapture), " |
| 97 | "faceid=276 (origin=255 cost=79 expires=47s ChildInherit)}\n" |
| 98 | " /localhost/nfd route={faceid=258 (origin=0 cost=0 ChildInherit)}\n"; |
| 99 | |
| 100 | BOOST_AUTO_TEST_CASE(Status) |
| 101 | { |
| 102 | this->fetchStatus(); |
| 103 | RibEntry payload1; |
| 104 | payload1.setName("/") |
| 105 | .addRoute(Route().setFaceId(262) |
| 106 | .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) |
| 107 | .setCost(9) |
| 108 | .setFlags(ndn::nfd::ROUTE_FLAG_CAPTURE)) |
| 109 | .addRoute(Route().setFaceId(272) |
| 110 | .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) |
| 111 | .setCost(50) |
| 112 | .setFlags(ndn::nfd::ROUTE_FLAGS_NONE)) |
| 113 | .addRoute(Route().setFaceId(274) |
| 114 | .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) |
| 115 | .setCost(78) |
| 116 | .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE)) |
| 117 | .addRoute(Route().setFaceId(276) |
| 118 | .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) |
| 119 | .setCost(79) |
| 120 | .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT) |
| 121 | .setExpirationPeriod(time::milliseconds(47292))); |
| 122 | RibEntry payload2; |
| 123 | payload2.setName("/localhost/nfd") |
| 124 | .addRoute(Route().setFaceId(258) |
| 125 | .setOrigin(ndn::nfd::ROUTE_ORIGIN_APP) |
| 126 | .setCost(0) |
| 127 | .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)); |
| 128 | this->sendDataset("/localhost/nfd/rib/list", payload1, payload2); |
| 129 | this->prepareStatusOutput(); |
| 130 | |
| 131 | BOOST_CHECK(statusXml.is_equal(STATUS_XML)); |
| 132 | BOOST_CHECK(statusText.is_equal(STATUS_TEXT)); |
| 133 | } |
| 134 | |
| 135 | BOOST_AUTO_TEST_SUITE_END() // TestRibModule |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 136 | BOOST_AUTO_TEST_SUITE_END() // Nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 137 | |
| 138 | } // namespace tests |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 139 | } // namespace nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 140 | } // namespace tools |
| 141 | } // namespace nfd |