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