Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | ae43030 | 2023-05-11 01:42:46 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2023, Regents of the University of California, |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [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 | |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 26 | #include "face/null-face.hpp" |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 27 | #include "face/null-transport.hpp" |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 29 | #include "tests/daemon/global-io-fixture.hpp" |
Davide Pesavento | 279af1c | 2022-08-29 20:18:32 -0400 | [diff] [blame] | 30 | #include "tests/daemon/face/transport-test-common.hpp" |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 31 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 32 | namespace nfd::tests { |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 33 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 34 | using namespace nfd::face; |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 35 | |
| 36 | BOOST_AUTO_TEST_SUITE(Face) |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 37 | BOOST_FIXTURE_TEST_SUITE(TestNullFace, GlobalIoFixture) |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 38 | |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 39 | BOOST_AUTO_TEST_CASE(StaticProperties) |
| 40 | { |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 41 | FaceUri uri("testnull://hhppt12sy"); |
| 42 | auto face = makeNullFace(uri); |
| 43 | auto transport = face->getTransport(); |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 44 | |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 45 | checkStaticPropertiesInitialized(*transport); |
| 46 | |
| 47 | BOOST_CHECK_EQUAL(transport->getLocalUri(), uri); |
| 48 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), uri); |
| 49 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 50 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT); |
| 51 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 52 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 53 | } |
| 54 | |
| 55 | BOOST_AUTO_TEST_CASE(ExpirationTime) |
| 56 | { |
| 57 | auto transport = make_unique<NullTransport>(); |
| 58 | |
Davide Pesavento | ae43030 | 2023-05-11 01:42:46 -0400 | [diff] [blame] | 59 | BOOST_CHECK_EQUAL(transport->getExpirationTime(), time::steady_clock::time_point::max()); |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | BOOST_AUTO_TEST_CASE(SendQueue) |
| 63 | { |
| 64 | auto transport = make_unique<NullTransport>(); |
| 65 | |
| 66 | BOOST_CHECK_EQUAL(transport->getSendQueueCapacity(), QUEUE_UNSUPPORTED); |
| 67 | BOOST_CHECK_EQUAL(transport->getSendQueueLength(), QUEUE_UNSUPPORTED); |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 68 | } |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 69 | |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 70 | BOOST_AUTO_TEST_CASE(Send) |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 71 | { |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 72 | auto face = makeNullFace(); |
| 73 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 74 | |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 75 | face->sendInterest(*makeInterest("/A")); |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 76 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 77 | |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 78 | face->sendData(*makeData("/B")); |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 79 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
| 80 | } |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 81 | |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 82 | BOOST_AUTO_TEST_CASE(PersistencyChange) |
| 83 | { |
| 84 | auto transport = make_unique<NullTransport>(); |
| 85 | |
| 86 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND), false); |
| 87 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERSISTENT), false); |
| 88 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERMANENT), true); |
| 89 | } |
| 90 | |
| 91 | BOOST_AUTO_TEST_CASE(Close) |
| 92 | { |
| 93 | auto transport = make_unique<NullTransport>(); |
| 94 | BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP); |
| 95 | |
| 96 | transport->close(); |
| 97 | BOOST_CHECK_EQUAL(transport->getState(), TransportState::CLOSED); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 98 | } |
| 99 | |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 100 | BOOST_AUTO_TEST_SUITE_END() // TestNullFace |
| 101 | BOOST_AUTO_TEST_SUITE_END() // Face |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 102 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 103 | } // namespace nfd::tests |