blob: c0d51380fc2696dbee5c21bd6f2dfa1d4117dfa3 [file] [log] [blame]
Davide Pesavento35120ea2015-11-17 21:13:18 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi7003c602017-01-10 13:35:28 +00003 * Copyright (c) 2014-2017, Regents of the University of California,
Davide Pesavento35120ea2015-11-17 21:13:18 +01004 * 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-transport.hpp"
Davide Pesavento35120ea2015-11-17 21:13:18 +010027
Junxiao Shi7003c602017-01-10 13:35:28 +000028#include "transport-test-common.hpp"
29#include "ethernet-fixture.hpp"
Davide Pesavento35120ea2015-11-17 21:13:18 +010030
31namespace nfd {
32namespace face {
33namespace tests {
34
35using namespace nfd::tests;
36
37BOOST_AUTO_TEST_SUITE(Face)
Junxiao Shi7003c602017-01-10 13:35:28 +000038BOOST_FIXTURE_TEST_SUITE(TestEthernetTransport, EthernetFixture)
Davide Pesavento35120ea2015-11-17 21:13:18 +010039
40BOOST_AUTO_TEST_CASE(StaticProperties)
41{
Junxiao Shi7003c602017-01-10 13:35:28 +000042 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Davide Pesavento35120ea2015-11-17 21:13:18 +010043
Junxiao Shi7003c602017-01-10 13:35:28 +000044 auto netif = netifs.front();
Teng Liangbfea5752017-03-29 04:51:10 +000045 EthernetTransport transport(netif,
46 ethernet::getDefaultMulticastAddress(),
47 ndn::nfd::LINK_TYPE_MULTI_ACCESS);
Davide Pesavento35120ea2015-11-17 21:13:18 +010048 checkStaticPropertiesInitialized(transport);
49
50 BOOST_CHECK_EQUAL(transport.getLocalUri(), FaceUri::fromDev(netif.name));
51 BOOST_CHECK_EQUAL(transport.getRemoteUri(), FaceUri(ethernet::getDefaultMulticastAddress()));
52 BOOST_CHECK_EQUAL(transport.getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL);
53 BOOST_CHECK_EQUAL(transport.getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT);
54 BOOST_CHECK_EQUAL(transport.getLinkType(), ndn::nfd::LINK_TYPE_MULTI_ACCESS);
55}
56
Davide Pesavento32065652017-01-15 01:52:21 -050057BOOST_AUTO_TEST_CASE(PersistencyChange)
58{
59 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Teng Liangbfea5752017-03-29 04:51:10 +000060 EthernetTransport transport(netifs.front(),
61 ethernet::getDefaultMulticastAddress(),
62 ndn::nfd::LINK_TYPE_MULTI_ACCESS);
Davide Pesavento32065652017-01-15 01:52:21 -050063
64 BOOST_CHECK_EQUAL(transport.canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND), false);
65 BOOST_CHECK_EQUAL(transport.canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERSISTENT), false);
66 BOOST_CHECK_EQUAL(transport.canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERMANENT), true);
67}
68
Junxiao Shi7003c602017-01-10 13:35:28 +000069///\todo #3369 add the equivalent of these test cases from ethernet.t.cpp
70/// as of commit:65caf200924b28748037750449e28bcb548dbc9c
71/// SendPacket, ProcessIncomingPacket
Junxiao Shicde37ad2015-12-24 01:02:05 -070072
Davide Pesavento35120ea2015-11-17 21:13:18 +010073BOOST_AUTO_TEST_SUITE_END() // TestEthernetTransport
74BOOST_AUTO_TEST_SUITE_END() // Face
75
76} // namespace tests
77} // namespace face
78} // namespace nfd