face: reimplement EndpointId with std::variant
Refs: #5041
Change-Id: Ib8aced49a7aa14b137fb06de4a0ae8b979f07587
diff --git a/tests/daemon/face/lp-reassembler.t.cpp b/tests/daemon/face/lp-reassembler.t.cpp
index 16a3592..073c3db 100644
--- a/tests/daemon/face/lp-reassembler.t.cpp
+++ b/tests/daemon/face/lp-reassembler.t.cpp
@@ -38,7 +38,7 @@
LpReassemblerFixture()
{
reassembler.beforeTimeout.connect(
- [this] (EndpointId remoteEp, size_t nDroppedFragments) {
+ [this] (const EndpointId& remoteEp, size_t nDroppedFragments) {
timeoutHistory.emplace_back(remoteEp, nDroppedFragments);
});
}
@@ -72,7 +72,7 @@
bool isComplete = false;
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
@@ -93,7 +93,7 @@
bool isComplete = false;
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
@@ -113,7 +113,7 @@
bool isComplete = false;
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
@@ -132,7 +132,7 @@
bool isComplete = false;
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
@@ -172,15 +172,15 @@
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 1);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 1);
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received3);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received3);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
@@ -215,13 +215,13 @@
Block netPacket;
lp::Packet packet;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received3);
+ std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment({}, received3);
BOOST_REQUIRE(isComplete);
BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
@@ -254,14 +254,14 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, frag2);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag0);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, frag0);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag1);
- BOOST_REQUIRE(isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, frag1);
+ BOOST_TEST(isComplete);
}
BOOST_AUTO_TEST_CASE(Duplicate)
@@ -276,11 +276,11 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag0);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, frag0);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag0);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, frag0);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_CASE(Timeout)
@@ -301,21 +301,21 @@
received2.add<lp::FragCountField>(2);
received2.add<lp::SequenceField>(1001);
- const EndpointId REMOTE_EP = 11028;
+ const EndpointId REMOTE_EP = ethernet::getDefaultMulticastAddress();
bool isComplete = false;
std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP, received1);
- BOOST_REQUIRE(!isComplete);
+ BOOST_TEST(!isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 1);
BOOST_CHECK(timeoutHistory.empty());
advanceClocks(1_ms, 600);
BOOST_CHECK_EQUAL(reassembler.size(), 0);
BOOST_REQUIRE_EQUAL(timeoutHistory.size(), 1);
- BOOST_CHECK_EQUAL(std::get<0>(timeoutHistory.back()), REMOTE_EP);
+ BOOST_CHECK(std::get<0>(timeoutHistory.back()) == REMOTE_EP);
BOOST_CHECK_EQUAL(std::get<1>(timeoutHistory.back()), 1);
std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP, received2);
- BOOST_REQUIRE(!isComplete);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_CASE(MissingSequence)
@@ -344,19 +344,19 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received3);
+ BOOST_TEST(!isComplete);
advanceClocks(1_ms, 600);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_CASE(FragCountOverLimit)
@@ -372,8 +372,8 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_CASE(MissingFragCount)
@@ -403,14 +403,14 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received3);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_CASE(OverFragCount)
@@ -444,14 +444,14 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received1);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received2);
+ BOOST_TEST(!isComplete);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment({}, received3);
+ BOOST_TEST(!isComplete);
}
BOOST_AUTO_TEST_SUITE_END() // MultiFragment
@@ -491,20 +491,23 @@
bool isComplete = false;
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag1_1);
- BOOST_REQUIRE(!isComplete);
+ const EndpointId REMOTE_EP_1 = ethernet::Address::fromString("11:22:33:45:67:89");
+ const EndpointId REMOTE_EP_2 = ethernet::Address::fromString("11:22:33:ab:cd:ef");
+
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP_1, frag1_1);
+ BOOST_TEST(!isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 1);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(2, frag2_2);
- BOOST_REQUIRE(!isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP_2, frag2_2);
+ BOOST_TEST(!isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 2);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag1_2);
- BOOST_REQUIRE(isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP_1, frag1_2);
+ BOOST_TEST(isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 1);
- std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(2, frag2_1);
- BOOST_REQUIRE(isComplete);
+ std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP_2, frag2_1);
+ BOOST_TEST(isComplete);
BOOST_CHECK_EQUAL(reassembler.size(), 0);
}