tests: sync common testing infrastructure with ndn-cxx
Change-Id: I1e5cdcda8f6d3d9f9addc7a9f17359aedef9db7e
diff --git a/tests/route/test-fib.cpp b/tests/route/test-fib.cpp
index 5c75314..9da37de 100644
--- a/tests/route/test-fib.cpp
+++ b/tests/route/test-fib.cpp
@@ -22,21 +22,20 @@
#include "adjacency-list.hpp"
#include "conf-parameter.hpp"
-#include "../test-common.hpp"
-#include "../control-commands.hpp"
+#include "tests/boost-test.hpp"
+#include "tests/io-key-chain-fixture.hpp"
+#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace nlsr {
namespace test {
-class FibFixture : public UnitTestTimeFixture
+class FibFixture : public IoKeyChainFixture
{
public:
FibFixture()
- : face(m_ioService, m_keyChain)
- , conf(face, m_keyChain)
- , adjacencies(conf.getAdjacencyList())
+ : adjacencies(conf.getAdjacencyList())
, fib(face, m_scheduler, adjacencies, conf, m_keyChain)
, interests(face.sentInterests)
{
@@ -58,7 +57,8 @@
}
void
- enableRegistrationReplyWithFaceId() {
+ enableRegistrationReplyWithFaceId()
+ {
face.onSendInterest.connect([this] (const ndn::Interest& interest) {
static const ndn::Name localhostRegistration("/localhost/nfd/rib");
if (!localhostRegistration.isPrefixOf(interest.getName()))
@@ -86,10 +86,25 @@
});
}
-public:
- ndn::util::DummyClientFace face;
+ static void
+ extractRibCommandParameters(const ndn::Interest& interest, ndn::Name::Component& verb,
+ ndn::nfd::ControlParameters& extractedParameters)
+ {
+ static const ndn::Name commandPrefix("/localhost/nfd/rib");
- ConfParameter conf;
+ const auto& name = interest.getName();
+ verb = name.at(commandPrefix.size());
+ const auto& paramComponent = name.at(commandPrefix.size() + 1);
+ extractedParameters.wireDecode(paramComponent.blockFromValue());
+ }
+
+private:
+ ndn::Scheduler m_scheduler{m_io};
+
+public:
+ ndn::util::DummyClientFace face{m_io, m_keyChain};
+
+ ConfParameter conf{face, m_keyChain};
AdjacencyList& adjacencies;
Fib fib;
std::vector<ndn::Interest>& interests;
@@ -402,7 +417,7 @@
int numRegister = 0;
// Do not expect any unregisters, just registers which will update the cost in NFD
for (const auto& i : face.sentInterests) {
- if (i.getName().getPrefix(4) == "/localhost/nfd/rib/unregister/") {
+ if (i.getName().getPrefix(4) == "/localhost/nfd/rib/unregister") {
BOOST_CHECK(false);
}
else {
diff --git a/tests/route/test-hyperbolic-calculator.cpp b/tests/route/test-hyperbolic-calculator.cpp
index 30f8ced..f830c94 100644
--- a/tests/route/test-hyperbolic-calculator.cpp
+++ b/tests/route/test-hyperbolic-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,8 +19,6 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "../test-common.hpp"
-
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
@@ -29,7 +27,8 @@
#include "route/map.hpp"
#include "route/routing-table.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include "tests/io-key-chain-fixture.hpp"
+#include "tests/test-common.hpp"
namespace nlsr {
namespace test {
@@ -38,11 +37,11 @@
using ndn::time::system_clock;
static const system_clock::TimePoint MAX_TIME = system_clock::TimePoint::max();
-class HyperbolicCalculatorFixture : public BaseFixture
+class HyperbolicCalculatorFixture : public IoKeyChainFixture
{
public:
HyperbolicCalculatorFixture()
- : face(m_ioService, m_keyChain)
+ : face(m_io, m_keyChain)
, conf(face, m_keyChain)
, nlsr(face, m_keyChain, conf)
, routingTable(nlsr.m_routingTable)
diff --git a/tests/route/test-link-state-calculator.cpp b/tests/route/test-link-state-calculator.cpp
index 057b1c8..46c27fe 100644
--- a/tests/route/test-link-state-calculator.cpp
+++ b/tests/route/test-link-state-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,14 +22,14 @@
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
+#include "adjacent.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
-#include "../test-common.hpp"
#include "route/map.hpp"
#include "route/routing-table.hpp"
-#include "adjacent.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include "tests/io-key-chain-fixture.hpp"
+#include "tests/test-common.hpp"
namespace nlsr {
namespace test {
@@ -37,11 +37,11 @@
static const ndn::time::system_clock::TimePoint MAX_TIME =
ndn::time::system_clock::TimePoint::max();
-class LinkStateCalculatorFixture : public BaseFixture
+class LinkStateCalculatorFixture : public IoKeyChainFixture
{
public:
LinkStateCalculatorFixture()
- : face(m_ioService, m_keyChain)
+ : face(m_io, m_keyChain)
, conf(face, m_keyChain)
, confProcessor(conf)
, nlsr(face, m_keyChain, conf)
diff --git a/tests/route/test-name-prefix-table.cpp b/tests/route/test-name-prefix-table.cpp
index fbe6c5a..9c9833f 100644
--- a/tests/route/test-name-prefix-table.cpp
+++ b/tests/route/test-name-prefix-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, The University of Memphis,
+ * Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -23,21 +23,18 @@
#include "route/fib.hpp"
#include "route/routing-table.hpp"
#include "lsdb.hpp"
-#include "../test-common.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include "tests/io-key-chain-fixture.hpp"
+#include "tests/test-common.hpp"
namespace nlsr {
namespace test {
-class NamePrefixTableFixture : public UnitTestTimeFixture
+class NamePrefixTableFixture : public IoKeyChainFixture
{
public:
NamePrefixTableFixture()
- : face(m_ioService, m_keyChain)
- , conf(face, m_keyChain)
- , confProcessor(conf)
- , lsdb(face, m_keyChain, conf)
+ : lsdb(face, m_keyChain, conf)
, fib(face, m_scheduler, conf.getAdjacencyList(), conf, m_keyChain)
, rt(m_scheduler, lsdb, conf)
, npt(conf.getRouterPrefix(), fib, rt, rt.afterRoutingChange, lsdb.onLsdbModified)
@@ -52,10 +49,13 @@
return it != npt.end();
}
+private:
+ ndn::Scheduler m_scheduler{m_io};
+
public:
- ndn::util::DummyClientFace face;
- ConfParameter conf;
- DummyConfFileProcessor confProcessor;
+ ndn::util::DummyClientFace face{m_io, m_keyChain};
+ ConfParameter conf{face, m_keyChain};
+ DummyConfFileProcessor confProcessor{conf};
Lsdb lsdb;
Fib fib;
diff --git a/tests/route/test-routing-table.cpp b/tests/route/test-routing-table.cpp
index 5624ad8..15ad958 100644
--- a/tests/route/test-routing-table.cpp
+++ b/tests/route/test-routing-table.cpp
@@ -23,30 +23,24 @@
#include "route/routing-table-entry.hpp"
#include "route/nexthop.hpp"
+#include "tests/io-key-chain-fixture.hpp"
#include "tests/test-common.hpp"
namespace nlsr {
namespace test {
-class RoutingTableFixture : public UnitTestTimeFixture
+class RoutingTableFixture : public IoKeyChainFixture
{
-public:
- RoutingTableFixture()
- : face(m_ioService, m_keyChain, {true, true})
- , conf(face, m_keyChain)
- , confProcessor(conf)
- , lsdb(face, m_keyChain, conf)
- , rt(m_scheduler, lsdb, conf)
- {
- }
+private:
+ ndn::Scheduler m_scheduler{m_io};
public:
- ndn::util::DummyClientFace face;
- ConfParameter conf;
- DummyConfFileProcessor confProcessor;
+ ndn::util::DummyClientFace face{m_io, m_keyChain, {true, true}};
+ ConfParameter conf{face, m_keyChain};
+ DummyConfFileProcessor confProcessor{conf};
- Lsdb lsdb;
- RoutingTable rt;
+ Lsdb lsdb{face, m_keyChain, conf};
+ RoutingTable rt{m_scheduler, lsdb, conf};
};
BOOST_AUTO_TEST_SUITE(TestRoutingTable)