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 | /* |
| 3 | * Copyright (c) 2014-2019, 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 | |
| 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(TestFibModule, StatusFixture<FibModule>) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 37 | |
| 38 | const std::string STATUS_XML = stripXmlSpaces(R"XML( |
| 39 | <fib> |
| 40 | <fibEntry> |
| 41 | <prefix>/</prefix> |
| 42 | <nextHops> |
| 43 | <nextHop> |
| 44 | <faceId>262</faceId> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 45 | <endpointId>1</endpointId> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 46 | <cost>9</cost> |
| 47 | </nextHop> |
| 48 | <nextHop> |
| 49 | <faceId>272</faceId> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 50 | <endpointId>2</endpointId> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 51 | <cost>50</cost> |
| 52 | </nextHop> |
| 53 | <nextHop> |
| 54 | <faceId>274</faceId> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 55 | <endpointId>3</endpointId> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 56 | <cost>78</cost> |
| 57 | </nextHop> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 58 | <nextHop> |
| 59 | <faceId>275</faceId> |
| 60 | <endpointId>0</endpointId> |
| 61 | <cost>80</cost> |
| 62 | </nextHop> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 63 | </nextHops> |
| 64 | </fibEntry> |
| 65 | <fibEntry> |
| 66 | <prefix>/localhost/nfd</prefix> |
| 67 | <nextHops> |
| 68 | <nextHop> |
| 69 | <faceId>1</faceId> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 70 | <endpointId>0</endpointId> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 71 | <cost>0</cost> |
| 72 | </nextHop> |
| 73 | <nextHop> |
| 74 | <faceId>274</faceId> |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 75 | <endpointId>5</endpointId> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 76 | <cost>0</cost> |
| 77 | </nextHop> |
| 78 | </nextHops> |
| 79 | </fibEntry> |
| 80 | </fib> |
| 81 | )XML"); |
| 82 | |
| 83 | const std::string STATUS_TEXT = std::string(R"TEXT( |
| 84 | FIB: |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 85 | / nexthops={face=262:1 (cost=9), face=272:2 (cost=50), face=274:3 (cost=78), face=275 (cost=80)} |
| 86 | /localhost/nfd nexthops={face=1 (cost=0), face=274:5 (cost=0)} |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 87 | )TEXT").substr(1); |
| 88 | |
| 89 | BOOST_AUTO_TEST_CASE(Status) |
| 90 | { |
| 91 | this->fetchStatus(); |
| 92 | FibEntry payload1; |
| 93 | payload1.setPrefix("/") |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 94 | .addNextHopRecord(NextHopRecord().setFaceId(262).setEndpointId(1).setCost(9)) |
| 95 | .addNextHopRecord(NextHopRecord().setFaceId(272).setEndpointId(2).setCost(50)) |
| 96 | .addNextHopRecord(NextHopRecord().setFaceId(274).setEndpointId(3).setCost(78)) |
| 97 | .addNextHopRecord(NextHopRecord().setFaceId(275).setCost(80)); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 98 | FibEntry payload2; |
| 99 | payload2.setPrefix("/localhost/nfd") |
| 100 | .addNextHopRecord(NextHopRecord().setFaceId(1).setCost(0)) |
Ju Pan | 13839ac | 2019-06-04 03:50:04 +0000 | [diff] [blame] | 101 | .addNextHopRecord(NextHopRecord().setFaceId(274).setEndpointId(5).setCost(0)); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 102 | this->sendDataset("/localhost/nfd/fib/list", payload1, payload2); |
| 103 | this->prepareStatusOutput(); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 104 | BOOST_CHECK(statusXml.is_equal(STATUS_XML)); |
| 105 | BOOST_CHECK(statusText.is_equal(STATUS_TEXT)); |
| 106 | } |
| 107 | |
| 108 | BOOST_AUTO_TEST_SUITE_END() // TestFibModule |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 109 | BOOST_AUTO_TEST_SUITE_END() // Nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 110 | |
| 111 | } // namespace tests |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 112 | } // namespace nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 113 | } // namespace tools |
| 114 | } // namespace nfd |