blob: 6148b3b8765b7b62221c1d54e87f9c4089e6b149 [file] [log] [blame]
Junxiao Shicde37ad2015-12-24 01:02:05 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, 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 "face/ethernet-factory.hpp"
27
28#include "network-interface-fixture.hpp"
29
30namespace nfd {
31namespace tests {
32
33using nfd::face::tests::NetworkInterfaceFixture;
34
35BOOST_AUTO_TEST_SUITE(Face)
36BOOST_FIXTURE_TEST_SUITE(TestEthernetFactory, NetworkInterfaceFixture)
37
38BOOST_AUTO_TEST_CASE(GetChannels)
39{
40 EthernetFactory factory;
41
42 auto channels = factory.getChannels();
43 BOOST_CHECK_EQUAL(channels.empty(), true);
44}
45
46BOOST_AUTO_TEST_CASE(MulticastFacesMap)
47{
48 SKIP_IF_NETWORK_INTERFACE_COUNT_LT(1);
49
50 EthernetFactory factory;
51 auto face1 = factory.createMulticastFace(m_interfaces.front(), ethernet::getBroadcastAddress());
52 auto face1bis = factory.createMulticastFace(m_interfaces.front(), ethernet::getBroadcastAddress());
53 BOOST_CHECK_EQUAL(face1, face1bis);
54
55 auto face2 = factory.createMulticastFace(m_interfaces.front(), ethernet::getDefaultMulticastAddress());
56 BOOST_CHECK_NE(face1, face2);
57
58 SKIP_IF_NETWORK_INTERFACE_COUNT_LT(2);
59
60 auto face3 = factory.createMulticastFace(m_interfaces.back(), ethernet::getBroadcastAddress());
61 BOOST_CHECK_NE(face1, face3);
62}
63
64BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
65{
66 EthernetFactory factory;
67
68 BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
69 ndn::nfd::FACE_PERSISTENCY_PERMANENT,
70 bind([]{}),
71 bind([]{})),
72 ProtocolFactory::Error);
73
74 BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
75 ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
76 bind([]{}),
77 bind([]{})),
78 ProtocolFactory::Error);
79
80 BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
81 ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
82 bind([]{}),
83 bind([]{})),
84 ProtocolFactory::Error);
85}
86
87BOOST_AUTO_TEST_SUITE_END() // TestEthernetFactory
88BOOST_AUTO_TEST_SUITE_END() // Face
89
90} // namespace tests
91} // namespace nfd