From d7083a507fe0730fd083fd66c18cdfe9c9281341 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Thu, 19 Oct 2023 17:51:16 -0400 Subject: [PATCH] tests: refactor EthernetFixture Also, use BOOST_TEST_INFO_SCOPE in a few places. Change-Id: I113f326207825949ed9d3d22ade0654976d49b76 --- tests/daemon/face/ethernet-factory.t.cpp | 18 ++- tests/daemon/face/ethernet-fixture.hpp | 86 ++----------- .../face/ethernet-transport-fixture.hpp | 115 ++++++++++++++++++ .../face/multicast-ethernet-transport.t.cpp | 6 +- tests/daemon/face/transport-test-common.hpp | 28 +++-- tests/daemon/face/transport.t.cpp | 15 ++- tests/daemon/face/udp-factory.t.cpp | 12 +- .../face/unicast-ethernet-transport.t.cpp | 4 +- tests/daemon/fw/asf-strategy.t.cpp | 21 ++-- tests/daemon/fw/strategy-instantiation.t.cpp | 21 ++-- tests/daemon/mgmt/face-manager.t.cpp | 9 +- tests/daemon/mgmt/fib-manager.t.cpp | 1 + .../daemon/mgmt/rib-manager-sl-announce.t.cpp | 4 +- tests/daemon/mgmt/rib-manager.t.cpp | 1 + .../daemon/mgmt/strategy-choice-manager.t.cpp | 7 +- tests/daemon/table/fib.t.cpp | 18 +-- tests/tools/mock-nfd-mgmt-fixture.hpp | 6 +- tests/tools/nfdc/rib-module.t.cpp | 5 +- 18 files changed, 214 insertions(+), 163 deletions(-) create mode 100644 tests/daemon/face/ethernet-transport-fixture.hpp diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp index b6d2516b..0ee45628 100644 --- a/tests/daemon/face/ethernet-factory.t.cpp +++ b/tests/daemon/face/ethernet-factory.t.cpp @@ -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 @@ class EthernetFactoryFixture : public EthernetFixture { std::set 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 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); diff --git a/tests/daemon/face/ethernet-fixture.hpp b/tests/daemon/face/ethernet-fixture.hpp index dfd5615e..45ce00df 100644 --- a/tests/daemon/face/ethernet-fixture.hpp +++ b/tests/daemon/face/ethernet-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, @@ -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 @@ class EthernetFixture : public virtual GlobalIoFixture 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(netifs.front()); - } - } - - /** \brief Returns the first running interface. - */ - shared_ptr - getRunningNetif() const - { - for (const auto& netif : netifs) { - if (netif->getState() == ndn::net::InterfaceState::RUNNING) { - return const_pointer_cast(netif); - } - } - - return nullptr; - } - - /** \brief Create a UnicastEthernetTransport. - */ - void - initializeUnicast(shared_ptr 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(*netif, remoteEp, persistency, 2_s); - } - - /** \brief Create a MulticastEthernetTransport. - */ - void - initializeMulticast(shared_ptr 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(*netif, remoteEp, linkType); } protected: - LimitedIo limitedIo; - - /** \brief EthernetTransport-capable network interfaces. + /** + * \brief EthernetTransport-capable network interfaces. */ std::vector> netifs; - - shared_ptr defaultNetif; - unique_ptr transport; - std::string localEp; - ethernet::Address remoteEp; }; } // namespace nfd::tests @@ -133,13 +74,4 @@ class EthernetFixture : public virtual GlobalIoFixture } \ } 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 diff --git a/tests/daemon/face/ethernet-transport-fixture.hpp b/tests/daemon/face/ethernet-transport-fixture.hpp new file mode 100644 index 00000000..ab737956 --- /dev/null +++ b/tests/daemon/face/ethernet-transport-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 . + */ + +#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(netifs.front()); + } + } + + /** + * \brief Returns the first running interface. + */ + shared_ptr + getRunningNetif() const + { + for (const auto& netif : netifs) { + if (netif->getState() == ndn::net::InterfaceState::RUNNING) { + return const_pointer_cast(netif); + } + } + + return nullptr; + } + + /** + * \brief Create a UnicastEthernetTransport. + */ + void + initializeUnicast(shared_ptr 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(*netif, remoteEp, persistency, 2_s); + } + + /** + * \brief Create a MulticastEthernetTransport. + */ + void + initializeMulticast(shared_ptr 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(*netif, remoteEp, linkType); + } + +protected: + LimitedIo limitedIo; + shared_ptr defaultNetif; + unique_ptr 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 diff --git a/tests/daemon/face/multicast-ethernet-transport.t.cpp b/tests/daemon/face/multicast-ethernet-transport.t.cpp index 2791ca79..2694e000 100644 --- a/tests/daemon/face/multicast-ethernet-transport.t.cpp +++ b/tests/daemon/face/multicast-ethernet-transport.t.cpp @@ -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 . */ -#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) { diff --git a/tests/daemon/face/transport-test-common.hpp b/tests/daemon/face/transport-test-common.hpp index c257a04b..4a90c777 100644 --- a/tests/daemon/face/transport-test-common.hpp +++ b/tests/daemon/face/transport-test-common.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, @@ -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(T::first::value); auto to = static_cast(T::second::value); - BOOST_TEST_MESSAGE("SetState " << from << " -> " << to); + BOOST_TEST_INFO_SCOPE(from << " -> " << to); // enter from state using Steps = typename mpl::at>::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 || diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp index 106ba0b1..fd836566 100644 --- a/tests/daemon/face/udp-factory.t.cpp +++ b/tests/daemon/face/udp-factory.t.cpp @@ -69,7 +69,7 @@ class UdpFactoryMcastFixture : public UdpFactoryFixture } } } - this->copyRealNetifsToNetmon(); + copyRealNetifsToNetmon(); } shared_ptr @@ -106,16 +106,17 @@ class UdpFactoryMcastFixture : public UdpFactoryFixture std::vector listUdp4McastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const { - return this->listFacesByScheme("udp4", linkType); + return listFacesByScheme("udp4", linkType); } std::vector 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 @@ class UdpFactoryMcastFixture : public UdpFactoryFixture [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) diff --git a/tests/daemon/face/unicast-ethernet-transport.t.cpp b/tests/daemon/face/unicast-ethernet-transport.t.cpp index 373bcc38..83e4b54f 100644 --- a/tests/daemon/face/unicast-ethernet-transport.t.cpp +++ b/tests/daemon/face/unicast-ethernet-transport.t.cpp @@ -23,7 +23,7 @@ * NFD, e.g., in COPYING.md file. If not, see . */ -#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) { diff --git a/tests/daemon/fw/asf-strategy.t.cpp b/tests/daemon/fw/asf-strategy.t.cpp index a853c79a..ff8ed50d 100644 --- a/tests/daemon/fw/asf-strategy.t.cpp +++ b/tests/daemon/fw/asf-strategy.t.cpp @@ -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 strategy; - BOOST_TEST_CONTEXT(parameters) { - if (isCorrect) { - strategy = make_unique(forwarder, strategyName); - BOOST_CHECK(strategy->m_retxSuppression != nullptr); - } - else { - BOOST_CHECK_THROW(make_unique(forwarder, strategyName), std::invalid_argument); - } + if (isCorrect) { + strategy = make_unique(forwarder, strategyName); + BOOST_CHECK(strategy->m_retxSuppression != nullptr); + } + else { + BOOST_CHECK_THROW(make_unique(forwarder, strategyName), std::invalid_argument); } return strategy; }; diff --git a/tests/daemon/fw/strategy-instantiation.t.cpp b/tests/daemon/fw/strategy-instantiation.t.cpp index 12c13a17..0ac730cc 100644 --- a/tests/daemon/fw/strategy-instantiation.t.cpp +++ b/tests/daemon/fw/strategy-instantiation.t.cpp @@ -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 - 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 strategy; - BOOST_TEST_CONTEXT(parameters) { - if (isCorrect) { - strategy = make_unique(m_forwarder, strategyName); - BOOST_CHECK(strategy->m_retxSuppression != nullptr); - } - else { - BOOST_CHECK_THROW(make_unique(m_forwarder, strategyName), std::invalid_argument); - } + if (isCorrect) { + strategy = make_unique(m_forwarder, strategyName); + BOOST_CHECK(strategy->m_retxSuppression != nullptr); + } + else { + BOOST_CHECK_THROW(make_unique(m_forwarder, strategyName), std::invalid_argument); } return strategy; } diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp index 140b1c62..d73dc242 100644 --- a/tests/daemon/mgmt/face-manager.t.cpp +++ b/tests/daemon/mgmt/face-manager.t.cpp @@ -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 @@ class FaceManagerFixture : public ManagerFixtureWithAuthenticator 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 addFace(unsigned int flags = 0) @@ -169,6 +170,7 @@ BOOST_AUTO_TEST_CASE(FaceDataset) std::set 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()); } } diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp index 32bbec3d..5da697be 100644 --- a/tests/daemon/mgmt/fib-manager.t.cpp +++ b/tests/daemon/mgmt/fib-manager.t.cpp @@ -421,6 +421,7 @@ BOOST_AUTO_TEST_CASE(FibDataset) std::vector 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()); diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp index 6c82d4a9..83a0af22 100644 --- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp +++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp @@ -71,14 +71,14 @@ class RibManagerSlAnnounceFixture : public GlobalIoTimeFixture, public KeyChainF loadDefaultPaConfig(); } - template + template ndn::PrefixAnnouncement makeTrustedAnn(T&&... args) { return signPrefixAnn(makePrefixAnn(std::forward(args)...), m_keyChain, m_trustedSigner); } - template + template ndn::PrefixAnnouncement makeUntrustedAnn(T&&... args) { diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp index 0b407f6d..417500e1 100644 --- a/tests/daemon/mgmt/rib-manager.t.cpp +++ b/tests/daemon/mgmt/rib-manager.t.cpp @@ -486,6 +486,7 @@ BOOST_FIXTURE_TEST_CASE(RibDataset, UnauthorizedRibManagerFixture) std::vector 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()); diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp index 71763bb0..4a6e3dfc 100644 --- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp +++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp @@ -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); } } diff --git a/tests/daemon/table/fib.t.cpp b/tests/daemon/table/fib.t.cpp index 65b12805..073d88c3 100644 --- a/tests/daemon/table/fib.t.cpp +++ b/tests/daemon/table/fib.t.cpp @@ -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) diff --git a/tests/tools/mock-nfd-mgmt-fixture.hpp b/tests/tools/mock-nfd-mgmt-fixture.hpp index eed9846e..f5feb865 100644 --- a/tests/tools/mock-nfd-mgmt-fixture.hpp +++ b/tests/tools/mock-nfd-mgmt-fixture.hpp @@ -173,7 +173,7 @@ class MockNfdMgmtFixture : public IoFixture, public KeyChainFixture * \param name dataset prefix without version and segment * \param contentArgs passed to Data::setContent */ - template + template void sendDatasetReply(Name name, ContentArgs&&... contentArgs) { @@ -220,8 +220,8 @@ class MockNfdMgmtFixture : public IoFixture, public KeyChainFixture [&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 diff --git a/tests/tools/nfdc/rib-module.t.cpp b/tests/tools/nfdc/rib-module.t.cpp index b50625db..f349dfd6 100644 --- a/tests/tools/nfdc/rib-module.t.cpp +++ b/tests/tools/nfdc/rib-module.t.cpp @@ -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);