Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -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 | |
Eric Newberry | 65caf20 | 2015-12-17 15:08:16 -0700 | [diff] [blame] | 26 | #include "transport-test-common.hpp" |
| 27 | |
Eric Newberry | f68f378 | 2015-12-11 00:31:32 -0700 | [diff] [blame] | 28 | #include "tcp-transport-fixture.hpp" |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 29 | |
| 30 | namespace nfd { |
| 31 | namespace face { |
| 32 | namespace tests { |
| 33 | |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 34 | BOOST_AUTO_TEST_SUITE(Face) |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 35 | BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, TcpTransportFixture) |
| 36 | |
| 37 | BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4) |
| 38 | { |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 39 | auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes); |
| 40 | SKIP_IF_IP_UNAVAILABLE(address); |
| 41 | initialize(address); |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 42 | |
| 43 | checkStaticPropertiesInitialized(*transport); |
| 44 | |
| 45 | BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp4://127.0.0.1:" + to_string(localEp.port()))); |
| 46 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp4://127.0.0.1:7070")); |
| 47 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 48 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 49 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 50 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 53 | BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6) |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 54 | { |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 55 | auto address = getTestIp<ip::address_v6>(LoopbackAddress::Yes); |
| 56 | SKIP_IF_IP_UNAVAILABLE(address); |
| 57 | initialize(address); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 58 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 59 | checkStaticPropertiesInitialized(*transport); |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 60 | |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp6://[::1]:" + to_string(localEp.port()))); |
| 62 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp6://[::1]:7070")); |
| 63 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 64 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 65 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 66 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 67 | } |
| 68 | |
| 69 | BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4) |
| 70 | { |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 71 | auto address = getTestIp<ip::address_v4>(LoopbackAddress::No); |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 72 | SKIP_IF_IP_UNAVAILABLE(address); |
| 73 | initialize(address); |
| 74 | |
| 75 | checkStaticPropertiesInitialized(*transport); |
| 76 | |
| 77 | BOOST_CHECK_EQUAL(transport->getLocalUri(), |
| 78 | FaceUri("tcp4://" + address.to_string() + ":" + to_string(localEp.port()))); |
| 79 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), |
| 80 | FaceUri("tcp4://" + address.to_string() + ":7070")); |
| 81 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 82 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 83 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 84 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 85 | } |
| 86 | |
| 87 | BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6) |
| 88 | { |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 89 | auto address = getTestIp<ip::address_v6>(LoopbackAddress::No); |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 90 | SKIP_IF_IP_UNAVAILABLE(address); |
| 91 | initialize(address); |
| 92 | |
| 93 | checkStaticPropertiesInitialized(*transport); |
| 94 | |
| 95 | BOOST_CHECK_EQUAL(transport->getLocalUri(), |
| 96 | FaceUri("tcp6://[" + address.to_string() + "]:" + to_string(localEp.port()))); |
| 97 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), |
| 98 | FaceUri("tcp6://[" + address.to_string() + "]:7070")); |
| 99 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 100 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 101 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 102 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 103 | } |
| 104 | |
Yukai Tu | 16aabbc | 2015-10-06 05:08:42 -0700 | [diff] [blame] | 105 | BOOST_AUTO_TEST_SUITE_END() // TestTcpTransport |
| 106 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 107 | |
| 108 | } // namespace tests |
| 109 | } // namespace face |
| 110 | } // namespace nfd |