face: use NetworkMonitor::listNetworkInterfaces() in tests
refs #4021 Change-Id: I6daccc3872a0c6b2e2e49390bc5881c796503926
This commit is contained in:
1 parent
7b0071e6a9
commit
84d62cbbc6
17 files changed
+373
-266
No files matched your search
@@ -38,7 +38,7 @@ protected:
|
||||
makeChannel()
|
||||
{
|
||||
BOOST_ASSERT(netifs.size() > 0);
|
||||
return make_unique<EthernetChannel>(netifs.front().asNetworkInterface(), time::seconds(2));
|
||||
return make_unique<EthernetChannel>(netifs.front(), time::seconds(2));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(Uri)
|
||||
SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
|
||||
|
||||
auto channel = makeChannel();
|
||||
BOOST_CHECK_EQUAL(channel->getUri(), FaceUri::fromDev(netifs.front().name));
|
||||
BOOST_CHECK_EQUAL(channel->getUri(), FaceUri::fromDev(netifs.front()->getName()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Listen)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -195,12 +195,12 @@ BOOST_AUTO_TEST_CASE(Whitelist)
|
||||
}
|
||||
}
|
||||
)CONFIG";
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front().name);
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());
|
||||
|
||||
parseConfig(CONFIG, false);
|
||||
auto etherMcastFaces = this->listEtherMcastFaces();
|
||||
BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), 1);
|
||||
BOOST_CHECK_EQUAL(etherMcastFaces.front()->getLocalUri().getHost(), netifs.front().name);
|
||||
BOOST_CHECK_EQUAL(etherMcastFaces.front()->getLocalUri().getHost(), netifs.front()->getName());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Blacklist)
|
||||
@@ -219,13 +219,13 @@ BOOST_AUTO_TEST_CASE(Blacklist)
|
||||
}
|
||||
}
|
||||
)CONFIG";
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front().name);
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());
|
||||
|
||||
parseConfig(CONFIG, false);
|
||||
auto etherMcastFaces = this->listEtherMcastFaces();
|
||||
BOOST_CHECK_EQUAL(etherMcastFaces.size(), netifs.size() - 1);
|
||||
BOOST_CHECK_EQUAL(boost::count_if(etherMcastFaces, [=] (const Face* face) {
|
||||
return face->getLocalUri().getHost() == netifs.front().name;
|
||||
return face->getLocalUri().getHost() == netifs.front()->getName();
|
||||
}), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#ifndef NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
|
||||
#define NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
|
||||
|
||||
#include "core/network-interface.hpp"
|
||||
#include "face/multicast-ethernet-transport.hpp"
|
||||
#include "face/unicast-ethernet-transport.hpp"
|
||||
|
||||
#include "tests/limited-io.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
|
||||
namespace nfd {
|
||||
namespace face {
|
||||
@@ -38,16 +38,17 @@ namespace tests {
|
||||
|
||||
using namespace nfd::tests;
|
||||
|
||||
/** \brief a fixture providing a list of EthernetTransport-capable network interfaces
|
||||
*/
|
||||
class EthernetFixture : public virtual BaseFixture
|
||||
{
|
||||
protected:
|
||||
EthernetFixture()
|
||||
{
|
||||
for (const auto& netif : listNetworkInterfaces()) {
|
||||
if (!netif.isLoopback() && netif.isUp()) {
|
||||
for (const auto& netif : collectNetworkInterfaces()) {
|
||||
if (!netif->isLoopback() && netif->isUp()) {
|
||||
try {
|
||||
MulticastEthernetTransport transport(*netif.asNetworkInterface(),
|
||||
ethernet::getBroadcastAddress(),
|
||||
MulticastEthernetTransport transport(*netif, ethernet::getBroadcastAddress(),
|
||||
ndn::nfd::LINK_TYPE_MULTI_ACCESS);
|
||||
netifs.push_back(netif);
|
||||
}
|
||||
@@ -58,37 +59,40 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief create a UnicastEthernetTransport
|
||||
*/
|
||||
void
|
||||
initializeUnicast(ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
|
||||
ethernet::Address remoteAddr = {0x00, 0x00, 0x5e, 0x00, 0x53, 0x5e})
|
||||
{
|
||||
BOOST_ASSERT(netifs.size() > 0);
|
||||
localEp = netifs.front().name;
|
||||
localEp = netifs.front()->getName();
|
||||
remoteEp = remoteAddr;
|
||||
transport = make_unique<UnicastEthernetTransport>(*netifs.front().asNetworkInterface(),
|
||||
remoteEp, persistency, time::seconds(2));
|
||||
transport = make_unique<UnicastEthernetTransport>(*netifs.front(), remoteEp, persistency, time::seconds(2));
|
||||
}
|
||||
|
||||
/** \brief create a MulticastEthernetTransport
|
||||
*/
|
||||
void
|
||||
initializeMulticast(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS,
|
||||
ethernet::Address mcastGroup = {0x01, 0x00, 0x5e, 0x90, 0x10, 0x5e})
|
||||
{
|
||||
BOOST_ASSERT(netifs.size() > 0);
|
||||
localEp = netifs.front().name;
|
||||
localEp = netifs.front()->getName();
|
||||
remoteEp = mcastGroup;
|
||||
transport = make_unique<MulticastEthernetTransport>(*netifs.front().asNetworkInterface(),
|
||||
remoteEp, linkType);
|
||||
transport = make_unique<MulticastEthernetTransport>(*netifs.front(), remoteEp, linkType);
|
||||
}
|
||||
|
||||
protected:
|
||||
LimitedIo limitedIo;
|
||||
unique_ptr<EthernetTransport> transport;
|
||||
std::string localEp;
|
||||
ethernet::Address remoteEp;
|
||||
|
||||
/** \brief EthernetTransport-capable network interfaces
|
||||
*/
|
||||
std::vector<NetworkInterfaceInfo> netifs;
|
||||
std::vector<shared_ptr<const ndn::net::NetworkInterface>> netifs;
|
||||
|
||||
unique_ptr<EthernetTransport> transport;
|
||||
std::string localEp;
|
||||
ethernet::Address remoteEp;
|
||||
};
|
||||
|
||||
#define SKIP_IF_ETHERNET_NETIF_COUNT_LT(n) \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "face/face.hpp"
|
||||
|
||||
#include "dummy-receive-link-service.hpp"
|
||||
#include "test-ip.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
#include "tests/limited-io.hpp"
|
||||
|
||||
namespace nfd {
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
MulticastUdpTransportFixture()
|
||||
: transport(nullptr)
|
||||
, multicastEp(ip::address::from_string("230.15.19.47"), 7070)
|
||||
, defaultAddr(getTestIp<ip::address_v4>(LoopbackAddress::No, MulticastInterface::Yes))
|
||||
, defaultAddr(getTestIp<AddressFamily::V4>(LoopbackAddress::No, MulticastInterface::Yes))
|
||||
, receivedPackets(nullptr)
|
||||
, remoteSockRx(g_io)
|
||||
, remoteSockTx(g_io)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -25,8 +25,7 @@
|
||||
|
||||
#include "tcp-channel-fixture.hpp"
|
||||
|
||||
#include "test-ip.hpp"
|
||||
|
||||
#include "test-netif-ip.hpp"
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace nfd {
|
||||
@@ -36,16 +35,17 @@ namespace tests {
|
||||
BOOST_AUTO_TEST_SUITE(Face)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestTcpChannel, TcpChannelFixture)
|
||||
|
||||
using AddressFamilies = boost::mpl::vector<boost::asio::ip::address_v4,
|
||||
boost::asio::ip::address_v6>;
|
||||
using AddressFamilies = boost::mpl::vector<
|
||||
std::integral_constant<AddressFamily, AddressFamily::V4>,
|
||||
std::integral_constant<AddressFamily, AddressFamily::V6>>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(ConnectTimeout, A, AddressFamilies)
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(ConnectTimeout, F, AddressFamilies)
|
||||
{
|
||||
auto address = getTestIp<A>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<F::value>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
// do not listen
|
||||
|
||||
auto channel = this->makeChannel(A());
|
||||
auto channel = this->makeChannel(typename IpAddressFromFamily<F::value>::type());
|
||||
channel->connect(tcp::Endpoint(address, 7040),
|
||||
ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false,
|
||||
[this] (const shared_ptr<nfd::Face>&) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "face/face.hpp"
|
||||
|
||||
#include "dummy-receive-link-service.hpp"
|
||||
#include "test-ip.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
#include "tests/limited-io.hpp"
|
||||
|
||||
namespace nfd {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, TcpTransportFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v6>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V6>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::No);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::No);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v6>(LoopbackAddress::No);
|
||||
auto address = getTestIp<AddressFamily::V6>(LoopbackAddress::No);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PermanentReconnect)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, ndn::nfd::FACE_PERSISTENCY_PERMANENT);
|
||||
|
||||
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(ChangePersistencyFromPermanentWhenDown)
|
||||
// when persistency is changed out of permanent while transport is DOWN,
|
||||
// the transport immediately goes into FAILED state
|
||||
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, ndn::nfd::FACE_PERSISTENCY_PERMANENT);
|
||||
|
||||
@@ -206,7 +206,7 @@ asFloatMilliseconds(const time::nanoseconds& t)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PermanentReconnectWithExponentialBackoff)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
|
||||
tcp::endpoint remoteEp(address, 7070);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -26,8 +26,7 @@
|
||||
#include "tcp-channel-fixture.hpp"
|
||||
#include "udp-channel-fixture.hpp"
|
||||
|
||||
#include "test-ip.hpp"
|
||||
|
||||
#include "test-netif-ip.hpp"
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace nfd {
|
||||
@@ -37,18 +36,19 @@ namespace tests {
|
||||
BOOST_AUTO_TEST_SUITE(Face)
|
||||
BOOST_AUTO_TEST_SUITE(TestTcpUdpChannel)
|
||||
|
||||
template<typename F, typename A>
|
||||
template<typename F, AddressFamily AF>
|
||||
struct FixtureAndAddress
|
||||
{
|
||||
using Fixture = F;
|
||||
using Address = A;
|
||||
static constexpr AddressFamily ADDRESS_FAMILY = AF;
|
||||
using Address = typename IpAddressFromFamily<AF>::type;
|
||||
};
|
||||
|
||||
using FixtureAndAddressList = boost::mpl::vector<
|
||||
FixtureAndAddress<TcpChannelFixture, boost::asio::ip::address_v4>,
|
||||
FixtureAndAddress<TcpChannelFixture, boost::asio::ip::address_v6>,
|
||||
FixtureAndAddress<UdpChannelFixture, boost::asio::ip::address_v4>,
|
||||
FixtureAndAddress<UdpChannelFixture, boost::asio::ip::address_v6>
|
||||
FixtureAndAddress<TcpChannelFixture, AddressFamily::V4>,
|
||||
FixtureAndAddress<TcpChannelFixture, AddressFamily::V6>,
|
||||
FixtureAndAddress<UdpChannelFixture, AddressFamily::V4>,
|
||||
FixtureAndAddress<UdpChannelFixture, AddressFamily::V6>
|
||||
>;
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Uri, T, FixtureAndAddressList, T::Fixture)
|
||||
@@ -73,7 +73,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Listen, T, FixtureAndAddressList, T::Fixture)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(MultipleAccepts, T, FixtureAndAddressList, T::Fixture)
|
||||
{
|
||||
auto address = getTestIp<typename T::Address>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<T::ADDRESS_FAMILY>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->listen(address);
|
||||
|
||||
@@ -125,7 +125,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(MultipleAccepts, T, FixtureAndAddressList, T::F
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(FaceClosure, T, FixtureAndAddressList, T::Fixture)
|
||||
{
|
||||
auto address = getTestIp<typename T::Address>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<T::ADDRESS_FAMILY>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->listen(address);
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis.
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
*
|
||||
* NFD is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-ip.hpp"
|
||||
|
||||
#include "core/network-interface.hpp"
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
namespace {
|
||||
|
||||
template<typename E>
|
||||
bool
|
||||
matchTristate(E e, bool b)
|
||||
{
|
||||
return (e == E::DontCare) ||
|
||||
(e == E::Yes && b) ||
|
||||
(e == E::No && !b);
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
template<>
|
||||
boost::asio::ip::address_v4
|
||||
getTestIp(LoopbackAddress loopback, MulticastInterface mcast)
|
||||
{
|
||||
for (const auto& interface : listNetworkInterfaces()) {
|
||||
if (interface.isUp() &&
|
||||
matchTristate(loopback, interface.isLoopback()) &&
|
||||
matchTristate(mcast, interface.isMulticastCapable())) {
|
||||
for (const auto& address : interface.ipv4Addresses) {
|
||||
if (!address.is_unspecified() &&
|
||||
matchTristate(loopback, address.is_loopback())) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
boost::asio::ip::address_v6
|
||||
getTestIp(LoopbackAddress loopback, MulticastInterface mcast)
|
||||
{
|
||||
for (const auto& interface : listNetworkInterfaces()) {
|
||||
if (interface.isUp() &&
|
||||
matchTristate(loopback, interface.isLoopback()) &&
|
||||
matchTristate(mcast, interface.isMulticastCapable())) {
|
||||
for (const auto& address : interface.ipv6Addresses) {
|
||||
if (!address.is_unspecified() &&
|
||||
!address.is_link_local() && // see #1428
|
||||
matchTristate(loopback, address.is_loopback())) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
} // namespace nfd
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis.
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
*
|
||||
* NFD is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NFD_TESTS_DAEMON_FACE_TEST_IP_HPP
|
||||
#define NFD_TESTS_DAEMON_FACE_TEST_IP_HPP
|
||||
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
|
||||
#define SKIP_IF_IP_UNAVAILABLE(address) \
|
||||
do { \
|
||||
if ((address).is_unspecified()) { \
|
||||
BOOST_WARN_MESSAGE(false, "skipping assertions that require a valid IP address"); \
|
||||
return; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
|
||||
enum class LoopbackAddress {
|
||||
No,
|
||||
Yes,
|
||||
DontCare,
|
||||
Default = Yes
|
||||
};
|
||||
|
||||
enum class MulticastInterface {
|
||||
No,
|
||||
Yes,
|
||||
DontCare,
|
||||
Default = DontCare
|
||||
};
|
||||
|
||||
/** \brief get an IP address for test purposes from any available network interface
|
||||
* \tparam A the address type, either boost::asio::ip::address_v4 or boost::asio::ip::address_v6
|
||||
* \param loopback specifies if the address can, must, or must not be a loopback address
|
||||
* \param mcast specifies if the address can, must, or must not be chosen from a multicast-capable interface
|
||||
* \return an IP address
|
||||
* \retval default-constructed A, if no appropriate address is available
|
||||
*/
|
||||
template<typename A>
|
||||
A
|
||||
getTestIp(LoopbackAddress loopback = LoopbackAddress::Default,
|
||||
MulticastInterface mcast = MulticastInterface::Default);
|
||||
|
||||
template<>
|
||||
boost::asio::ip::address_v4
|
||||
getTestIp(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
template<>
|
||||
boost::asio::ip::address_v6
|
||||
getTestIp(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
} // namespace tests
|
||||
} // namespace nfd
|
||||
|
||||
#endif // NFD_TESTS_DAEMON_FACE_TEST_IP_HPP
|
||||
@@ -0,0 +1,122 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis.
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
*
|
||||
* NFD is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-netif-ip.hpp"
|
||||
#include "core/global-io.hpp"
|
||||
#include <ndn-cxx/net/network-monitor.hpp>
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
|
||||
std::vector<shared_ptr<const NetworkInterface>>
|
||||
collectNetworkInterfaces(bool allowCached)
|
||||
{
|
||||
using ndn::net::NetworkMonitor;
|
||||
|
||||
static std::vector<shared_ptr<const NetworkInterface>> cached;
|
||||
// cached.empty() indicates there's no cached list of netifs.
|
||||
// Although it could also mean a system without any network interface, this situation is rare
|
||||
// because the loopback interface is present on almost all systems.
|
||||
|
||||
if (!allowCached || cached.empty()) {
|
||||
NetworkMonitor netmon(getGlobalIoService());
|
||||
if ((netmon.getCapabilities() & NetworkMonitor::CAP_ENUM) == 0) {
|
||||
BOOST_THROW_EXCEPTION(NetworkMonitor::Error("NetworkMonitor::CAP_ENUM is unavailable"));
|
||||
}
|
||||
|
||||
netmon.onEnumerationCompleted.connect([] { getGlobalIoService().stop(); });
|
||||
getGlobalIoService().run();
|
||||
getGlobalIoService().reset();
|
||||
|
||||
cached = netmon.listNetworkInterfaces();
|
||||
}
|
||||
|
||||
return cached;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename E>
|
||||
bool
|
||||
matchTristate(E e, bool b)
|
||||
{
|
||||
return (e == E::DontCare) ||
|
||||
(e == E::Yes && b) ||
|
||||
(e == E::No && !b);
|
||||
}
|
||||
|
||||
template<AddressFamily AF>
|
||||
typename IpAddressFromFamily<AF>::type
|
||||
fromIpAddress(const boost::asio::ip::address& a);
|
||||
|
||||
template<>
|
||||
IpAddressFromFamily<AddressFamily::V4>::type
|
||||
fromIpAddress<AddressFamily::V4>(const boost::asio::ip::address& a)
|
||||
{
|
||||
return a.to_v4();
|
||||
}
|
||||
|
||||
template<>
|
||||
IpAddressFromFamily<AddressFamily::V6>::type
|
||||
fromIpAddress<AddressFamily::V6>(const boost::asio::ip::address& a)
|
||||
{
|
||||
return a.to_v6();
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
template<AddressFamily AF>
|
||||
typename IpAddressFromFamily<AF>::type
|
||||
getTestIp(LoopbackAddress loopback, MulticastInterface mcast)
|
||||
{
|
||||
for (const auto& interface : collectNetworkInterfaces()) {
|
||||
if (!interface->isUp() ||
|
||||
!matchTristate(loopback, interface->isLoopback()) ||
|
||||
!matchTristate(mcast, interface->canMulticast())) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& address : interface->getNetworkAddresses()) {
|
||||
if (isAddressFamily<AF>(address) &&
|
||||
!address.getIp().is_unspecified() &&
|
||||
address.getScope() != ndn::net::AddressScope::NOWHERE &&
|
||||
address.getScope() != ndn::net::AddressScope::LINK && // link-local addresses are not supported yet (#1428)
|
||||
matchTristate(loopback, address.getIp().is_loopback())) {
|
||||
return fromIpAddress<AF>(address.getIp());
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template
|
||||
IpAddressFromFamily<AddressFamily::V4>::type
|
||||
getTestIp<AddressFamily::V4>(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
template
|
||||
IpAddressFromFamily<AddressFamily::V6>::type
|
||||
getTestIp<AddressFamily::V6>(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
} // namespace tests
|
||||
} // namespace nfd
|
||||
@@ -0,0 +1,144 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis.
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
*
|
||||
* NFD is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NFD_TESTS_DAEMON_FACE_TEST_NETIF_IP_HPP
|
||||
#define NFD_TESTS_DAEMON_FACE_TEST_NETIF_IP_HPP
|
||||
|
||||
#include "core/common.hpp"
|
||||
#include <type_traits>
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include <ndn-cxx/net/network-address.hpp>
|
||||
#include <ndn-cxx/net/network-interface.hpp>
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
|
||||
using ndn::net::AddressFamily;
|
||||
using ndn::net::NetworkAddress;
|
||||
using ndn::net::NetworkInterface;
|
||||
|
||||
// ---- network interface ----
|
||||
|
||||
/** \brief Collect information about network interfaces
|
||||
* \param allowCached if true, previously collected information can be returned
|
||||
* \note This function is blocking if \p allowCached is false or no previous information exists
|
||||
* \throw ndn::net::NetworkMonitor::Error NetworkMonitor::CAP_ENUM is unavailable
|
||||
*/
|
||||
std::vector<shared_ptr<const NetworkInterface>>
|
||||
collectNetworkInterfaces(bool allowCached = true);
|
||||
|
||||
template<AddressFamily AF>
|
||||
bool
|
||||
isAddressFamily(const NetworkAddress& a)
|
||||
{
|
||||
return a.getFamily() == AF;
|
||||
}
|
||||
|
||||
template<AddressFamily AF>
|
||||
bool
|
||||
hasAddressFamily(const NetworkInterface& netif)
|
||||
{
|
||||
return std::any_of(netif.getNetworkAddresses().begin(), netif.getNetworkAddresses().end(),
|
||||
&isAddressFamily<AF>);
|
||||
}
|
||||
|
||||
// ---- IP address ----
|
||||
|
||||
enum class LoopbackAddress {
|
||||
No,
|
||||
Yes,
|
||||
DontCare,
|
||||
Default = Yes
|
||||
};
|
||||
|
||||
enum class MulticastInterface {
|
||||
No,
|
||||
Yes,
|
||||
DontCare,
|
||||
Default = DontCare
|
||||
};
|
||||
|
||||
/** \brief Derives IP address type from AddressFamily
|
||||
*/
|
||||
template<AddressFamily AF>
|
||||
struct IpAddressFromFamily;
|
||||
|
||||
template<>
|
||||
struct IpAddressFromFamily<AddressFamily::V4>
|
||||
{
|
||||
using type = boost::asio::ip::address_v4;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct IpAddressFromFamily<AddressFamily::V6>
|
||||
{
|
||||
using type = boost::asio::ip::address_v6;
|
||||
};
|
||||
|
||||
/** \brief Get an IP address from any available network interface
|
||||
* \tparam F address family, either AddressFamily::V4 or AddressFamily::V6
|
||||
* \param loopback specifies if the address can, must, or must not be a loopback address
|
||||
* \param mcast specifies if the address can, must, or must not be chosen from a multicast-capable interface
|
||||
* \return an IP address, either boost::asio::ip::address_v4 or boost::asio::ip::address_v6
|
||||
* \retval unspecified address, if no appropriate address is available
|
||||
*/
|
||||
template<AddressFamily F>
|
||||
typename IpAddressFromFamily<F>::type
|
||||
getTestIp(LoopbackAddress loopback = LoopbackAddress::Default,
|
||||
MulticastInterface mcast = MulticastInterface::Default);
|
||||
|
||||
extern template
|
||||
IpAddressFromFamily<AddressFamily::V4>::type
|
||||
getTestIp<AddressFamily::V4>(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
extern template
|
||||
IpAddressFromFamily<AddressFamily::V6>::type
|
||||
getTestIp<AddressFamily::V6>(LoopbackAddress loopback, MulticastInterface mcast);
|
||||
|
||||
/** \brief Skip rest of the test case if \p address is unavailable
|
||||
*
|
||||
* This macro can be used in conjunction with \p nfd::tests::getTestIp in a test case. Example:
|
||||
* \code
|
||||
* BOOST_AUTO_TEST_CASE(TestCase)
|
||||
* {
|
||||
* auto ip = getTestIp<AddressFamily::V4>();
|
||||
* SKIP_IF_IP_UNAVAILABLE(ip);
|
||||
* // Test something that requires an IPv4 address.
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
#define SKIP_IF_IP_UNAVAILABLE(address) \
|
||||
do { \
|
||||
if ((address).is_unspecified()) { \
|
||||
BOOST_WARN_MESSAGE(false, "skipping assertions that require a valid IP address"); \
|
||||
return; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
} // namespace tests
|
||||
} // namespace nfd
|
||||
|
||||
#endif // NFD_TESTS_DAEMON_FACE_TEST_NETIF_IP_HPP
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "factory-test-common.hpp"
|
||||
#include "face-system-fixture.hpp"
|
||||
#include "tests/limited-io.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/range/algorithm.hpp>
|
||||
|
||||
@@ -114,8 +115,8 @@ class UdpMcastConfigFixture : public FaceSystemFixture
|
||||
protected:
|
||||
UdpMcastConfigFixture()
|
||||
{
|
||||
for (const auto& netif : listNetworkInterfaces()) {
|
||||
if (netif.isUp() && netif.isMulticastCapable() && !netif.ipv4Addresses.empty()) {
|
||||
for (const auto& netif : collectNetworkInterfaces()) {
|
||||
if (netif->isUp() && netif->canMulticast() && hasAddressFamily<AddressFamily::V4>(*netif)) {
|
||||
netifs.push_back(netif);
|
||||
}
|
||||
}
|
||||
@@ -136,16 +137,17 @@ protected:
|
||||
/** \brief determine whether a UDP multicast face is created on \p netif
|
||||
*/
|
||||
static bool
|
||||
isFaceOnNetif(const Face& face, const NetworkInterfaceInfo& netif)
|
||||
isFaceOnNetif(const Face& face, const shared_ptr<const ndn::net::NetworkInterface>& netif)
|
||||
{
|
||||
auto ip = boost::asio::ip::address_v4::from_string(face.getLocalUri().getHost());
|
||||
return boost::count(netif.ipv4Addresses, ip) > 0;
|
||||
return std::any_of(netif->getNetworkAddresses().begin(), netif->getNetworkAddresses().end(),
|
||||
[ip] (const ndn::net::NetworkAddress& a) { return a.getIp() == ip; });
|
||||
}
|
||||
|
||||
protected:
|
||||
/** \brief MulticastUdpTransport-capable network interfaces
|
||||
*/
|
||||
std::vector<NetworkInterfaceInfo> netifs;
|
||||
std::vector<shared_ptr<const ndn::net::NetworkInterface>> netifs;
|
||||
};
|
||||
|
||||
#define SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(n) \
|
||||
@@ -282,7 +284,7 @@ BOOST_FIXTURE_TEST_CASE(Whitelist, UdpMcastConfigFixture)
|
||||
}
|
||||
}
|
||||
)CONFIG";
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front().name);
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());
|
||||
|
||||
parseConfig(CONFIG, false);
|
||||
auto udpMcastFaces = this->listUdpMcastFaces();
|
||||
@@ -310,7 +312,7 @@ BOOST_FIXTURE_TEST_CASE(Blacklist, UdpMcastConfigFixture)
|
||||
}
|
||||
}
|
||||
)CONFIG";
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front().name);
|
||||
boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());
|
||||
|
||||
parseConfig(CONFIG, false);
|
||||
auto udpMcastFaces = this->listUdpMcastFaces();
|
||||
@@ -341,8 +343,8 @@ BOOST_FIXTURE_TEST_CASE(ChangePredicate, UdpMcastConfigFixture)
|
||||
}
|
||||
)CONFIG";
|
||||
std::string CONFIG2 = CONFIG1;
|
||||
boost::replace_first(CONFIG1, "%ifname", netifs.front().name);
|
||||
boost::replace_first(CONFIG2, "%ifname", netifs.back().name);
|
||||
boost::replace_first(CONFIG1, "%ifname", netifs.front()->getName());
|
||||
boost::replace_first(CONFIG2, "%ifname", netifs.back()->getName());
|
||||
|
||||
parseConfig(CONFIG1, false);
|
||||
auto udpMcastFaces = this->listUdpMcastFaces();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "face/face.hpp"
|
||||
|
||||
#include "dummy-receive-link-service.hpp"
|
||||
#include "test-ip.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
#include "tests/limited-io.hpp"
|
||||
|
||||
namespace nfd {
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
UnicastUdpTransportFixture()
|
||||
: transport(nullptr)
|
||||
, remoteSocket(g_io)
|
||||
, defaultAddr(getTestIp<ip::address_v4>())
|
||||
, defaultAddr(getTestIp<AddressFamily::V4>())
|
||||
, receivedPackets(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_SUITE(TestUnicastUdpTransport, UnicastUdpTransportFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v6>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V6>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::No);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::No);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v6>(LoopbackAddress::No);
|
||||
auto address = getTestIp<AddressFamily::V6>(LoopbackAddress::No);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address);
|
||||
|
||||
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ExpirationTime)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, ndn::nfd::FACE_PERSISTENCY_ON_DEMAND);
|
||||
BOOST_CHECK_NE(transport->getExpirationTime(), time::steady_clock::TimePoint::max());
|
||||
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(ExpirationTime)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(IdleClose)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, ndn::nfd::FACE_PERSISTENCY_ON_DEMAND);
|
||||
|
||||
@@ -162,7 +162,7 @@ using RemoteClosePersistencies = boost::mpl::vector<OnDemand, Persistent>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(RemoteClose, Persistency, RemoteClosePersistencies)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, Persistency::value);
|
||||
|
||||
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(RemoteClose, Persistency, RemoteClosePersistencies
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RemoteClosePermanent)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
initialize(address, ndn::nfd::FACE_PERSISTENCY_PERMANENT);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "face/websocket-transport.hpp"
|
||||
|
||||
#include "channel-fixture.hpp"
|
||||
#include "test-ip.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
|
||||
namespace nfd {
|
||||
namespace face {
|
||||
@@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(Listen)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(MultipleAccepts)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->listen(address);
|
||||
|
||||
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(MultipleAccepts)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Send)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address);
|
||||
auto transport = listenerFaces.front()->getTransport();
|
||||
@@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE(Send)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Receive)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address);
|
||||
|
||||
@@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(Receive)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(FaceClosure)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address);
|
||||
|
||||
@@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE(FaceClosure)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RemoteClose)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address);
|
||||
|
||||
@@ -288,7 +288,7 @@ BOOST_AUTO_TEST_CASE(RemoteClose)
|
||||
BOOST_AUTO_TEST_CASE(SetPingInterval)
|
||||
{
|
||||
auto pingInterval = time::milliseconds(300);
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address, pingInterval, time::milliseconds(1000));
|
||||
|
||||
@@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(SetPingInterval)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SetPongTimeOut)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->initialize(address, time::milliseconds(500), time::milliseconds(300));
|
||||
clientShouldPong = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "face/face.hpp"
|
||||
|
||||
#include "dummy-receive-link-service.hpp"
|
||||
#include "test-ip.hpp"
|
||||
#include "test-netif-ip.hpp"
|
||||
#include "transport-test-common.hpp"
|
||||
#include "tests/limited-io.hpp"
|
||||
|
||||
@@ -227,7 +227,7 @@ BOOST_FIXTURE_TEST_SUITE(TestWebSocketTransport, SingleWebSocketFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
ip::tcp::endpoint ep(address, 20070);
|
||||
this->endToEndInitialize(ep);
|
||||
@@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>(LoopbackAddress::No);
|
||||
auto address = getTestIp<AddressFamily::V4>(LoopbackAddress::No);
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
ip::tcp::endpoint ep(address, 20070);
|
||||
this->endToEndInitialize(ep);
|
||||
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4MappedIpv6)
|
||||
{
|
||||
auto address4 = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
|
||||
auto address4 = getTestIp<AddressFamily::V4>(LoopbackAddress::Yes);
|
||||
SKIP_IF_IP_UNAVAILABLE(address4);
|
||||
auto address6 = ip::address_v6::v4_mapped(address4);
|
||||
BOOST_REQUIRE(address6.is_v4_mapped());
|
||||
@@ -280,7 +280,7 @@ BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4MappedIpv6)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
@@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PingPong)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070),
|
||||
time::milliseconds(500), time::milliseconds(300));
|
||||
@@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(PingPong)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Send)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
@@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(Send)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ReceiveNormal)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(ReceiveNormal)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ReceiveMalformed)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
@@ -391,7 +391,7 @@ BOOST_AUTO_TEST_CASE(ReceiveMalformed)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Close)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
@@ -419,7 +419,7 @@ BOOST_AUTO_TEST_CASE(Close)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RemoteClose)
|
||||
{
|
||||
auto address = getTestIp<ip::address_v4>();
|
||||
auto address = getTestIp<AddressFamily::V4>();
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->endToEndInitialize(ip::tcp::endpoint(address, 20070));
|
||||
|
||||
|
||||
Reference in new issue
Block a user