blob: 292ccd865639af015f2ed5e4f7d4fa14d6d0f363 [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
26#include "nfd-status/face-module.hpp"
27
28#include "module-fixture.hpp"
29
30namespace nfd {
31namespace tools {
32namespace nfd_status {
33namespace tests {
34
35BOOST_AUTO_TEST_SUITE(NfdStatus)
36BOOST_FIXTURE_TEST_SUITE(TestFaceModule, ModuleFixture<FaceModule>)
37
38const std::string STATUS_XML = stripXmlSpaces(R"XML(
39 <faces>
40 <face>
41 <faceId>134</faceId>
42 <remoteUri>udp4://233.252.0.4:6363</remoteUri>
43 <localUri>udp4://192.0.2.1:6363</localUri>
44 <faceScope>non-local</faceScope>
45 <facePersistency>permanent</facePersistency>
46 <linkType>multi-access</linkType>
47 <packetCounters>
48 <incomingPackets>
49 <nInterests>22562</nInterests>
50 <nDatas>22031</nDatas>
51 <nNacks>63</nNacks>
52 </incomingPackets>
53 <outgoingPackets>
54 <nInterests>30121</nInterests>
55 <nDatas>20940</nDatas>
56 <nNacks>1218</nNacks>
57 </outgoingPackets>
58 </packetCounters>
59 <byteCounters>
60 <incomingBytes>2522915</incomingBytes>
61 <outgoingBytes>1353592</outgoingBytes>
62 </byteCounters>
63 </face>
64 <face>
65 <faceId>745</faceId>
66 <remoteUri>fd://75</remoteUri>
67 <localUri>unix:///var/run/nfd.sock</localUri>
68 <faceScope>local</faceScope>
69 <facePersistency>on-demand</facePersistency>
70 <linkType>point-to-point</linkType>
71 <packetCounters>
72 <incomingPackets>
73 <nInterests>18998</nInterests>
74 <nDatas>26701</nDatas>
75 <nNacks>147</nNacks>
76 </incomingPackets>
77 <outgoingPackets>
78 <nInterests>34779</nInterests>
79 <nDatas>17028</nDatas>
80 <nNacks>1176</nNacks>
81 </outgoingPackets>
82 </packetCounters>
83 <byteCounters>
84 <incomingBytes>4672308</incomingBytes>
85 <outgoingBytes>8957187</outgoingBytes>
86 </byteCounters>
87 </face>
88 </faces>
89)XML");
90
91const std::string STATUS_TEXT =
92 "Faces:\n"
93 " faceid=134 remote=udp4://233.252.0.4:6363 local=udp4://192.0.2.1:6363"
94 " counters={in={22562i 22031d 63n 2522915B} out={30121i 20940d 1218n 1353592B}}"
95 " non-local permanent multi-access\n"
96 " faceid=745 remote=fd://75 local=unix:///var/run/nfd.sock"
97 " counters={in={18998i 26701d 147n 4672308B} out={34779i 17028d 1176n 8957187B}}"
98 " local on-demand point-to-point\n";
99
100BOOST_AUTO_TEST_CASE(Status)
101{
102 this->fetchStatus();
103 FaceStatus payload1;
104 payload1.setFaceId(134)
105 .setRemoteUri("udp4://233.252.0.4:6363")
106 .setLocalUri("udp4://192.0.2.1:6363")
107 .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL)
108 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT)
109 .setLinkType(ndn::nfd::LINK_TYPE_MULTI_ACCESS)
110 .setNInInterests(22562)
111 .setNInDatas(22031)
112 .setNInNacks(63)
113 .setNOutInterests(30121)
114 .setNOutDatas(20940)
115 .setNOutNacks(1218)
116 .setNInBytes(2522915)
117 .setNOutBytes(1353592);
118 FaceStatus payload2;
119 payload2.setFaceId(745)
120 .setRemoteUri("fd://75")
121 .setLocalUri("unix:///var/run/nfd.sock")
122 .setFaceScope(ndn::nfd::FACE_SCOPE_LOCAL)
123 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND)
124 .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT)
125 .setNInInterests(18998)
126 .setNInDatas(26701)
127 .setNInNacks(147)
128 .setNOutInterests(34779)
129 .setNOutDatas(17028)
130 .setNOutNacks(1176)
131 .setNInBytes(4672308)
132 .setNOutBytes(8957187);
133 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
134 this->prepareStatusOutput();
135
136 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
137 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
138}
139
140BOOST_AUTO_TEST_SUITE_END() // TestFaceModule
141BOOST_AUTO_TEST_SUITE_END() // NfdStatus
142
143} // namespace tests
144} // namespace nfd_status
145} // namespace tools
146} // namespace nfd