blob: 3ec37759e6a52e28088b96762b226ead41d1badd [file] [log] [blame]
Junxiao Shi38f4ce92016-08-04 10:01:52 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, 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.
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 Shi331ade72016-08-19 14:07:19 +000026#include "nfdc/fib-module.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000027
28#include "module-fixture.hpp"
29
30namespace nfd {
31namespace tools {
Junxiao Shi331ade72016-08-19 14:07:19 +000032namespace nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000033namespace tests {
34
Junxiao Shi331ade72016-08-19 14:07:19 +000035BOOST_AUTO_TEST_SUITE(Nfdc)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000036BOOST_FIXTURE_TEST_SUITE(TestFibModule, ModuleFixture<FibModule>)
37
38const std::string STATUS_XML = stripXmlSpaces(R"XML(
39 <fib>
40 <fibEntry>
41 <prefix>/</prefix>
42 <nextHops>
43 <nextHop>
44 <faceId>262</faceId>
45 <cost>9</cost>
46 </nextHop>
47 <nextHop>
48 <faceId>272</faceId>
49 <cost>50</cost>
50 </nextHop>
51 <nextHop>
52 <faceId>274</faceId>
53 <cost>78</cost>
54 </nextHop>
55 </nextHops>
56 </fibEntry>
57 <fibEntry>
58 <prefix>/localhost/nfd</prefix>
59 <nextHops>
60 <nextHop>
61 <faceId>1</faceId>
62 <cost>0</cost>
63 </nextHop>
64 <nextHop>
65 <faceId>274</faceId>
66 <cost>0</cost>
67 </nextHop>
68 </nextHops>
69 </fibEntry>
70 </fib>
71)XML");
72
73const std::string STATUS_TEXT = std::string(R"TEXT(
74FIB:
75 / nexthops={faceid=262 (cost=9), faceid=272 (cost=50), faceid=274 (cost=78)}
76 /localhost/nfd nexthops={faceid=1 (cost=0), faceid=274 (cost=0)}
77)TEXT").substr(1);
78
79BOOST_AUTO_TEST_CASE(Status)
80{
81 this->fetchStatus();
82 FibEntry payload1;
83 payload1.setPrefix("/")
84 .addNextHopRecord(NextHopRecord().setFaceId(262).setCost(9))
85 .addNextHopRecord(NextHopRecord().setFaceId(272).setCost(50))
86 .addNextHopRecord(NextHopRecord().setFaceId(274).setCost(78));
87 FibEntry payload2;
88 payload2.setPrefix("/localhost/nfd")
89 .addNextHopRecord(NextHopRecord().setFaceId(1).setCost(0))
90 .addNextHopRecord(NextHopRecord().setFaceId(274).setCost(0));
91 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
92 this->prepareStatusOutput();
93
94 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
95 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
96}
97
98BOOST_AUTO_TEST_SUITE_END() // TestFibModule
Junxiao Shi331ade72016-08-19 14:07:19 +000099BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000100
101} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +0000102} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000103} // namespace tools
104} // namespace nfd