Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
Eric Newberry | f68f378 | 2015-12-11 00:31:32 -0700 | [diff] [blame^] | 26 | #include "tcp-transport-fixture.hpp" |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 27 | |
| 28 | namespace nfd { |
| 29 | namespace face { |
| 30 | namespace tests { |
| 31 | |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 32 | BOOST_AUTO_TEST_SUITE(Face) |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 33 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 34 | BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, TcpTransportFixture) |
| 35 | |
| 36 | BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4) |
| 37 | { |
| 38 | initialize(); |
| 39 | |
| 40 | checkStaticPropertiesInitialized(*transport); |
| 41 | |
| 42 | BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp4://127.0.0.1:" + to_string(localEp.port()))); |
| 43 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp4://127.0.0.1:7070")); |
| 44 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 45 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 46 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 47 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 50 | BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6) |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 51 | { |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 52 | initialize(ip::address_v6::loopback()); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 53 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 54 | checkStaticPropertiesInitialized(*transport); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 55 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 56 | BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp6://[::1]:" + to_string(localEp.port()))); |
| 57 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp6://[::1]:7070")); |
| 58 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 59 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 60 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 61 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 62 | } |
| 63 | |
| 64 | BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4) |
| 65 | { |
| 66 | auto address = getAvailableInterfaceIp<ip::address_v4>(); |
| 67 | SKIP_IF_IP_UNAVAILABLE(address); |
| 68 | initialize(address); |
| 69 | |
| 70 | checkStaticPropertiesInitialized(*transport); |
| 71 | |
| 72 | BOOST_CHECK_EQUAL(transport->getLocalUri(), |
| 73 | FaceUri("tcp4://" + address.to_string() + ":" + to_string(localEp.port()))); |
| 74 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), |
| 75 | FaceUri("tcp4://" + address.to_string() + ":7070")); |
| 76 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 77 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 78 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 79 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 80 | } |
| 81 | |
| 82 | BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6) |
| 83 | { |
| 84 | auto address = getAvailableInterfaceIp<ip::address_v6>(); |
| 85 | SKIP_IF_IP_UNAVAILABLE(address); |
| 86 | initialize(address); |
| 87 | |
| 88 | checkStaticPropertiesInitialized(*transport); |
| 89 | |
| 90 | BOOST_CHECK_EQUAL(transport->getLocalUri(), |
| 91 | FaceUri("tcp6://[" + address.to_string() + "]:" + to_string(localEp.port()))); |
| 92 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), |
| 93 | FaceUri("tcp6://[" + address.to_string() + "]:7070")); |
| 94 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 95 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 96 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 97 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 98 | } |
| 99 | |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 100 | BOOST_AUTO_TEST_SUITE_END() // TestTcpTransport |
| 101 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 102 | |
| 103 | } // namespace tests |
| 104 | } // namespace face |
| 105 | } // namespace nfd |