build: align minimum build dependencies with ndn-cxx
* boost 1.65.1
* gcc 7.4
* clang 6.0
* Xcode 10.0 (11.3 or later recommended)
Also improve some test cases
Change-Id: Ib81d082a19e61940fa6f1d89204ea8de8ed57940
diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp
index 55007b8..3c71f74 100644
--- a/tests/communication/test-sync-logic-handler.cpp
+++ b/tests/communication/test-sync-logic-handler.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.
*
@@ -36,13 +36,7 @@
{
public:
SyncLogicFixture()
- : face(m_ioService, m_keyChain)
- , conf(face, m_keyChain)
- , confProcessor(conf, SYNC_PROTOCOL_PSYNC)
- , testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType,
- const uint64_t sequenceNumber) {
- return true;
- })
+ : testIsLsaNew([] (auto&&...) { return true; })
, sync(face, testIsLsaNew, conf)
, updateNamePrefix(this->conf.getLsaPrefix().toUri() +
this->conf.getSiteName().toUri() +
@@ -65,146 +59,156 @@
}
public:
- ndn::util::DummyClientFace face;
- ConfParameter conf;
- DummyConfFileProcessor confProcessor;
+ ndn::util::DummyClientFace face{m_ioService, m_keyChain};
+ ConfParameter conf{face, m_keyChain};
+ DummyConfFileProcessor confProcessor{conf, SYNC_PROTOCOL_PSYNC};
SyncLogicHandler::IsLsaNew testIsLsaNew;
SyncLogicHandler sync;
const std::string updateNamePrefix;
- const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY,
- Lsa::Type::COORDINATE};
+ const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME,
+ Lsa::Type::ADJACENCY,
+ Lsa::Type::COORDINATE};
};
-BOOST_AUTO_TEST_SUITE(TestSyncLogicHandler)
+BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
/* Tests that when SyncLogicHandler receives an LSA of either Name or
Adjacency type that appears to be newer, it will emit to its signal
with those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherLS, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
{
- std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY};
-
+ size_t nCallbacks = 0;
uint64_t syncSeqNo = 1;
- for (const Lsa::Type& lsaType : lsaTypes) {
+ for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
- // Actual testing done here -- signal function callback
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+ ++nCallbacks;
});
this->receiveUpdate(updateName, syncSeqNo);
}
+
+ BOOST_CHECK_EQUAL(nCallbacks, 2);
}
/* Tests that when SyncLogicHandler in HR mode receives an LSA of
either Coordinate or Name type that appears to be newer, it will
emit to its signal with those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherHR, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
{
this->conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
+ size_t nCallbacks = 0;
uint64_t syncSeqNo = 1;
- std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
- for (const Lsa::Type& lsaType : lsaTypes) {
+ for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+ ++nCallbacks;
});
this->receiveUpdate(updateName, syncSeqNo);
}
+
+ BOOST_CHECK_EQUAL(nCallbacks, 2);
}
/* Tests that when SyncLogicHandler in HR-dry mode receives an LSA of
any type that appears to be newer, it will emit to its signal with
those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherHRDry, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
{
this->conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
+ size_t nCallbacks = 0;
uint64_t syncSeqNo = 1;
- for (const Lsa::Type& lsaType : this->lsaTypes) {
+ for (auto lsaType : this->lsaTypes) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+ ++nCallbacks;
});
this->receiveUpdate(updateName, syncSeqNo);
}
+
+ BOOST_CHECK_EQUAL(nCallbacks, 3);
}
/* Tests that when SyncLogicHandler receives an update for an LSA with
details matching this router's details, it will *not* emit to its
signal those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(NoUpdateForSelf, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
{
const uint64_t sequenceNumber = 1;
- for (const Lsa::Type& lsaType : this->lsaTypes) {
+ for (auto lsaType : this->lsaTypes) {
// To ensure that we get correctly-separated components, create
// and modify a Name to hand off.
- ndn::Name updateName = ndn::Name{this->conf.getLsaPrefix()};
+ ndn::Name updateName{this->conf.getLsaPrefix()};
updateName.append(this->conf.getSiteName())
.append(this->conf.getRouterName())
.append(boost::lexical_cast<std::string>(lsaType));
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_FAIL("Updates for self should not be emitted!");
});
this->receiveUpdate(updateName.toUri(), sequenceNumber);
}
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
/* Tests that when SyncLogicHandler receives an update for an LSA with
details that do not match the expected format, it will *not* emit
to its signal those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(MalformedUpdate, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(MalformedUpdate)
{
const uint64_t sequenceNumber = 1;
- for (const Lsa::Type& lsaType : this->lsaTypes) {
+ for (auto lsaType : this->lsaTypes) {
ndn::Name updateName{this->conf.getSiteName()};
updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_FAIL("Malformed updates should not be emitted!");
});
this->receiveUpdate(updateName.toUri(), sequenceNumber);
}
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
/* Tests that when SyncLogicHandler receives an update for an LSA with
details that do not appear to be new, it will *not* emit to its
signal those LSA details.
*/
-BOOST_FIXTURE_TEST_CASE(LsaNotNew, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(LsaNotNew)
{
auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
const uint64_t& sequenceNumber) {
@@ -214,21 +218,22 @@
const uint64_t sequenceNumber = 1;
SyncLogicHandler sync{this->face, testLsaAlwaysFalse, this->conf};
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
- [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
- const ndn::Name& originRouter) {
+ [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
});
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(Lsa::Type::NAME);
-
this->receiveUpdate(updateName, sequenceNumber);
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
/* Tests that SyncLogicHandler successfully concatenates configured
variables together to form the necessary prefixes to advertise
through sync.
*/
-BOOST_FIXTURE_TEST_CASE(UpdatePrefix, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdatePrefix)
{
ndn::Name expectedPrefix = this->conf.getLsaPrefix();
expectedPrefix.append(this->conf.getSiteName());