Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, 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/fib-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 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 30 | namespace nfd::tools::nfdc::tests { |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 31 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 32 | BOOST_AUTO_TEST_SUITE(Nfdc) |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 33 | BOOST_FIXTURE_TEST_SUITE(TestFibModule, StatusFixture<FibModule>) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 34 | |
| 35 | const std::string STATUS_XML = stripXmlSpaces(R"XML( |
| 36 | <fib> |
| 37 | <fibEntry> |
| 38 | <prefix>/</prefix> |
| 39 | <nextHops> |
| 40 | <nextHop> |
| 41 | <faceId>262</faceId> |
| 42 | <cost>9</cost> |
| 43 | </nextHop> |
| 44 | <nextHop> |
| 45 | <faceId>272</faceId> |
| 46 | <cost>50</cost> |
| 47 | </nextHop> |
| 48 | <nextHop> |
| 49 | <faceId>274</faceId> |
| 50 | <cost>78</cost> |
| 51 | </nextHop> |
| 52 | </nextHops> |
| 53 | </fibEntry> |
| 54 | <fibEntry> |
| 55 | <prefix>/localhost/nfd</prefix> |
| 56 | <nextHops> |
| 57 | <nextHop> |
| 58 | <faceId>1</faceId> |
| 59 | <cost>0</cost> |
| 60 | </nextHop> |
| 61 | <nextHop> |
| 62 | <faceId>274</faceId> |
| 63 | <cost>0</cost> |
| 64 | </nextHop> |
| 65 | </nextHops> |
| 66 | </fibEntry> |
| 67 | </fib> |
| 68 | )XML"); |
| 69 | |
| 70 | const std::string STATUS_TEXT = std::string(R"TEXT( |
| 71 | FIB: |
Ju Pan | 57113d1 | 2019-08-05 22:52:40 +0000 | [diff] [blame] | 72 | / nexthops={faceid=262 (cost=9), faceid=272 (cost=50), faceid=274 (cost=78)} |
| 73 | /localhost/nfd nexthops={faceid=1 (cost=0), faceid=274 (cost=0)} |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 74 | )TEXT").substr(1); |
| 75 | |
| 76 | BOOST_AUTO_TEST_CASE(Status) |
| 77 | { |
| 78 | this->fetchStatus(); |
| 79 | FibEntry payload1; |
| 80 | payload1.setPrefix("/") |
Ju Pan | 57113d1 | 2019-08-05 22:52:40 +0000 | [diff] [blame] | 81 | .addNextHopRecord(NextHopRecord().setFaceId(262).setCost(9)) |
| 82 | .addNextHopRecord(NextHopRecord().setFaceId(272).setCost(50)) |
| 83 | .addNextHopRecord(NextHopRecord().setFaceId(274).setCost(78)); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 84 | FibEntry payload2; |
| 85 | payload2.setPrefix("/localhost/nfd") |
| 86 | .addNextHopRecord(NextHopRecord().setFaceId(1).setCost(0)) |
Ju Pan | 57113d1 | 2019-08-05 22:52:40 +0000 | [diff] [blame] | 87 | .addNextHopRecord(NextHopRecord().setFaceId(274).setCost(0)); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 88 | this->sendDataset("/localhost/nfd/fib/list", payload1, payload2); |
| 89 | this->prepareStatusOutput(); |
Ju Pan | 57113d1 | 2019-08-05 22:52:40 +0000 | [diff] [blame] | 90 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 91 | BOOST_CHECK(statusXml.is_equal(STATUS_XML)); |
| 92 | BOOST_CHECK(statusText.is_equal(STATUS_TEXT)); |
| 93 | } |
| 94 | |
| 95 | BOOST_AUTO_TEST_SUITE_END() // TestFibModule |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 96 | BOOST_AUTO_TEST_SUITE_END() // Nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 97 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 98 | } // namespace nfd::tools::nfdc::tests |