tests: refactor EthernetFixture
Also, use BOOST_TEST_INFO_SCOPE in a few places. Change-Id: I113f326207825949ed9d3d22ade0654976d49b76
This commit is contained in:
1 parent
c5a9f81fce
commit
d7083a507f
18 files changed
+214
-163
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -49,22 +49,20 @@ protected:
|
||||
{
|
||||
std::set<std::string> uris;
|
||||
std::transform(netifs.begin(), netifs.end(), std::inserter(uris, uris.end()),
|
||||
[] (const auto& netif) {
|
||||
return FaceUri::fromDev(netif->getName()).toString();
|
||||
});
|
||||
[] (const auto& netif) { return FaceUri::fromDev(netif->getName()).toString(); });
|
||||
return uris;
|
||||
}
|
||||
|
||||
std::vector<const Face*>
|
||||
listEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
|
||||
{
|
||||
return this->listFacesByScheme("ether", linkType);
|
||||
return listFacesByScheme("ether", linkType);
|
||||
}
|
||||
|
||||
size_t
|
||||
countEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
|
||||
{
|
||||
return this->listEtherMcastFaces(linkType).size();
|
||||
return listEtherMcastFaces(linkType).size();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -303,10 +301,9 @@ BOOST_AUTO_TEST_CASE(Blacklist)
|
||||
auto etherMcastFaces = this->listEtherMcastFaces();
|
||||
BOOST_CHECK_EQUAL(etherMcastFaces.size(), netifs.size() - 1);
|
||||
BOOST_CHECK(std::none_of(etherMcastFaces.begin(), etherMcastFaces.end(),
|
||||
[ifname] (const nfd::Face* face) {
|
||||
return face->getLocalUri() == FaceUri::fromDev(ifname);
|
||||
}
|
||||
));
|
||||
[uri = FaceUri::fromDev(ifname)] (const auto* face) {
|
||||
return face->getLocalUri() == uri;
|
||||
}));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Omitted)
|
||||
@@ -438,6 +435,7 @@ BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
|
||||
BOOST_AUTO_TEST_CASE(GetChannels)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(factory.getChannels().empty(), true);
|
||||
|
||||
SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
|
||||
|
||||
factory.createChannel(netifs.front(), 1_min);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -27,17 +27,12 @@
|
||||
#define NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
|
||||
|
||||
#include "face/multicast-ethernet-transport.hpp"
|
||||
#include "face/unicast-ethernet-transport.hpp"
|
||||
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/global-io-fixture.hpp"
|
||||
#include "test-netif.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using face::EthernetTransport;
|
||||
using face::MulticastEthernetTransport;
|
||||
using face::UnicastEthernetTransport;
|
||||
|
||||
/**
|
||||
* \brief Fixture providing a list of EthernetTransport-capable network interfaces.
|
||||
*/
|
||||
@@ -47,79 +42,25 @@ protected:
|
||||
EthernetFixture()
|
||||
{
|
||||
for (const auto& netif : collectNetworkInterfaces()) {
|
||||
if (!netif->isLoopback() && netif->isUp()) {
|
||||
// similar filtering logic to EthernetFactory::applyMcastConfigToNetif()
|
||||
if (netif->isUp() && !netif->isLoopback() && netif->canMulticast()) {
|
||||
try {
|
||||
MulticastEthernetTransport t(*netif, ethernet::getBroadcastAddress(),
|
||||
ndn::nfd::LINK_TYPE_MULTI_ACCESS);
|
||||
face::MulticastEthernetTransport t(*netif, ethernet::getBroadcastAddress(),
|
||||
ndn::nfd::LINK_TYPE_MULTI_ACCESS);
|
||||
netifs.push_back(netif);
|
||||
}
|
||||
catch (const EthernetTransport::Error&) {
|
||||
catch (const face::EthernetTransport::Error&) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!netifs.empty()) {
|
||||
defaultNetif = const_pointer_cast<ndn::net::NetworkInterface>(netifs.front());
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Returns the first running interface.
|
||||
*/
|
||||
shared_ptr<ndn::net::NetworkInterface>
|
||||
getRunningNetif() const
|
||||
{
|
||||
for (const auto& netif : netifs) {
|
||||
if (netif->getState() == ndn::net::InterfaceState::RUNNING) {
|
||||
return const_pointer_cast<ndn::net::NetworkInterface>(netif);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \brief Create a UnicastEthernetTransport.
|
||||
*/
|
||||
void
|
||||
initializeUnicast(shared_ptr<ndn::net::NetworkInterface> netif = nullptr,
|
||||
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
|
||||
ethernet::Address remoteAddr = {0x00, 0x00, 0x5e, 0x00, 0x53, 0x5e})
|
||||
{
|
||||
if (!netif) {
|
||||
netif = defaultNetif;
|
||||
}
|
||||
|
||||
localEp = netif->getName();
|
||||
remoteEp = remoteAddr;
|
||||
transport = make_unique<UnicastEthernetTransport>(*netif, remoteEp, persistency, 2_s);
|
||||
}
|
||||
|
||||
/** \brief Create a MulticastEthernetTransport.
|
||||
*/
|
||||
void
|
||||
initializeMulticast(shared_ptr<ndn::net::NetworkInterface> netif = nullptr,
|
||||
ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS,
|
||||
ethernet::Address mcastGroup = {0x01, 0x00, 0x5e, 0x90, 0x10, 0x5e})
|
||||
{
|
||||
if (!netif) {
|
||||
netif = defaultNetif;
|
||||
}
|
||||
|
||||
localEp = netif->getName();
|
||||
remoteEp = mcastGroup;
|
||||
transport = make_unique<MulticastEthernetTransport>(*netif, remoteEp, linkType);
|
||||
}
|
||||
|
||||
protected:
|
||||
LimitedIo limitedIo;
|
||||
|
||||
/** \brief EthernetTransport-capable network interfaces.
|
||||
/**
|
||||
* \brief EthernetTransport-capable network interfaces.
|
||||
*/
|
||||
std::vector<shared_ptr<const ndn::net::NetworkInterface>> netifs;
|
||||
|
||||
shared_ptr<ndn::net::NetworkInterface> defaultNetif;
|
||||
unique_ptr<EthernetTransport> transport;
|
||||
std::string localEp;
|
||||
ethernet::Address remoteEp;
|
||||
};
|
||||
|
||||
} // namespace nfd::tests
|
||||
@@ -133,13 +74,4 @@ protected:
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define SKIP_IF_NO_RUNNING_ETHERNET_NETIF() \
|
||||
do { \
|
||||
if (!this->getRunningNetif()) { \
|
||||
BOOST_WARN_MESSAGE(false, "skipping assertions that require a running " \
|
||||
"EthernetTransport-capable network interface"); \
|
||||
return; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#endif // NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
|
||||
@@ -0,0 +1,115 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2023, 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_ETHERNET_TRANSPORT_FIXTURE_HPP
|
||||
#define NFD_TESTS_DAEMON_FACE_ETHERNET_TRANSPORT_FIXTURE_HPP
|
||||
|
||||
#include "face/multicast-ethernet-transport.hpp"
|
||||
#include "face/unicast-ethernet-transport.hpp"
|
||||
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "ethernet-fixture.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
class EthernetTransportFixture : public EthernetFixture
|
||||
{
|
||||
protected:
|
||||
EthernetTransportFixture()
|
||||
{
|
||||
if (!netifs.empty()) {
|
||||
defaultNetif = const_pointer_cast<ndn::net::NetworkInterface>(netifs.front());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the first running interface.
|
||||
*/
|
||||
shared_ptr<ndn::net::NetworkInterface>
|
||||
getRunningNetif() const
|
||||
{
|
||||
for (const auto& netif : netifs) {
|
||||
if (netif->getState() == ndn::net::InterfaceState::RUNNING) {
|
||||
return const_pointer_cast<ndn::net::NetworkInterface>(netif);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Create a UnicastEthernetTransport.
|
||||
*/
|
||||
void
|
||||
initializeUnicast(shared_ptr<ndn::net::NetworkInterface> netif = nullptr,
|
||||
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
|
||||
ethernet::Address remoteAddr = {0x00, 0x00, 0x5e, 0x00, 0x53, 0x5e})
|
||||
{
|
||||
if (!netif) {
|
||||
netif = defaultNetif;
|
||||
}
|
||||
|
||||
localEp = netif->getName();
|
||||
remoteEp = remoteAddr;
|
||||
transport = make_unique<face::UnicastEthernetTransport>(*netif, remoteEp, persistency, 2_s);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Create a MulticastEthernetTransport.
|
||||
*/
|
||||
void
|
||||
initializeMulticast(shared_ptr<ndn::net::NetworkInterface> netif = nullptr,
|
||||
ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS,
|
||||
ethernet::Address mcastGroup = {0x01, 0x00, 0x5e, 0x90, 0x10, 0x5e})
|
||||
{
|
||||
if (!netif) {
|
||||
netif = defaultNetif;
|
||||
}
|
||||
|
||||
localEp = netif->getName();
|
||||
remoteEp = mcastGroup;
|
||||
transport = make_unique<face::MulticastEthernetTransport>(*netif, remoteEp, linkType);
|
||||
}
|
||||
|
||||
protected:
|
||||
LimitedIo limitedIo;
|
||||
shared_ptr<ndn::net::NetworkInterface> defaultNetif;
|
||||
unique_ptr<face::EthernetTransport> transport;
|
||||
std::string localEp;
|
||||
ethernet::Address remoteEp;
|
||||
};
|
||||
|
||||
} // namespace nfd::tests
|
||||
|
||||
#define SKIP_IF_NO_RUNNING_ETHERNET_NETIF() \
|
||||
do { \
|
||||
if (!this->getRunningNetif()) { \
|
||||
BOOST_WARN_MESSAGE(false, "skipping assertions that require a running " \
|
||||
"EthernetTransport-capable network interface"); \
|
||||
return; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#endif // NFD_TESTS_DAEMON_FACE_ETHERNET_TRANSPORT_FIXTURE_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -23,7 +23,7 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ethernet-fixture.hpp"
|
||||
#include "ethernet-transport-fixture.hpp"
|
||||
|
||||
#include "common/global.hpp"
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace nfd::tests {
|
||||
using namespace nfd::face;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Face)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestMulticastEthernetTransport, EthernetFixture)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestMulticastEthernetTransport, EthernetTransportFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticProperties)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -32,25 +32,27 @@
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
/** \brief Check that a transport has all its static properties set after initialization
|
||||
/**
|
||||
* \brief Check that a transport has all its static properties set after initialization.
|
||||
*
|
||||
* This check shall be inserted to the StaticProperties test case for each transport,
|
||||
* in addition to checking the values of properties.
|
||||
* When a new static property is defined, this test case shall be updated.
|
||||
* Thus, if a transport forgets to set a static property, this check would fail.
|
||||
* This check shall be inserted to the StaticProperties test case for each transport,
|
||||
* in addition to checking the values of properties.
|
||||
* When a new static property is defined, this test case shall be updated.
|
||||
* Thus, if a transport forgets to set a static property, this check would fail.
|
||||
*/
|
||||
inline void
|
||||
checkStaticPropertiesInitialized(const face::Transport& transport)
|
||||
{
|
||||
BOOST_CHECK(!transport.getLocalUri().getScheme().empty());
|
||||
BOOST_CHECK(!transport.getRemoteUri().getScheme().empty());
|
||||
BOOST_CHECK_NE(transport.getScope(), ndn::nfd::FACE_SCOPE_NONE);
|
||||
BOOST_CHECK_NE(transport.getPersistency(), ndn::nfd::FACE_PERSISTENCY_NONE);
|
||||
BOOST_CHECK_NE(transport.getLinkType(), ndn::nfd::LINK_TYPE_NONE);
|
||||
BOOST_CHECK_NE(transport.getMtu(), face::MTU_INVALID);
|
||||
BOOST_TEST(transport.getLocalUri().getScheme().empty() == false);
|
||||
BOOST_TEST(transport.getRemoteUri().getScheme().empty() == false);
|
||||
BOOST_TEST(transport.getScope() != ndn::nfd::FACE_SCOPE_NONE);
|
||||
BOOST_TEST(transport.getPersistency() != ndn::nfd::FACE_PERSISTENCY_NONE);
|
||||
BOOST_TEST(transport.getLinkType() != ndn::nfd::LINK_TYPE_NONE);
|
||||
BOOST_TEST(transport.getMtu() != face::MTU_INVALID);
|
||||
}
|
||||
|
||||
/** \brief Generic wrapper for transport fixtures that require an IP address
|
||||
/**
|
||||
* \brief Generic wrapper for transport fixtures that require an IP address.
|
||||
*/
|
||||
template<typename TransportFixtureBase,
|
||||
AddressFamily AF = AddressFamily::Any,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SetState, T, AllStateTransitions)
|
||||
|
||||
auto from = static_cast<TransportState>(T::first::value);
|
||||
auto to = static_cast<TransportState>(T::second::value);
|
||||
BOOST_TEST_MESSAGE("SetState " << from << " -> " << to);
|
||||
BOOST_TEST_INFO_SCOPE(from << " -> " << to);
|
||||
|
||||
// enter from state
|
||||
using Steps = typename mpl::at<StateEntering, mpl::int_<T::first::value>>::type;
|
||||
@@ -155,12 +155,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SetState, T, AllStateTransitions)
|
||||
BOOST_REQUIRE_EQUAL(transport->getState(), from);
|
||||
|
||||
bool hasSignal = false;
|
||||
transport->afterStateChange.connect(
|
||||
[from, to, &hasSignal] (TransportState oldState, TransportState newState) {
|
||||
hasSignal = true;
|
||||
BOOST_CHECK_EQUAL(oldState, from);
|
||||
BOOST_CHECK_EQUAL(newState, to);
|
||||
});
|
||||
transport->afterStateChange.connect([&] (TransportState oldState, TransportState newState) {
|
||||
hasSignal = true;
|
||||
BOOST_CHECK_EQUAL(oldState, from);
|
||||
BOOST_CHECK_EQUAL(newState, to);
|
||||
});
|
||||
|
||||
// do transition
|
||||
bool isValid = from == to ||
|
||||
|
||||
@@ -69,7 +69,7 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
this->copyRealNetifsToNetmon();
|
||||
copyRealNetifsToNetmon();
|
||||
}
|
||||
|
||||
shared_ptr<Face>
|
||||
@@ -106,16 +106,17 @@ protected:
|
||||
std::vector<const Face*>
|
||||
listUdp4McastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
|
||||
{
|
||||
return this->listFacesByScheme("udp4", linkType);
|
||||
return listFacesByScheme("udp4", linkType);
|
||||
}
|
||||
|
||||
std::vector<const Face*>
|
||||
listUdp6McastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
|
||||
{
|
||||
return this->listFacesByScheme("udp6", linkType);
|
||||
return listFacesByScheme("udp6", linkType);
|
||||
}
|
||||
|
||||
/** \brief Determine whether \p netif has at least one IP address of the given family.
|
||||
/**
|
||||
* \brief Determine whether \p netif has at least one IP address of the given family.
|
||||
*/
|
||||
static bool
|
||||
hasAddressFamily(const NetworkInterface& netif, ndn::net::AddressFamily af)
|
||||
@@ -124,7 +125,8 @@ protected:
|
||||
[af] (const auto& a) { return a.getFamily() == af; });
|
||||
}
|
||||
|
||||
/** \brief Determine whether a UDP multicast face is created on \p netif.
|
||||
/**
|
||||
* \brief Determine whether a UDP multicast face is created on \p netif.
|
||||
*/
|
||||
static bool
|
||||
isFaceOnNetif(const Face& face, const NetworkInterface& netif)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ethernet-fixture.hpp"
|
||||
#include "ethernet-transport-fixture.hpp"
|
||||
|
||||
#include "common/global.hpp"
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace nfd::tests {
|
||||
using namespace nfd::face;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Face)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestUnicastEthernetTransport, EthernetFixture)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestUnicastEthernetTransport, EthernetTransportFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StaticProperties)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -541,17 +541,16 @@ BOOST_AUTO_TEST_CASE(Parameters)
|
||||
FaceTable faceTable;
|
||||
Forwarder forwarder{faceTable};
|
||||
|
||||
auto checkValidity = [&] (const std::string& parameters, bool isCorrect) {
|
||||
Name strategyName(Name(AsfStrategy::getStrategyName()).append(parameters));
|
||||
auto checkValidity = [&] (std::string_view parameters, bool isCorrect) {
|
||||
BOOST_TEST_INFO_SCOPE(parameters);
|
||||
Name strategyName(Name(AsfStrategy::getStrategyName()).append(Name(parameters)));
|
||||
std::unique_ptr<AsfStrategy> strategy;
|
||||
BOOST_TEST_CONTEXT(parameters) {
|
||||
if (isCorrect) {
|
||||
strategy = make_unique<AsfStrategy>(forwarder, strategyName);
|
||||
BOOST_CHECK(strategy->m_retxSuppression != nullptr);
|
||||
}
|
||||
else {
|
||||
BOOST_CHECK_THROW(make_unique<AsfStrategy>(forwarder, strategyName), std::invalid_argument);
|
||||
}
|
||||
if (isCorrect) {
|
||||
strategy = make_unique<AsfStrategy>(forwarder, strategyName);
|
||||
BOOST_CHECK(strategy->m_retxSuppression != nullptr);
|
||||
}
|
||||
else {
|
||||
BOOST_CHECK_THROW(make_unique<AsfStrategy>(forwarder, strategyName), std::invalid_argument);
|
||||
}
|
||||
return strategy;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -125,18 +125,17 @@ class SuppressionParametersFixture
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<S>
|
||||
checkValidity(const std::string& parameters, bool isCorrect)
|
||||
checkValidity(std::string_view parameters, bool isCorrect)
|
||||
{
|
||||
Name strategyName(Name(S::getStrategyName()).append(parameters));
|
||||
BOOST_TEST_INFO_SCOPE(parameters);
|
||||
Name strategyName(Name(S::getStrategyName()).append(Name(parameters)));
|
||||
std::unique_ptr<S> strategy;
|
||||
BOOST_TEST_CONTEXT(parameters) {
|
||||
if (isCorrect) {
|
||||
strategy = make_unique<S>(m_forwarder, strategyName);
|
||||
BOOST_CHECK(strategy->m_retxSuppression != nullptr);
|
||||
}
|
||||
else {
|
||||
BOOST_CHECK_THROW(make_unique<S>(m_forwarder, strategyName), std::invalid_argument);
|
||||
}
|
||||
if (isCorrect) {
|
||||
strategy = make_unique<S>(m_forwarder, strategyName);
|
||||
BOOST_CHECK(strategy->m_retxSuppression != nullptr);
|
||||
}
|
||||
else {
|
||||
BOOST_CHECK_THROW(make_unique<S>(m_forwarder, strategyName), std::invalid_argument);
|
||||
}
|
||||
return strategy;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -60,8 +60,9 @@ public:
|
||||
RANDOMIZE_COUNTERS = 1 << 3,
|
||||
};
|
||||
|
||||
/** \brief Adds a face to the FaceTable.
|
||||
* \param options bitwise OR'ed AddFaceFlags
|
||||
/**
|
||||
* \brief Adds a face to the FaceTable.
|
||||
* \param flags bitwise OR'ed AddFaceFlags
|
||||
*/
|
||||
shared_ptr<Face>
|
||||
addFace(unsigned int flags = 0)
|
||||
@@ -169,6 +170,7 @@ BOOST_AUTO_TEST_CASE(FaceDataset)
|
||||
std::set<FaceId> faceIds;
|
||||
for (size_t idx = 0; idx < nEntries; ++idx) {
|
||||
ndn::nfd::FaceStatus decodedStatus(content.elements()[idx]);
|
||||
BOOST_TEST_INFO_SCOPE(decodedStatus);
|
||||
BOOST_CHECK(m_faceTable.get(decodedStatus.getFaceId()) != nullptr);
|
||||
faceIds.insert(decodedStatus.getFaceId());
|
||||
}
|
||||
@@ -330,6 +332,7 @@ BOOST_AUTO_TEST_CASE(ChannelDataset)
|
||||
|
||||
for (size_t idx = 0; idx < nEntries; ++idx) {
|
||||
ndn::nfd::ChannelStatus decodedStatus(content.elements()[idx]);
|
||||
BOOST_TEST_INFO_SCOPE(decodedStatus);
|
||||
BOOST_CHECK(addedChannels.find(decodedStatus.getLocalUri()) != addedChannels.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,6 +421,7 @@ BOOST_AUTO_TEST_CASE(FibDataset)
|
||||
std::vector<ndn::nfd::FibEntry> receivedRecords, expectedRecords;
|
||||
for (size_t idx = 0; idx < nEntries; ++idx) {
|
||||
ndn::nfd::FibEntry decodedEntry(content.elements()[idx]);
|
||||
BOOST_TEST_INFO_SCOPE(decodedEntry);
|
||||
receivedRecords.push_back(decodedEntry);
|
||||
actualPrefixes.erase(decodedEntry.getPrefix());
|
||||
|
||||
|
||||
@@ -71,14 +71,14 @@ public:
|
||||
loadDefaultPaConfig();
|
||||
}
|
||||
|
||||
template<typename ...T>
|
||||
template<typename... T>
|
||||
ndn::PrefixAnnouncement
|
||||
makeTrustedAnn(T&&... args)
|
||||
{
|
||||
return signPrefixAnn(makePrefixAnn(std::forward<T>(args)...), m_keyChain, m_trustedSigner);
|
||||
}
|
||||
|
||||
template<typename ...T>
|
||||
template<typename... T>
|
||||
ndn::PrefixAnnouncement
|
||||
makeUntrustedAnn(T&&... args)
|
||||
{
|
||||
|
||||
@@ -486,6 +486,7 @@ BOOST_FIXTURE_TEST_CASE(RibDataset, UnauthorizedRibManagerFixture)
|
||||
std::vector<ndn::nfd::RibEntry> receivedRecords, expectedRecords;
|
||||
for (size_t idx = 0; idx < nEntries; ++idx) {
|
||||
ndn::nfd::RibEntry decodedEntry(content.elements()[idx]);
|
||||
BOOST_TEST_INFO_SCOPE(decodedEntry);
|
||||
receivedRecords.push_back(decodedEntry);
|
||||
actualPrefixes.erase(decodedEntry.getName());
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -218,14 +218,13 @@ BOOST_AUTO_TEST_CASE(StrategyChoiceDataset)
|
||||
|
||||
for (auto i = dataset.elements_begin(); i != dataset.elements_end(); ++i) {
|
||||
ndn::nfd::StrategyChoice record(*i);
|
||||
BOOST_TEST_INFO_SCOPE(record);
|
||||
auto found = expected.find(record.getName());
|
||||
if (found == expected.end()) {
|
||||
BOOST_ERROR("record has unexpected namespace " << record.getName());
|
||||
}
|
||||
else {
|
||||
BOOST_CHECK_MESSAGE(record.getStrategy() == found->second,
|
||||
"record for " << record.getName() << " has wrong strategy " << record.getStrategy() <<
|
||||
", should be " << found->second);
|
||||
BOOST_TEST(record.getStrategy() == found->second);
|
||||
expected.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,20 +244,21 @@ BOOST_AUTO_TEST_CASE(LongestPrefixMatchWithMeasurementsEntry)
|
||||
BOOST_CHECK_EQUAL(fib.findLongestPrefixMatch(mABCD).getPrefix(), "/A/B/C");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
validateFindExactMatch(Fib& fib, const Name& target)
|
||||
{
|
||||
BOOST_TEST_INFO_SCOPE(target);
|
||||
const Entry* entry = fib.findExactMatch(target);
|
||||
BOOST_REQUIRE_MESSAGE(entry != nullptr, "No entry found for " << target);
|
||||
BOOST_REQUIRE(entry != nullptr);
|
||||
BOOST_CHECK_EQUAL(entry->getPrefix(), target);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
validateNoExactMatch(Fib& fib, const Name& target)
|
||||
{
|
||||
BOOST_TEST_INFO_SCOPE(target);
|
||||
const Entry* entry = fib.findExactMatch(target);
|
||||
BOOST_CHECK_MESSAGE(entry == nullptr,
|
||||
"Found unexpected entry for " << target);
|
||||
BOOST_CHECK(entry == nullptr);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ExactMatch)
|
||||
@@ -294,13 +295,12 @@ BOOST_AUTO_TEST_CASE(ExactMatchEmpty)
|
||||
validateNoExactMatch(fib, "/nothing/here");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
validateErase(Fib& fib, const Name& target)
|
||||
{
|
||||
BOOST_TEST_INFO_SCOPE(target);
|
||||
fib.erase(target);
|
||||
|
||||
const Entry* entry = fib.findExactMatch(target);
|
||||
BOOST_CHECK_MESSAGE(entry == nullptr, "Found \"removed\" entry for " << target);
|
||||
BOOST_CHECK(fib.findExactMatch(target) == nullptr);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Erase)
|
||||
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
* \param name dataset prefix without version and segment
|
||||
* \param contentArgs passed to Data::setContent
|
||||
*/
|
||||
template<typename ...ContentArgs>
|
||||
template<typename... ContentArgs>
|
||||
void
|
||||
sendDatasetReply(Name name, ContentArgs&&... contentArgs)
|
||||
{
|
||||
@@ -220,8 +220,8 @@ protected:
|
||||
[&interest] { \
|
||||
auto params = parseCommand(interest, (expectedPrefix)); \
|
||||
BOOST_REQUIRE_MESSAGE(params.has_value(), "Interest " << interest.getName() << \
|
||||
" does not match command prefix " << (expectedPrefix)); \
|
||||
" must match the prefix " << (expectedPrefix)); \
|
||||
return *params; \
|
||||
} ()
|
||||
}()
|
||||
|
||||
#endif // NFD_TESTS_TOOLS_MOCK_NFD_MGMT_FIXTURE_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -457,8 +457,9 @@ BOOST_AUTO_TEST_CASE(MultipleFaces)
|
||||
ndn::nfd::RibUnregisterCommand cmd;
|
||||
cmd.validateRequest(req);
|
||||
cmd.applyDefaultsToRequest(req);
|
||||
BOOST_TEST_INFO_SCOPE("FaceId=" << req.getFaceId());
|
||||
BOOST_CHECK_EQUAL(req.getName(), "/nm5y8X8b2");
|
||||
BOOST_CHECK_MESSAGE(faceIds.erase(req.getFaceId()), "expected face " + to_string(req.getFaceId()));
|
||||
BOOST_CHECK(faceIds.erase(req.getFaceId()));
|
||||
BOOST_CHECK_EQUAL(req.getOrigin(), ndn::nfd::ROUTE_ORIGIN_STATIC);
|
||||
|
||||
this->succeedCommand(interest, req);
|
||||
|
||||
Reference in new issue
Block a user