blob: faf8eadd419445f4e98b741b1ccd88df6a4659c5 [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/face-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(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>
Eric Newberry6d932e82016-11-24 05:05:43 +000047 <flags/>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000048 <packetCounters>
49 <incomingPackets>
50 <nInterests>22562</nInterests>
51 <nDatas>22031</nDatas>
52 <nNacks>63</nNacks>
53 </incomingPackets>
54 <outgoingPackets>
55 <nInterests>30121</nInterests>
56 <nDatas>20940</nDatas>
57 <nNacks>1218</nNacks>
58 </outgoingPackets>
59 </packetCounters>
60 <byteCounters>
61 <incomingBytes>2522915</incomingBytes>
62 <outgoingBytes>1353592</outgoingBytes>
63 </byteCounters>
64 </face>
65 <face>
66 <faceId>745</faceId>
67 <remoteUri>fd://75</remoteUri>
68 <localUri>unix:///var/run/nfd.sock</localUri>
69 <faceScope>local</faceScope>
70 <facePersistency>on-demand</facePersistency>
71 <linkType>point-to-point</linkType>
Eric Newberry6d932e82016-11-24 05:05:43 +000072 <flags>
73 <localFieldsEnabled/>
74 </flags>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000075 <packetCounters>
76 <incomingPackets>
77 <nInterests>18998</nInterests>
78 <nDatas>26701</nDatas>
79 <nNacks>147</nNacks>
80 </incomingPackets>
81 <outgoingPackets>
82 <nInterests>34779</nInterests>
83 <nDatas>17028</nDatas>
84 <nNacks>1176</nNacks>
85 </outgoingPackets>
86 </packetCounters>
87 <byteCounters>
88 <incomingBytes>4672308</incomingBytes>
89 <outgoingBytes>8957187</outgoingBytes>
90 </byteCounters>
91 </face>
92 </faces>
93)XML");
94
95const std::string STATUS_TEXT =
96 "Faces:\n"
97 " faceid=134 remote=udp4://233.252.0.4:6363 local=udp4://192.0.2.1:6363"
98 " counters={in={22562i 22031d 63n 2522915B} out={30121i 20940d 1218n 1353592B}}"
Eric Newberry6d932e82016-11-24 05:05:43 +000099 " non-local permanent multi-access flags={}\n"
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000100 " faceid=745 remote=fd://75 local=unix:///var/run/nfd.sock"
101 " counters={in={18998i 26701d 147n 4672308B} out={34779i 17028d 1176n 8957187B}}"
Eric Newberry6d932e82016-11-24 05:05:43 +0000102 " local on-demand point-to-point flags={local-fields}\n";
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000103
104BOOST_AUTO_TEST_CASE(Status)
105{
106 this->fetchStatus();
107 FaceStatus payload1;
108 payload1.setFaceId(134)
109 .setRemoteUri("udp4://233.252.0.4:6363")
110 .setLocalUri("udp4://192.0.2.1:6363")
111 .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL)
112 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT)
113 .setLinkType(ndn::nfd::LINK_TYPE_MULTI_ACCESS)
114 .setNInInterests(22562)
115 .setNInDatas(22031)
116 .setNInNacks(63)
117 .setNOutInterests(30121)
118 .setNOutDatas(20940)
119 .setNOutNacks(1218)
120 .setNInBytes(2522915)
121 .setNOutBytes(1353592);
122 FaceStatus payload2;
123 payload2.setFaceId(745)
124 .setRemoteUri("fd://75")
125 .setLocalUri("unix:///var/run/nfd.sock")
126 .setFaceScope(ndn::nfd::FACE_SCOPE_LOCAL)
127 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND)
128 .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT)
Eric Newberry6d932e82016-11-24 05:05:43 +0000129 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true)
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000130 .setNInInterests(18998)
131 .setNInDatas(26701)
132 .setNInNacks(147)
133 .setNOutInterests(34779)
134 .setNOutDatas(17028)
135 .setNOutNacks(1176)
136 .setNInBytes(4672308)
137 .setNOutBytes(8957187);
138 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
139 this->prepareStatusOutput();
140
141 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
142 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
143}
144
145BOOST_AUTO_TEST_SUITE_END() // TestFaceModule
Junxiao Shi331ade72016-08-19 14:07:19 +0000146BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000147
148} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +0000149} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000150} // namespace tools
151} // namespace nfd