fw: pull FaceTable construction out of Forwarder class
Refs: #4922, #4973
Change-Id: Ibbd4a8840cb0d01ebbd4cabf9c34fa78a1d23db1
diff --git a/tests/daemon/fw/asf-strategy.t.cpp b/tests/daemon/fw/asf-strategy.t.cpp
index 77cb4b6..09013ee 100644
--- a/tests/daemon/fw/asf-strategy.t.cpp
+++ b/tests/daemon/fw/asf-strategy.t.cpp
@@ -469,7 +469,8 @@
}
protected:
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
};
BOOST_FIXTURE_TEST_CASE(InstantiationTest, ParametersFixture)
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 3ab261e..fa9d883 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -43,27 +43,25 @@
{
protected:
BestRouteStrategy2Fixture()
- : strategy(forwarder)
- , fib(forwarder.getFib())
- , pit(forwarder.getPit())
- , face1(make_shared<DummyFace>())
+ : face1(make_shared<DummyFace>())
, face2(make_shared<DummyFace>())
, face3(make_shared<DummyFace>())
, face4(make_shared<DummyFace>())
, face5(make_shared<DummyFace>())
{
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
- forwarder.addFace(face5);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
+ faceTable.add(face4);
+ faceTable.add(face5);
}
-public:
- Forwarder forwarder;
- BestRouteStrategy2Tester strategy;
- Fib& fib;
- Pit& pit;
+protected:
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ BestRouteStrategy2Tester strategy{forwarder};
+ Fib& fib{forwarder.getFib()};
+ Pit& pit{forwarder.getPit()};
shared_ptr<DummyFace> face1;
shared_ptr<DummyFace> face2;
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index c2e646e..af362e1 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -37,17 +37,30 @@
namespace nfd {
namespace tests {
+class ForwarderFixture : public GlobalIoTimeFixture
+{
+protected:
+ template<typename ...Args>
+ shared_ptr<DummyFace>
+ addFace(Args&&... args)
+ {
+ auto face = make_shared<DummyFace>(std::forward<Args>(args)...);
+ faceTable.add(face);
+ return face;
+ }
+
+protected:
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+};
+
BOOST_AUTO_TEST_SUITE(Fw)
-BOOST_FIXTURE_TEST_SUITE(TestForwarder, GlobalIoTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestForwarder, ForwarderFixture)
BOOST_AUTO_TEST_CASE(SimpleExchange)
{
- Forwarder forwarder;
-
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = addFace();
+ auto face2 = addFace();
Fib& fib = forwarder.getFib();
fib::Entry* entry = fib.insert("/A").first;
@@ -82,14 +95,9 @@
BOOST_AUTO_TEST_CASE(CsMatched)
{
- Forwarder forwarder;
-
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace();
Fib& fib = forwarder.getFib();
fib::Entry* entry = fib.insert("/A").first;
@@ -124,11 +132,8 @@
BOOST_AUTO_TEST_CASE(OutgoingInterest)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = addFace();
+ auto face2 = addFace();
Pit& pit = forwarder.getPit();
auto interestA1 = makeInterest("/A", false, nullopt, 8378);
@@ -148,14 +153,9 @@
BOOST_AUTO_TEST_CASE(NextHopFaceId)
{
- Forwarder forwarder;
-
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace();
Fib& fib = forwarder.getFib();
fib::Entry* entry = fib.insert("/A").first;
@@ -174,6 +174,8 @@
class ScopeLocalhostIncomingTestForwarder : public Forwarder
{
public:
+ using Forwarder::Forwarder;
+
void
onDataUnsolicited(const FaceEndpoint&, const Data&) final
{
@@ -192,13 +194,15 @@
int onDataUnsolicited_count = 0;
};
-BOOST_AUTO_TEST_CASE(ScopeLocalhostIncoming)
+BOOST_FIXTURE_TEST_CASE(ScopeLocalhostIncoming, GlobalIoTimeFixture)
{
- ScopeLocalhostIncomingTestForwarder forwarder;
+ FaceTable faceTable;
+ ScopeLocalhostIncomingTestForwarder forwarder(faceTable);
+
auto face1 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
// local face, /localhost: OK
forwarder.dispatchToStrategy_count = 0;
@@ -251,11 +255,8 @@
BOOST_AUTO_TEST_CASE(IncomingInterestStrategyDispatch)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = addFace();
+ auto face2 = addFace();
DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "/", DummyStrategy::getStrategyName());
DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "/B", DummyStrategy::getStrategyName());
@@ -292,15 +293,10 @@
BOOST_AUTO_TEST_CASE(IncomingData)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>();
- auto face4 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace();
+ auto face4 = addFace();
Pit& pit = forwarder.getPit();
auto interestD = makeInterest("/A/B/C/D");
@@ -327,16 +323,12 @@
BOOST_AUTO_TEST_CASE(IncomingNack)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS);
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "/", DummyStrategy::getStrategyName());
DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "/B", DummyStrategy::getStrategyName());
@@ -410,16 +402,12 @@
BOOST_AUTO_TEST_CASE(OutgoingNack)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS);
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
Pit& pit = forwarder.getPit();
@@ -474,18 +462,13 @@
BOOST_AUTO_TEST_CASE(InterestLoopNack)
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS);
- auto face4 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
+ auto face1 = addFace();
+ auto face2 = addFace();
+ auto face3 = addFace("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
+ auto face4 = addFace();
Fib& fib = forwarder.getFib();
fib::Entry* entry = fib.insert("/zT4XwK0Hnx").first;
@@ -526,11 +509,8 @@
BOOST_AUTO_TEST_CASE(InterestLoopWithShortLifetime) // Bug 1953
{
- Forwarder forwarder;
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = addFace();
+ auto face2 = addFace();
// cause an Interest sent out of face2 to loop back into face1 after a delay
face2->afterSend.connect([face1, face2] (uint32_t pktType) {
@@ -563,9 +543,7 @@
BOOST_AUTO_TEST_CASE(PitLeak) // Bug 3484
{
- Forwarder forwarder;
- shared_ptr<Face> face1 = make_shared<DummyFace>();
- forwarder.addFace(face1);
+ auto face1 = addFace();
auto interest = makeInterest("/hcLSAsQ9A", false, 2_s, 61883075);
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index 7db3abd..526d7b0 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -41,23 +41,22 @@
{
protected:
MulticastStrategyFixture()
- : strategy(forwarder)
- , fib(forwarder.getFib())
- , pit(forwarder.getPit())
- , face1(make_shared<DummyFace>())
+ : face1(make_shared<DummyFace>())
, face2(make_shared<DummyFace>())
, face3(make_shared<DummyFace>())
{
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
}
protected:
- Forwarder forwarder;
- MulticastStrategyTester strategy;
- Fib& fib;
- Pit& pit;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ MulticastStrategyTester strategy{forwarder};
+ Fib& fib{forwarder.getFib()};
+ Pit& pit{forwarder.getPit()};
+
shared_ptr<DummyFace> face1;
shared_ptr<DummyFace> face2;
shared_ptr<DummyFace> face3;
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index 7b03f4f..3c3f4d4 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -46,16 +46,17 @@
// and favors this upstream in subsequent Interests.
LimitedIo limitedIo(this);
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NccStrategyTester& strategy = choose<NccStrategyTester>(forwarder);
strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
@@ -106,15 +107,16 @@
BOOST_AUTO_TEST_CASE(Bug1853)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NccStrategyTester& strategy = choose<NccStrategyTester>(forwarder);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
@@ -156,16 +158,17 @@
BOOST_AUTO_TEST_CASE(Bug1961)
{
LimitedIo limitedIo(this);
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NccStrategyTester& strategy = choose<NccStrategyTester>(forwarder);
strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
@@ -211,14 +214,15 @@
BOOST_AUTO_TEST_CASE(Bug1971)
{
LimitedIo limitedIo(this);
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NccStrategyTester& strategy = choose<NccStrategyTester>(forwarder);
strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
@@ -255,13 +259,14 @@
BOOST_AUTO_TEST_CASE(Bug1998)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NccStrategyTester& strategy = choose<NccStrategyTester>(forwarder);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
diff --git a/tests/daemon/fw/pit-expiry.t.cpp b/tests/daemon/fw/pit-expiry.t.cpp
index d69448c..16956fc 100644
--- a/tests/daemon/fw/pit-expiry.t.cpp
+++ b/tests/daemon/fw/pit-expiry.t.cpp
@@ -121,12 +121,13 @@
BOOST_AUTO_TEST_CASE(UnsatisfiedInterest)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Pit& pit = forwarder.getPit();
@@ -145,12 +146,13 @@
BOOST_AUTO_TEST_CASE(SatisfiedInterest)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Pit& pit = forwarder.getPit();
@@ -169,12 +171,13 @@
BOOST_AUTO_TEST_CASE(CsHit)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Name strategyA("/strategyA/%FD%01");
PitExpiryTestStrategy::registerAs(strategyA);
@@ -206,14 +209,15 @@
BOOST_AUTO_TEST_CASE(ReceiveNack)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
auto face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Name strategyA("/strategyA/%FD%01");
PitExpiryTestStrategy::registerAs(strategyA);
@@ -241,10 +245,11 @@
BOOST_AUTO_TEST_CASE(ResetTimerAfterReceiveInterest)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face = make_shared<DummyFace>();
- forwarder.addFace(face);
+ faceTable.add(face);
Name strategyA("/strategyA/%FD%01");
PitExpiryTestStrategy::registerAs(strategyA);
@@ -266,14 +271,15 @@
BOOST_AUTO_TEST_CASE(ResetTimerBeforeSatisfyInterest)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
auto face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Name strategyA("/strategyA/%FD%01");
Name strategyB("/strategyB/%FD%01");
@@ -322,12 +328,13 @@
BOOST_AUTO_TEST_CASE(ResetTimerAfterReceiveData)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
Name strategyA("/strategyA/%FD%01");
PitExpiryTestStrategy::registerAs(strategyA);
@@ -368,14 +375,15 @@
BOOST_AUTO_TEST_CASE(ReceiveNackAfterResetTimer)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
auto face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
Name strategyA("/strategyA/%FD%01");
PitExpiryTestStrategy::registerAs(strategyA);
diff --git a/tests/daemon/fw/random-strategy.t.cpp b/tests/daemon/fw/random-strategy.t.cpp
index 84347f5..4822e4c 100644
--- a/tests/daemon/fw/random-strategy.t.cpp
+++ b/tests/daemon/fw/random-strategy.t.cpp
@@ -43,25 +43,23 @@
{
protected:
RandomStrategyFixture()
- : strategy(forwarder)
- , fib(forwarder.getFib())
- , pit(forwarder.getPit())
- , face1(make_shared<DummyFace>())
+ : face1(make_shared<DummyFace>())
, face2(make_shared<DummyFace>())
, face3(make_shared<DummyFace>())
, face4(make_shared<DummyFace>())
{
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
+ faceTable.add(face4);
}
-public:
- Forwarder forwarder;
- RandomStrategyTester strategy;
- Fib& fib;
- Pit& pit;
+protected:
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ RandomStrategyTester strategy{forwarder};
+ Fib& fib{forwarder.getFib()};
+ Pit& pit{forwarder.getPit()};
shared_ptr<DummyFace> face1;
shared_ptr<DummyFace> face2;
diff --git a/tests/daemon/fw/retx-suppression.t.cpp b/tests/daemon/fw/retx-suppression.t.cpp
index 07831ae..3522ace 100644
--- a/tests/daemon/fw/retx-suppression.t.cpp
+++ b/tests/daemon/fw/retx-suppression.t.cpp
@@ -42,7 +42,8 @@
BOOST_AUTO_TEST_CASE(Fixed)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
Pit& pit = forwarder.getPit();
static const time::milliseconds MIN_RETX_INTERVAL(200);
RetxSuppressionFixed rs(MIN_RETX_INTERVAL);
@@ -50,9 +51,9 @@
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
shared_ptr<Interest> interest = makeInterest("ndn:/0JiimvmxK8");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
@@ -91,14 +92,15 @@
BOOST_AUTO_TEST_CASE(Exponential)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
Pit& pit = forwarder.getPit();
RetxSuppressionExponential rs(10_ms, 3.0, 100_ms);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
shared_ptr<Interest> interest = makeInterest("ndn:/smuVeQSW6q");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
@@ -159,14 +161,15 @@
BOOST_AUTO_TEST_CASE(ExponentialPerUpstream)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
Pit& pit = forwarder.getPit();
RetxSuppressionExponential rs(10_ms, 3.0, 100_ms);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
shared_ptr<Interest> interest = makeInterest("ndn:/covfefeW6q");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
diff --git a/tests/daemon/fw/strategy-instantiation.t.cpp b/tests/daemon/fw/strategy-instantiation.t.cpp
index 705b3aa..312294c 100644
--- a/tests/daemon/fw/strategy-instantiation.t.cpp
+++ b/tests/daemon/fw/strategy-instantiation.t.cpp
@@ -96,7 +96,8 @@
uint64_t maxVersion = T::Strategy::getStrategyName().at(-1).toVersion();
BOOST_REQUIRE_LE(T::getMinVersion(), maxVersion);
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
for (uint64_t version = T::getMinVersion(); version <= maxVersion; ++version) {
Name versionedName = T::getVersionedStrategyName(version);
unique_ptr<typename T::Strategy> instance;
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index bfddf0c..870253b 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -51,6 +51,7 @@
public:
StrategyNackReturnFixture()
: limitedIo(this)
+ , forwarder(faceTable)
, strategy(choose<StrategyTester<S>>(forwarder))
, fib(forwarder.getFib())
, pit(forwarder.getPit())
@@ -60,16 +61,17 @@
, face4(make_shared<DummyFace>())
, face5(make_shared<DummyFace>())
{
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
- forwarder.addFace(face5);
+ faceTable.add(face1);
+ faceTable.add(face2);
+ faceTable.add(face3);
+ faceTable.add(face4);
+ faceTable.add(face5);
}
public:
LimitedIo limitedIo;
+ FaceTable faceTable;
Forwarder forwarder;
StrategyTester<S>& strategy;
Fib& fib;
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
index 4ebd5cf..26b7874 100644
--- a/tests/daemon/fw/strategy-no-route.t.cpp
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -53,19 +53,21 @@
public:
StrategyNoRouteFixture()
: limitedIo(this)
+ , forwarder(faceTable)
, strategy(choose<StrategyTester<S>>(forwarder))
, fib(forwarder.getFib())
, pit(forwarder.getPit())
, face1(make_shared<DummyFace>())
, face2(make_shared<DummyFace>())
{
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
}
public:
LimitedIo limitedIo;
+ FaceTable faceTable;
Forwarder forwarder;
StrategyTester<S>& strategy;
Fib& fib;
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 643e0ee..268ae67 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -54,6 +54,7 @@
public:
StrategyScopeControlFixture()
: limitedIo(this)
+ , forwarder(faceTable)
, strategy(choose<StrategyTester<S>>(forwarder))
, fib(forwarder.getFib())
, pit(forwarder.getPit())
@@ -62,15 +63,16 @@
, localFace3(make_shared<DummyFace>("dummy://3", "dummy://3", ndn::nfd::FACE_SCOPE_LOCAL))
, localFace4(make_shared<DummyFace>("dummy://4", "dummy://4", ndn::nfd::FACE_SCOPE_LOCAL))
{
- forwarder.addFace(nonLocalFace1);
- forwarder.addFace(nonLocalFace2);
- forwarder.addFace(localFace3);
- forwarder.addFace(localFace4);
+ faceTable.add(nonLocalFace1);
+ faceTable.add(nonLocalFace2);
+ faceTable.add(localFace3);
+ faceTable.add(localFace4);
}
public:
LimitedIo limitedIo;
+ FaceTable faceTable;
Forwarder forwarder;
StrategyTester<S>& strategy;
Fib& fib;
diff --git a/tests/daemon/fw/strategy.t.cpp b/tests/daemon/fw/strategy.t.cpp
index 41b0f8d..8b27986 100644
--- a/tests/daemon/fw/strategy.t.cpp
+++ b/tests/daemon/fw/strategy.t.cpp
@@ -83,13 +83,14 @@
BOOST_AUTO_TEST_CASE(FaceTableAccess)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
FaceTableAccessTestStrategy strategy(forwarder);
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ faceTable.add(face1);
+ faceTable.add(face2);
FaceId id1 = face1->getId();
FaceId id2 = face2->getId();
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 6a70ead..92495d4 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -197,9 +197,7 @@
TopologyTester::addForwarder(const std::string& label)
{
size_t i = m_forwarders.size();
- m_forwarders.push_back(make_unique<Forwarder>());
- m_forwarderLabels.push_back(label);
- BOOST_ASSERT(m_forwarders.size() == m_forwarderLabels.size());
+ m_forwarders.push_back(make_unique<TopologyForwarder>(label));
return i;
}
@@ -207,12 +205,11 @@
TopologyTester::makeFace(TopologyNode i, const FaceUri& localUri, const FaceUri& remoteUri,
ndn::nfd::FaceScope scope, ndn::nfd::LinkType linkType)
{
- Forwarder& forwarder = this->getForwarder(i);
unique_ptr<GenericLinkService> service = m_wantPcap ? make_unique<TopologyPcapLinkService>() :
make_unique<GenericLinkService>();
auto transport = make_unique<InternalForwarderTransport>(localUri, remoteUri, scope, linkType);
auto face = make_shared<Face>(std::move(service), std::move(transport));
- forwarder.addFace(face);
+ m_forwarders.at(i)->faceTable.add(face);
return face;
}
@@ -230,7 +227,7 @@
BOOST_ASSERT(forwarders.size() <= 2 || linkType != ndn::nfd::LINK_TYPE_POINT_TO_POINT);
for (TopologyNode i : forwarders) {
- FaceUri localUri("topology://" + m_forwarderLabels.at(i) + "/" + label);
+ FaceUri localUri("topology://" + m_forwarders.at(i)->label + "/" + label);
auto face = makeFace(i, localUri, remoteUri, ndn::nfd::FACE_SCOPE_NON_LOCAL, linkType);
link->addFace(i, std::move(face));
}
@@ -242,8 +239,8 @@
shared_ptr<TopologyAppLink>
TopologyTester::addAppFace(const std::string& label, TopologyNode i)
{
- FaceUri localUri("topology://" + m_forwarderLabels.at(i) + "/local/" + label);
- FaceUri remoteUri("topology://" + m_forwarderLabels.at(i) + "/app/" + label);
+ FaceUri localUri("topology://" + m_forwarders.at(i)->label + "/local/" + label);
+ FaceUri remoteUri("topology://" + m_forwarders.at(i)->label + "/app/" + label);
auto face = makeFace(i, localUri, remoteUri, ndn::nfd::FACE_SCOPE_LOCAL, ndn::nfd::LINK_TYPE_POINT_TO_POINT);
auto al = make_shared<TopologyAppLink>(std::move(face));
@@ -263,8 +260,8 @@
TopologyTester::addBareLink(const std::string& label, TopologyNode i, ndn::nfd::FaceScope scope,
ndn::nfd::LinkType linkType)
{
- FaceUri localUri("topology://" + m_forwarderLabels.at(i) + "/local/" + label);
- FaceUri remoteUri("topology://" + m_forwarderLabels.at(i) + "/bare/" + label);
+ FaceUri localUri("topology://" + m_forwarders.at(i)->label + "/local/" + label);
+ FaceUri remoteUri("topology://" + m_forwarders.at(i)->label + "/bare/" + label);
auto face = makeFace(i, localUri, remoteUri, scope, linkType);
auto bl = make_shared<TopologyBareLink>(std::move(face));
@@ -272,12 +269,6 @@
return bl;
}
-void
-TopologyTester::enablePcap(bool isEnabled)
-{
- m_wantPcap = isEnabled;
-}
-
TopologyPcap&
TopologyTester::getPcap(const Face& face)
{
diff --git a/tests/daemon/fw/topology-tester.hpp b/tests/daemon/fw/topology-tester.hpp
index 9243476..6e5cb95 100644
--- a/tests/daemon/fw/topology-tester.hpp
+++ b/tests/daemon/fw/topology-tester.hpp
@@ -260,7 +260,7 @@
Forwarder&
getForwarder(TopologyNode i)
{
- return *m_forwarders.at(i);
+ return m_forwarders.at(i)->forwarder;
}
/** \brief sets strategy on forwarder \p i
@@ -310,7 +310,10 @@
/** \brief enables packet capture on every forwarder face
*/
void
- enablePcap(bool isEnabled = true);
+ enablePcap(bool isEnabled = true)
+ {
+ m_wantPcap = isEnabled;
+ }
/** \return captured packets on a forwarder face
* \pre enablePcap(true) is in effect when the face was created
@@ -342,12 +345,26 @@
ndn::nfd::FaceScope scope, ndn::nfd::LinkType linkType);
private:
- bool m_wantPcap = false;
- std::vector<unique_ptr<Forwarder>> m_forwarders;
- std::vector<std::string> m_forwarderLabels;
+ class TopologyForwarder
+ {
+ public:
+ explicit
+ TopologyForwarder(const std::string& label)
+ : label(label)
+ {
+ }
+
+ public:
+ std::string label;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ };
+
+ std::vector<unique_ptr<TopologyForwarder>> m_forwarders;
std::vector<shared_ptr<TopologyLink>> m_links;
std::vector<shared_ptr<TopologyAppLink>> m_appLinks;
std::vector<shared_ptr<TopologyBareLink>> m_bareLinks;
+ bool m_wantPcap = false;
};
} // namespace tests
diff --git a/tests/daemon/fw/unsolicited-data-policy.t.cpp b/tests/daemon/fw/unsolicited-data-policy.t.cpp
index 11eafe1..21894ca 100644
--- a/tests/daemon/fw/unsolicited-data-policy.t.cpp
+++ b/tests/daemon/fw/unsolicited-data-policy.t.cpp
@@ -42,11 +42,6 @@
class UnsolicitedDataPolicyFixture : public GlobalIoTimeFixture
{
protected:
- UnsolicitedDataPolicyFixture()
- : cs(forwarder.getCs())
- {
- }
-
/** \tparam Policy policy type, or void to keep default policy
*/
template<typename Policy>
@@ -72,8 +67,9 @@
}
protected:
- Forwarder forwarder;
- Cs& cs;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ Cs& cs{forwarder.getCs()};
};
template<>
@@ -117,7 +113,7 @@
auto face1 = make_shared<DummyFace>("dummy://", "dummy://",
ndn::nfd::FACE_SCOPE_LOCAL);
- forwarder.addFace(face1);
+ faceTable.add(face1);
shared_ptr<Data> data1 = makeData("/unsolicited-from-local");
forwarder.onIncomingData(FaceEndpoint(*face1, 0), *data1);
@@ -125,7 +121,7 @@
auto face2 = make_shared<DummyFace>("dummy://", "dummy://",
ndn::nfd::FACE_SCOPE_NON_LOCAL);
- forwarder.addFace(face2);
+ faceTable.add(face2);
shared_ptr<Data> data2 = makeData("/unsolicited-from-non-local");
forwarder.onIncomingData(FaceEndpoint(*face2, 0), *data2);
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index 8a418e5..0930374 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -46,8 +46,7 @@
{
public:
FaceManagerFixture()
- : m_faceTable(m_forwarder.getFaceTable())
- , m_faceSystem(m_faceTable, make_shared<ndn::net::NetworkMonitorStub>(0))
+ : m_faceSystem(m_faceTable, make_shared<ndn::net::NetworkMonitorStub>(0))
, m_manager(m_faceSystem, m_dispatcher, *m_authenticator)
{
setTopPrefix();
@@ -113,7 +112,6 @@
}
protected:
- FaceTable& m_faceTable;
FaceSystem m_faceSystem;
FaceManager m_manager;
};
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 4907a61..048f76d 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -40,7 +40,6 @@
public:
FibManagerFixture()
: m_fib(m_forwarder.getFib())
- , m_faceTable(m_forwarder.getFaceTable())
, m_manager(m_fib, m_faceTable, m_dispatcher, *m_authenticator)
{
setTopPrefix();
@@ -126,7 +125,6 @@
protected:
Fib& m_fib;
- FaceTable& m_faceTable;
FibManager m_manager;
};
@@ -144,8 +142,7 @@
return os << "NO_NEXTHOP";
case FibManagerFixture::CheckNextHopResult::WRONG_COST:
return os << "WRONG_COST";
- };
-
+ }
return os << static_cast<int>(result);
}
diff --git a/tests/daemon/mgmt/forwarder-status-manager.t.cpp b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
index e40e20d..132375a 100644
--- a/tests/daemon/mgmt/forwarder-status-manager.t.cpp
+++ b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
@@ -35,13 +35,15 @@
{
protected:
ForwarderStatusManagerFixture()
- : m_manager(m_forwarder, m_dispatcher)
+ : m_forwarder(m_faceTable)
+ , m_manager(m_forwarder, m_dispatcher)
, m_startTime(time::system_clock::now())
{
setTopPrefix();
}
protected:
+ FaceTable m_faceTable;
Forwarder m_forwarder;
ForwarderStatusManager m_manager;
time::system_clock::TimePoint m_startTime;
diff --git a/tests/daemon/mgmt/manager-common-fixture.hpp b/tests/daemon/mgmt/manager-common-fixture.hpp
index b5bae0d..3557627 100644
--- a/tests/daemon/mgmt/manager-common-fixture.hpp
+++ b/tests/daemon/mgmt/manager-common-fixture.hpp
@@ -171,7 +171,8 @@
setPrivilege(const std::string& privilege);
protected:
- Forwarder m_forwarder;
+ FaceTable m_faceTable;
+ Forwarder m_forwarder{m_faceTable};
shared_ptr<CommandAuthenticator> m_authenticator = CommandAuthenticator::create();
};
diff --git a/tests/daemon/mgmt/tables-config-section.t.cpp b/tests/daemon/mgmt/tables-config-section.t.cpp
index cfcc3ba..dfce51e 100644
--- a/tests/daemon/mgmt/tables-config-section.t.cpp
+++ b/tests/daemon/mgmt/tables-config-section.t.cpp
@@ -40,7 +40,8 @@
{
protected:
TablesConfigSectionFixture()
- : cs(forwarder.getCs())
+ : forwarder(faceTable)
+ , cs(forwarder.getCs())
, strategyChoice(forwarder.getStrategyChoice())
, networkRegionTable(forwarder.getNetworkRegionTable())
, tablesConfig(forwarder)
@@ -62,6 +63,7 @@
}
protected:
+ FaceTable faceTable;
Forwarder forwarder;
Cs& cs;
StrategyChoice& strategyChoice;
diff --git a/tests/daemon/table/cleanup.t.cpp b/tests/daemon/table/cleanup.t.cpp
index ae83f78..b7395a3 100644
--- a/tests/daemon/table/cleanup.t.cpp
+++ b/tests/daemon/table/cleanup.t.cpp
@@ -74,14 +74,15 @@
BOOST_AUTO_TEST_CASE(RemoveFibNexthops)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
NameTree& nameTree = forwarder.getNameTree();
Fib& fib = forwarder.getFib();
- shared_ptr<Face> face1 = make_shared<DummyFace>();
- shared_ptr<Face> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ faceTable.add(face1);
+ faceTable.add(face2);
// {}
size_t nNameTreeEntriesBefore = nameTree.size();
@@ -130,13 +131,14 @@
BOOST_AUTO_TEST_CASE(DeletePitInOutRecords)
{
- Forwarder forwarder;
+ FaceTable faceTable;
+ Forwarder forwarder(faceTable);
Pit& pit = forwarder.getPit();
- shared_ptr<Face> face1 = make_shared<DummyFace>();
- shared_ptr<Face> face2 = make_shared<DummyFace>();
- forwarder.addFace(face1);
- forwarder.addFace(face2);
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ faceTable.add(face1);
+ faceTable.add(face2);
// {}
BOOST_CHECK_EQUAL(pit.size(), 0);
diff --git a/tests/daemon/table/measurements-accessor.t.cpp b/tests/daemon/table/measurements-accessor.t.cpp
index aeed38f..1c5a850 100644
--- a/tests/daemon/table/measurements-accessor.t.cpp
+++ b/tests/daemon/table/measurements-accessor.t.cpp
@@ -62,7 +62,6 @@
{
protected:
MeasurementsAccessorFixture()
- : measurements(forwarder.getMeasurements())
{
const Name strategyP("/measurements-accessor-test-strategy-P/%FD%01");
const Name strategyQ("/measurements-accessor-test-strategy-Q/%FD%01");
@@ -81,8 +80,9 @@
}
protected:
- Forwarder forwarder;
- Measurements& measurements;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ Measurements& measurements{forwarder.getMeasurements()};
MeasurementsAccessor* accessor1;
MeasurementsAccessor* accessor2;
MeasurementsAccessor* accessor3;
diff --git a/tests/daemon/table/strategy-choice.t.cpp b/tests/daemon/table/strategy-choice.t.cpp
index 339903e..8c52b54 100644
--- a/tests/daemon/table/strategy-choice.t.cpp
+++ b/tests/daemon/table/strategy-choice.t.cpp
@@ -36,9 +36,6 @@
{
protected:
StrategyChoiceFixture()
- : sc(forwarder.getStrategyChoice())
- , strategyNameP("/strategy-choice-P/%FD%00")
- , strategyNameQ("/strategy-choice-Q/%FD%00")
{
DummyStrategy::registerAs(strategyNameP);
DummyStrategy::registerAs(strategyNameQ);
@@ -77,11 +74,12 @@
}
protected:
- Forwarder forwarder;
- StrategyChoice& sc;
+ FaceTable faceTable;
+ Forwarder forwarder{faceTable};
+ StrategyChoice& sc{forwarder.getStrategyChoice()};
- const Name strategyNameP;
- const Name strategyNameQ;
+ const Name strategyNameP = "/strategy-choice-P/%FD%00";
+ const Name strategyNameQ = "/strategy-choice-Q/%FD%00";
};
BOOST_AUTO_TEST_SUITE(Table)