From 14e71f0fe8478971da4003b1cd12f44a65450356 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Thu, 28 Mar 2019 17:35:25 -0400 Subject: [PATCH] tests+tools: minor code cleanup Change-Id: Ic3356d4a18a8e5eeb45fc076fc0563c3d1549c8a --- daemon/fw/asf-measurements.hpp | 4 +- daemon/fw/self-learning-strategy.cpp | 2 +- daemon/rib/readvertise/readvertise.cpp | 2 +- tests/core/config-file.t.cpp | 2 +- tests/core/ndebug.t.cpp | 6 +- tests/core/rtt-estimator.t.cpp | 6 +- tests/core/version.t.cpp | 6 +- tests/daemon/face/datagram-transport.t.cpp | 4 +- tests/daemon/face/ethernet-channel.t.cpp | 2 +- tests/daemon/face/ethernet-factory.t.cpp | 12 ++-- tests/daemon/face/ethernet-fixture.hpp | 2 +- tests/daemon/face/generic-link-service.t.cpp | 34 ++++----- tests/daemon/face/internal-face.t.cpp | 26 +++---- tests/daemon/face/lp-reassembler.t.cpp | 4 +- tests/daemon/face/lp-reliability.t.cpp | 42 +++++------ .../face/multicast-ethernet-transport.t.cpp | 2 +- .../face/multicast-udp-transport-fixture.hpp | 4 +- .../daemon/face/multicast-udp-transport.t.cpp | 4 +- tests/daemon/face/stream-transport.t.cpp | 10 +-- tests/daemon/face/tcp-channel.t.cpp | 6 +- tests/daemon/face/tcp-transport-fixture.hpp | 4 +- tests/daemon/face/tcp-udp-channel.t.cpp | 12 ++-- tests/daemon/face/transport.t.cpp | 3 +- tests/daemon/face/udp-channel-fixture.hpp | 4 +- .../face/unicast-ethernet-transport.t.cpp | 6 +- .../face/unicast-udp-transport-fixture.hpp | 6 +- tests/daemon/face/unicast-udp-transport.t.cpp | 12 ++-- tests/daemon/face/unix-stream-channel.t.cpp | 6 +- .../face/unix-stream-transport-fixture.hpp | 4 +- .../face/websocket-transport-fixture.hpp | 8 +-- tests/daemon/face/websocket-transport.t.cpp | 22 +++--- tests/daemon/fw/access-strategy.t.cpp | 46 +++++------- tests/daemon/fw/ad-hoc-forwarding.t.cpp | 18 +++-- tests/daemon/fw/algorithm.t.cpp | 2 +- tests/daemon/fw/asf-measurements.t.cpp | 6 +- tests/daemon/fw/asf-strategy.t.cpp | 47 ++++++------- tests/daemon/fw/best-route-strategy.t.cpp | 8 +-- tests/daemon/fw/best-route-strategy2.t.cpp | 4 +- tests/daemon/fw/forwarder.t.cpp | 32 ++++----- tests/daemon/fw/forwarding-hint.t.cpp | 16 ++--- tests/daemon/fw/multicast-strategy.t.cpp | 4 +- tests/daemon/fw/ncc-strategy.t.cpp | 70 +++++++++---------- tests/daemon/fw/retx-suppression.t.cpp | 24 +++---- tests/daemon/fw/strategy-nack-return.t.cpp | 20 +++--- tests/daemon/fw/strategy-no-route.t.cpp | 2 - tests/daemon/fw/strategy-scope-control.t.cpp | 2 - tests/daemon/fw/strategy-tester.hpp | 15 ++-- tests/daemon/mgmt/fib-manager.t.cpp | 2 +- .../mgmt/forwarder-status-manager.t.cpp | 2 +- tests/daemon/mgmt/manager-base.t.cpp | 2 +- tests/daemon/rib/fib-updates-common.hpp | 30 ++------ .../host-to-gateway-readvertise-policy.t.cpp | 6 +- .../nfd-rib-readvertise-destination.t.cpp | 12 ++-- .../daemon/rib/readvertise/readvertise.t.cpp | 20 +++--- tests/daemon/rib/rib-update.t.cpp | 4 +- tests/daemon/rib/rib.t.cpp | 8 ++- tests/daemon/rib/service.t.cpp | 4 +- .../table/cs-policy-priority-fifo.t.cpp | 24 +++---- tests/daemon/table/cs.t.cpp | 14 ++-- tests/daemon/table/dead-nonce-list.t.cpp | 2 +- tests/daemon/table/measurements.t.cpp | 18 ++--- tests/daemon/table/name-tree.t.cpp | 2 +- tests/daemon/table/network-region-table.t.cpp | 4 +- tests/daemon/table/pit-entry.t.cpp | 10 +-- tests/daemon/table/pit.t.cpp | 6 +- tests/other/face-benchmark.cpp | 2 +- .../ndn-autoconfig/multicast-discovery.t.cpp | 2 +- .../tools/nfdc/forwarder-general-module.t.cpp | 6 +- tests/tools/nfdc/rib-module.t.cpp | 10 +-- tests/tools/nfdc/status-fixture.hpp | 7 +- tests/tools/nfdc/status-report.t.cpp | 20 +++--- tools/ndn-autoconfig-server/program.cpp | 16 ++--- tools/ndn-autoconfig/main.cpp | 8 +-- tools/ndn-autoconfig/multicast-discovery.cpp | 12 ++-- tools/ndn-autoconfig/procedure.cpp | 10 +-- tools/nfdc/execute-command.cpp | 6 +- 76 files changed, 406 insertions(+), 446 deletions(-) diff --git a/daemon/fw/asf-measurements.hpp b/daemon/fw/asf-measurements.hpp index b5b1f8ed..a3775b05 100644 --- a/daemon/fw/asf-measurements.hpp +++ b/daemon/fw/asf-measurements.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -316,7 +316,7 @@ private: extendLifetime(measurements::Entry& me); public: - static constexpr time::microseconds MEASUREMENTS_LIFETIME = 300_s; + static constexpr time::microseconds MEASUREMENTS_LIFETIME = 5_min; private: MeasurementsAccessor& m_measurements; diff --git a/daemon/fw/self-learning-strategy.cpp b/daemon/fw/self-learning-strategy.cpp index f0eab59b..d199b864 100644 --- a/daemon/fw/self-learning-strategy.cpp +++ b/daemon/fw/self-learning-strategy.cpp @@ -42,7 +42,7 @@ namespace fw { NFD_LOG_INIT(SelfLearningStrategy); NFD_REGISTER_STRATEGY(SelfLearningStrategy); -const time::milliseconds SelfLearningStrategy::ROUTE_RENEW_LIFETIME(600_s); +const time::milliseconds SelfLearningStrategy::ROUTE_RENEW_LIFETIME(10_min); SelfLearningStrategy::SelfLearningStrategy(Forwarder& forwarder, const Name& name) : Strategy(forwarder) diff --git a/daemon/rib/readvertise/readvertise.cpp b/daemon/rib/readvertise/readvertise.cpp index d5bedf8c..7b59e222 100644 --- a/daemon/rib/readvertise/readvertise.cpp +++ b/daemon/rib/readvertise/readvertise.cpp @@ -35,7 +35,7 @@ namespace rib { NFD_LOG_INIT(Readvertise); const time::milliseconds Readvertise::RETRY_DELAY_MIN = 50_s; -const time::milliseconds Readvertise::RETRY_DELAY_MAX = 3600_s; +const time::milliseconds Readvertise::RETRY_DELAY_MAX = 1_h; static time::milliseconds randomizeTimer(time::milliseconds baseTimer) diff --git a/tests/core/config-file.t.cpp b/tests/core/config-file.t.cpp index c2ceb858..05b2722f 100644 --- a/tests/core/config-file.t.cpp +++ b/tests/core/config-file.t.cpp @@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(CoveredByPartialSubscribers) BOOST_CHECK(subB.allCallbacksFired()); } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestConfigFile } // namespace tests } // namespace nfd diff --git a/tests/core/ndebug.t.cpp b/tests/core/ndebug.t.cpp index 3af09aa4..8465b060 100644 --- a/tests/core/ndebug.t.cpp +++ b/tests/core/ndebug.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2016, Regents of the University of California, +/* + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(SideEffect) #endif } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestNdebug } // namespace tests } // namespace nfd diff --git a/tests/core/rtt-estimator.t.cpp b/tests/core/rtt-estimator.t.cpp index 526b03d1..6673ecdd 100644 --- a/tests/core/rtt-estimator.t.cpp +++ b/tests/core/rtt-estimator.t.cpp @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(Basic) RttEstimator rtt; for (int i = 0; i < 100; ++i) { - rtt.addMeasurement(time::seconds(5)); + rtt.addMeasurement(5_s); } double rto1 = computeRtoAsFloatSeconds(rtt); BOOST_CHECK_CLOSE(rto1, 5.0, 0.1); @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(Basic) double rto3 = computeRtoAsFloatSeconds(rtt); BOOST_CHECK_CLOSE(rto3, 20.0, 0.1); - rtt.addMeasurement(time::seconds(5)); // reset multiplier + rtt.addMeasurement(5_s); // reset multiplier double rto4 = computeRtoAsFloatSeconds(rtt); BOOST_CHECK_CLOSE(rto4, 5.0, 0.1); @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK_CLOSE(rto5, 10.0, 0.1); for (int i = 0; i < 5; ++i) { - rtt.addMeasurement(time::seconds(6)); + rtt.addMeasurement(6_s); } // increased variance double rto6 = computeRtoAsFloatSeconds(rtt); BOOST_CHECK_GT(rto6, rto1); diff --git a/tests/core/version.t.cpp b/tests/core/version.t.cpp index 1de0e60c..27e37993 100644 --- a/tests/core/version.t.cpp +++ b/tests/core/version.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California, +/* + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(VersionString) BOOST_CHECK_EQUAL(NFD_VERSION_STRING, buf); } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestVersion } // namespace tests } // namespace nfd diff --git a/tests/daemon/face/datagram-transport.t.cpp b/tests/daemon/face/datagram-transport.t.cpp index d5ce2a86..fd1a8e09 100644 --- a/tests/daemon/face/datagram-transport.t.cpp +++ b/tests/daemon/face/datagram-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -149,7 +149,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Close, T, DatagramTransportFixtures, T) this->limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(SendQueueLength, T, DatagramTransportFixtures, T) diff --git a/tests/daemon/face/ethernet-channel.t.cpp b/tests/daemon/face/ethernet-channel.t.cpp index d7a1cec6..c1311da0 100644 --- a/tests/daemon/face/ethernet-channel.t.cpp +++ b/tests/daemon/face/ethernet-channel.t.cpp @@ -39,7 +39,7 @@ protected: makeChannel() { BOOST_ASSERT(netifs.size() > 0); - return make_unique(netifs.front(), time::seconds(2)); + return make_unique(netifs.front(), 2_s); } }; diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp index b69141de..e204ceeb 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-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(GetChannels) BOOST_CHECK_EQUAL(factory.getChannels().empty(), true); SKIP_IF_ETHERNET_NETIF_COUNT_LT(1); - factory.createChannel(netifs.front(), time::minutes(1)); + factory.createChannel(netifs.front(), 1_min); checkChannelListEqual(factory, {FaceUri::fromDev(netifs.front()->getName()).toString()}); } @@ -444,14 +444,14 @@ BOOST_AUTO_TEST_CASE(CreateChannel) { SKIP_IF_ETHERNET_NETIF_COUNT_LT(1); - auto channel1 = factory.createChannel(netifs.front(), time::minutes(1)); - auto channel1a = factory.createChannel(netifs.front(), time::minutes(5)); + auto channel1 = factory.createChannel(netifs.front(), 1_min); + auto channel1a = factory.createChannel(netifs.front(), 5_min); BOOST_CHECK_EQUAL(channel1, channel1a); BOOST_CHECK_EQUAL(channel1->getUri().toString(), "dev://" + netifs.front()->getName()); SKIP_IF_ETHERNET_NETIF_COUNT_LT(2); - auto channel2 = factory.createChannel(netifs.back(), time::minutes(1)); + auto channel2 = factory.createChannel(netifs.back(), 1_min); BOOST_CHECK_NE(channel1, channel2); } @@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(CreateFace) {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"}); SKIP_IF_ETHERNET_NETIF_COUNT_LT(1); - auto localUri = factory.createChannel(netifs.front(), time::minutes(1))->getUri(); + auto localUri = factory.createChannel(netifs.front(), 1_min)->getUri(); createFace(factory, FaceUri("ether://[00:00:5e:00:53:5e]"), diff --git a/tests/daemon/face/ethernet-fixture.hpp b/tests/daemon/face/ethernet-fixture.hpp index 5a8160e5..1898d507 100644 --- a/tests/daemon/face/ethernet-fixture.hpp +++ b/tests/daemon/face/ethernet-fixture.hpp @@ -71,7 +71,7 @@ protected: BOOST_ASSERT(netif != nullptr); localEp = netif->getName(); remoteEp = remoteAddr; - transport = make_unique(*netif, remoteEp, persistency, time::seconds(2)); + transport = make_unique(*netif, remoteEp, persistency, 2_s); } /** \brief create a MulticastEthernetTransport diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp index d10dba52..cf51e54b 100644 --- a/tests/daemon/face/generic-link-service.t.cpp +++ b/tests/daemon/face/generic-link-service.t.cpp @@ -485,7 +485,7 @@ BOOST_AUTO_TEST_CASE(NoCongestion) { GenericLinkService::Options options; options.allowCongestionMarking = true; - options.baseCongestionMarkingInterval = time::milliseconds(100); + options.baseCongestionMarkingInterval = 100_ms; initialize(options, MTU_UNLIMITED, 65536); BOOST_CHECK_EQUAL(service->m_nextMarkTime, time::steady_clock::TimePoint::max()); BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 0); @@ -522,7 +522,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) { GenericLinkService::Options options; options.allowCongestionMarking = true; - options.baseCongestionMarkingInterval = time::milliseconds(100); + options.baseCongestionMarkingInterval = 100_ms; initialize(options, MTU_UNLIMITED, 65536); BOOST_CHECK_EQUAL(service->m_nextMarkTime, time::steady_clock::TimePoint::max()); BOOST_CHECK_EQUAL(service->m_lastMarkTime, time::steady_clock::TimePoint::min()); @@ -541,7 +541,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_REQUIRE_NO_THROW(pkt1.wireDecode(transport->sentPackets.back().packet)); BOOST_REQUIRE_EQUAL(pkt1.count(), 1); BOOST_CHECK_EQUAL(pkt1.get(), 1); - time::steady_clock::TimePoint nextMarkTime = time::steady_clock::now() + time::milliseconds(100); + time::steady_clock::TimePoint nextMarkTime = time::steady_clock::now() + 100_ms; BOOST_CHECK_EQUAL(service->m_nextMarkTime, nextMarkTime); time::steady_clock::TimePoint lastMarkTime = time::steady_clock::now(); BOOST_CHECK_EQUAL(service->m_lastMarkTime, lastMarkTime); @@ -549,7 +549,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 1); // advance clock to half of marking interval cycle - advanceClocks(time::milliseconds(50)); + advanceClocks(50_ms); // second congested packet, but within marking interval, will not be marked transport->setSendQueueLength(33000); @@ -564,7 +564,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 1); // advance clocks past end of initial interval cycle - this->advanceClocks(time::milliseconds(51)); + this->advanceClocks(51_ms); // first congested packet after waiting marking interval, will be marked transport->setSendQueueLength(40000); @@ -585,7 +585,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 2); // advance clock partway through current marking interval - this->advanceClocks(markingInterval - time::milliseconds(10)); + this->advanceClocks(markingInterval - 10_ms); // still congested, but within marking interval cycle transport->setSendQueueLength(38000); @@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 2); // advance clocks past end of current marking interval cycle - this->advanceClocks(time::milliseconds(11)); + this->advanceClocks(11_ms); // still congested, after marking interval cycle transport->setSendQueueLength(39000); @@ -620,7 +620,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 3); BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 3); - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); // still congested, but within marking interval cycle transport->setSendQueueLength(38000); @@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 0); BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 4); - this->advanceClocks(time::milliseconds(50)); + this->advanceClocks(50_ms); // send queue congested again, but can't mark packet because within one full interval of last mark transport->setSendQueueLength(50000); @@ -681,7 +681,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 4); // advance clock past full 100ms interval since last mark - this->advanceClocks(time::milliseconds(51)); + this->advanceClocks(51_ms); transport->setSendQueueLength(40000); face->sendInterest(*interest); @@ -690,7 +690,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_REQUIRE_NO_THROW(pkt10.wireDecode(transport->sentPackets.back().packet)); BOOST_REQUIRE_EQUAL(pkt10.count(), 1); BOOST_CHECK_EQUAL(pkt10.get(), 1); - nextMarkTime = time::steady_clock::now() + time::milliseconds(100); + nextMarkTime = time::steady_clock::now() + 100_ms; BOOST_CHECK_EQUAL(service->m_nextMarkTime, nextMarkTime); lastMarkTime = time::steady_clock::now(); BOOST_CHECK_EQUAL(service->m_lastMarkTime, lastMarkTime); @@ -698,7 +698,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 5); // advance clock partway through 100ms marking interval - this->advanceClocks(time::milliseconds(50)); + this->advanceClocks(50_ms); // not marked since within 100ms window before can mark again transport->setSendQueueLength(50000); @@ -713,7 +713,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 5); // advance clocks past m_nextMarkTime - this->advanceClocks(time::milliseconds(51)); + this->advanceClocks(51_ms); // markable packet, queue length still above threshold transport->setSendQueueLength(33000); @@ -746,7 +746,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 6); // advance clocks past one full interval since last mark - this->advanceClocks(time::milliseconds(101)); + this->advanceClocks(101_ms); // start congestion again transport->setSendQueueLength(50000); @@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel) BOOST_REQUIRE_NO_THROW(pkt14.wireDecode(transport->sentPackets.back().packet)); BOOST_REQUIRE_EQUAL(pkt14.count(), 1); BOOST_CHECK_EQUAL(pkt14.get(), 1); - nextMarkTime = time::steady_clock::now() + time::milliseconds(100); + nextMarkTime = time::steady_clock::now() + 100_ms; BOOST_CHECK_EQUAL(service->m_nextMarkTime, nextMarkTime); lastMarkTime = time::steady_clock::now(); BOOST_CHECK_EQUAL(service->m_lastMarkTime, lastMarkTime); @@ -780,7 +780,7 @@ BOOST_AUTO_TEST_CASE(DefaultThreshold) { GenericLinkService::Options options; options.allowCongestionMarking = true; - options.baseCongestionMarkingInterval = time::milliseconds(100); + options.baseCongestionMarkingInterval = 100_ms; initialize(options, MTU_UNLIMITED, QUEUE_UNSUPPORTED); BOOST_CHECK_EQUAL(service->m_nextMarkTime, time::steady_clock::TimePoint::max()); BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 0); @@ -821,7 +821,7 @@ BOOST_AUTO_TEST_CASE(DefaultThreshold) BOOST_REQUIRE_NO_THROW(pkt3.wireDecode(transport->sentPackets.back().packet)); BOOST_REQUIRE_EQUAL(pkt3.count(), 1); BOOST_CHECK_EQUAL(pkt3.get(), 1); - time::steady_clock::TimePoint nextMarkTime = time::steady_clock::now() + time::milliseconds(100); + time::steady_clock::TimePoint nextMarkTime = time::steady_clock::now() + 100_ms; BOOST_CHECK_EQUAL(service->m_nextMarkTime, nextMarkTime); BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 1); BOOST_CHECK_EQUAL(service->getCounters().nCongestionMarked, 1); diff --git a/tests/daemon/face/internal-face.t.cpp b/tests/daemon/face/internal-face.t.cpp index 4c1618b9..9ea69035 100644 --- a/tests/daemon/face/internal-face.t.cpp +++ b/tests/daemon/face/internal-face.t.cpp @@ -83,19 +83,19 @@ BOOST_AUTO_TEST_CASE(TransportStaticProperties) BOOST_AUTO_TEST_CASE(ReceiveInterestTimeout) { shared_ptr interest = makeInterest("/TLETccRv"); - interest->setInterestLifetime(time::milliseconds(100)); + interest->setInterestLifetime(100_ms); bool hasTimeout = false; clientFace->expressInterest(*interest, bind([] { BOOST_ERROR("unexpected Data"); }), bind([] { BOOST_ERROR("unexpected Nack"); }), bind([&hasTimeout] { hasTimeout = true; })); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1); BOOST_CHECK_EQUAL(receivedInterests.back().getName(), "/TLETccRv"); - this->advanceClocks(time::milliseconds(1), 100); + this->advanceClocks(1_ms, 100); BOOST_CHECK(hasTimeout); } @@ -112,14 +112,14 @@ BOOST_AUTO_TEST_CASE(ReceiveInterestSendData) }, bind([] { BOOST_ERROR("unexpected Nack"); }), bind([] { BOOST_ERROR("unexpected timeout"); })); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1); BOOST_CHECK_EQUAL(receivedInterests.back().getName(), "/PQstEJGdL"); shared_ptr data = makeData("/PQstEJGdL/aI7oCrDXNX"); forwarderFace->sendData(*data); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_CHECK(hasReceivedData); } @@ -136,14 +136,14 @@ BOOST_AUTO_TEST_CASE(ReceiveInterestSendNack) BOOST_CHECK_EQUAL(nack.getReason(), lp::NackReason::NO_ROUTE); }, bind([] { BOOST_ERROR("unexpected timeout"); })); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1); BOOST_CHECK_EQUAL(receivedInterests.back().getName(), "/1HrsRM1X"); lp::Nack nack = makeNack("/1HrsRM1X", 152, lp::NackReason::NO_ROUTE); forwarderFace->sendNack(nack); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_CHECK(hasReceivedNack); } @@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(SendInterestReceiveData) shared_ptr interest = makeInterest("/Wpc8TnEeoF/f6SzV8hD"); forwarderFace->sendInterest(*interest); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_CHECK(hasDeliveredInterest); BOOST_REQUIRE_EQUAL(receivedData.size(), 1); @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(SendInterestReceiveNack) shared_ptr interest = makeInterest("/4YgJKWcXN/5oaTe05o", 191); forwarderFace->sendInterest(*interest); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_CHECK(hasDeliveredInterest); BOOST_REQUIRE_EQUAL(receivedNacks.size(), 1); @@ -193,19 +193,19 @@ BOOST_AUTO_TEST_CASE(SendInterestReceiveNack) BOOST_AUTO_TEST_CASE(CloseForwarderFace) { forwarderFace->close(); - this->advanceClocks(time::milliseconds(1), 10); + this->advanceClocks(1_ms, 10); BOOST_CHECK_EQUAL(forwarderFace->getState(), FaceState::CLOSED); forwarderFace.reset(); shared_ptr interest = makeInterest("/zpHsVesu0B"); - interest->setInterestLifetime(time::milliseconds(100)); + interest->setInterestLifetime(100_ms); bool hasTimeout = false; clientFace->expressInterest(*interest, bind([] { BOOST_ERROR("unexpected Data"); }), bind([] { BOOST_ERROR("unexpected Nack"); }), bind([&hasTimeout] { hasTimeout = true; })); - BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(1), 200)); + BOOST_CHECK_NO_THROW(this->advanceClocks(1_ms, 200)); BOOST_CHECK_EQUAL(receivedInterests.size(), 0); BOOST_CHECK(hasTimeout); @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(CloseClientFace) shared_ptr interest = makeInterest("/aau42XQqb"); forwarderFace->sendInterest(*interest); - BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(1), 10)); + BOOST_CHECK_NO_THROW(this->advanceClocks(1_ms, 10)); } BOOST_AUTO_TEST_SUITE_END() // TestInternalFace diff --git a/tests/daemon/face/lp-reassembler.t.cpp b/tests/daemon/face/lp-reassembler.t.cpp index f24eb980..8e8bbce9 100644 --- a/tests/daemon/face/lp-reassembler.t.cpp +++ b/tests/daemon/face/lp-reassembler.t.cpp @@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(Timeout) BOOST_CHECK_EQUAL(reassembler.size(), 1); BOOST_CHECK(timeoutHistory.empty()); - advanceClocks(time::milliseconds(1), 600); + 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); @@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE(MissingSequence) std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3); BOOST_REQUIRE(!isComplete); - advanceClocks(time::milliseconds(1), 600); + advanceClocks(1_ms, 600); std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2); BOOST_REQUIRE(!isComplete); diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp index 8ec1dd0e..f9951744 100644 --- a/tests/daemon/face/lp-reliability.t.cpp +++ b/tests/daemon/face/lp-reliability.t.cpp @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+500ms // 1024 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 - advanceClocks(time::milliseconds(1), 500); + advanceClocks(1_ms, 500); linkService->sendLpPackets({pkt2}); BOOST_CHECK_EQUAL(transport->sentPackets.size(), 2); @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+1250ms // 1024 rto: 1000ms, txSeq: 4, started T+1000ms, retx 1 // 3000 rto: 1000ms, txSeq: 3, started T+500ms, retx 0 - advanceClocks(time::milliseconds(1), 750); + advanceClocks(1_ms, 750); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq), 0); @@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+2250ms // 1024 rto: 1000ms, txSeq: 6, started T+2000ms, retx 2 // 3000 rto: 1000ms, txSeq: 5, started T+1500ms, retx 1 - advanceClocks(time::milliseconds(1), 1000); + advanceClocks(1_ms, 1000); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 1), 0); @@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+3250ms // 1024 rto: 1000ms, txSeq: 8, started T+3000ms, retx 3 // 3000 rto: 1000ms, txSeq: 7, started T+2500ms, retx 2 - advanceClocks(time::milliseconds(1), 1000); + advanceClocks(1_ms, 1000); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 3), 0); @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+4250ms // 1024 rto: expired, removed // 3000 rto: 1000ms, txSeq: 9, started T+3500ms, retx 3 - advanceClocks(time::milliseconds(1), 1000); + advanceClocks(1_ms, 1000); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 5), 0); @@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) // T+4750ms // 1024 rto: expired, removed // 3000 rto: expired, removed - advanceClocks(time::milliseconds(1), 1000); + advanceClocks(1_ms, 1000); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); @@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(SendFragmentedRetx) // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 // 2049 rto: 1000ms, txSeq: 5, started T+250ms, retx 1 // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 - advanceClocks(time::milliseconds(1), 250); + advanceClocks(1_ms, 250); reliability->onLpPacketLost(3); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(SendFragmentedRetx) // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 // 2049 rto: 1000ms, txSeq: 6, started T+500ms, retx 2 // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 - advanceClocks(time::milliseconds(1), 250); + advanceClocks(1_ms, 250); reliability->onLpPacketLost(5); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); @@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE(SendFragmentedRetx) // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 // 2049 rto: 1000ms, txSeq: 7, started T+750ms, retx 3 // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 - advanceClocks(time::milliseconds(1), 250); + advanceClocks(1_ms, 250); reliability->onLpPacketLost(6); BOOST_REQUIRE_EQUAL(reliability->m_unackedFrags.count(2), 1); @@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(SendFragmentedRetx) // 2048 rto: expired, removed // 2049 rto: expired, removed // 2050 rto: expired, removed - advanceClocks(time::milliseconds(1), 100); + advanceClocks(1_ms, 100); reliability->onLpPacketLost(7); BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); @@ -698,13 +698,13 @@ BOOST_AUTO_TEST_CASE(CancelLossNotificationOnAck) linkService->sendLpPackets({makeFrag(1, 50)}); - advanceClocks(time::milliseconds(1), 500); + advanceClocks(1_ms, 500); lp::Packet ackPkt; ackPkt.add(1); reliability->processIncomingPacket(ackPkt); - advanceClocks(time::milliseconds(1), 1000); + advanceClocks(1_ms, 1000); BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 1); BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); @@ -737,7 +737,7 @@ BOOST_AUTO_TEST_CASE(ProcessIncomingPacket) BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 234567); // T+5ms - advanceClocks(time::milliseconds(1), 5); + advanceClocks(1_ms, 5); BOOST_CHECK(!reliability->m_isIdleAckTimerRunning); } @@ -827,7 +827,7 @@ BOOST_AUTO_TEST_CASE(StartIdleAckTimer) BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+1ms - advanceClocks(time::milliseconds(1), 1); + advanceClocks(1_ms, 1); BOOST_CHECK(reliability->m_isIdleAckTimerRunning); lp::Packet pkt2 = makeFrag(2, 100); @@ -836,7 +836,7 @@ BOOST_AUTO_TEST_CASE(StartIdleAckTimer) BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+5ms - advanceClocks(time::milliseconds(1), 4); + advanceClocks(1_ms, 4); BOOST_CHECK(!reliability->m_isIdleAckTimerRunning); lp::Packet pkt3 = makeFrag(3, 100); @@ -845,11 +845,11 @@ BOOST_AUTO_TEST_CASE(StartIdleAckTimer) BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+9ms - advanceClocks(time::milliseconds(1), 4); + advanceClocks(1_ms, 4); BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+10ms - advanceClocks(time::milliseconds(1), 1); + advanceClocks(1_ms, 1); BOOST_CHECK(!reliability->m_isIdleAckTimerRunning); } @@ -866,7 +866,7 @@ BOOST_AUTO_TEST_CASE(IdleAckTimer) BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+4ms: idle ack timer has not yet expired, no IDLE packet generated - advanceClocks(time::milliseconds(1), 4); + advanceClocks(1_ms, 4); BOOST_CHECK(reliability->m_isIdleAckTimerRunning); BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500); BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000); @@ -874,7 +874,7 @@ BOOST_AUTO_TEST_CASE(IdleAckTimer) BOOST_CHECK_EQUAL(transport->sentPackets.size(), 0); // T+5ms: idle ack timer expires, IDLE packet generated - advanceClocks(time::milliseconds(1), 1); + advanceClocks(1_ms, 1); BOOST_CHECK(!reliability->m_isIdleAckTimerRunning); BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1); @@ -902,7 +902,7 @@ BOOST_AUTO_TEST_CASE(IdleAckTimerMtu) BOOST_CHECK(reliability->m_isIdleAckTimerRunning); // T+4ms: idle ack timer has not yet expired, no IDLE packet generated - advanceClocks(time::milliseconds(1), 4); + advanceClocks(1_ms, 4); BOOST_CHECK(reliability->m_isIdleAckTimerRunning); BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500); BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000); @@ -910,7 +910,7 @@ BOOST_AUTO_TEST_CASE(IdleAckTimerMtu) BOOST_CHECK_EQUAL(transport->sentPackets.size(), 0); // T+5ms: idle ack timer expires, IDLE packets generated - advanceClocks(time::milliseconds(1), 1); + advanceClocks(1_ms, 1); BOOST_CHECK(!reliability->m_isIdleAckTimerRunning); BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); diff --git a/tests/daemon/face/multicast-ethernet-transport.t.cpp b/tests/daemon/face/multicast-ethernet-transport.t.cpp index 220274c9..db248acb 100644 --- a/tests/daemon/face/multicast-ethernet-transport.t.cpp +++ b/tests/daemon/face/multicast-ethernet-transport.t.cpp @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(Close) limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_AUTO_TEST_CASE(SendQueueLength) diff --git a/tests/daemon/face/multicast-udp-transport-fixture.hpp b/tests/daemon/face/multicast-udp-transport-fixture.hpp index 775b12dd..626c37a5 100644 --- a/tests/daemon/face/multicast-udp-transport-fixture.hpp +++ b/tests/daemon/face/multicast-udp-transport-fixture.hpp @@ -98,14 +98,14 @@ protected: } limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } void remoteWrite(const std::vector& buf, bool needToCheck = true) { sendToGroup(remoteSockTx, buf, needToCheck); - limitedIo.defer(time::seconds(1)); + limitedIo.defer(1_s); } void diff --git a/tests/daemon/face/multicast-udp-transport.t.cpp b/tests/daemon/face/multicast-udp-transport.t.cpp index d8e7a60c..80d4c303 100644 --- a/tests/daemon/face/multicast-udp-transport.t.cpp +++ b/tests/daemon/face/multicast-udp-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -98,7 +98,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveMultipleRemoteEndpoints, T, MulticastUdp this->sendToGroup(remoteSockTx2, buf1); this->sendToGroup(remoteSockTx2, buf2); - this->limitedIo.defer(time::seconds(1)); + this->limitedIo.defer(1_s); BOOST_CHECK_EQUAL(this->transport->getCounters().nInPackets, 4); BOOST_CHECK_EQUAL(this->transport->getCounters().nInBytes, 2 * buf1.size() + 2 * buf2.size()); diff --git a/tests/daemon/face/stream-transport.t.cpp b/tests/daemon/face/stream-transport.t.cpp index 6628b925..de32a4d2 100644 --- a/tests/daemon/face/stream-transport.t.cpp +++ b/tests/daemon/face/stream-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Send, T, StreamTransportFixtures, T) this->limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.begin() + block1.size(), block1.begin(), block1.end()); BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin() + block1.size(), readBuf.end(), block2.begin(), block2.end()); @@ -189,7 +189,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Close, T, StreamTransportFixtures, T) this->limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, T, StreamTransportFixtures, T) @@ -203,7 +203,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, T, StreamTransportFixtures, T) }); this->remoteSocket.close(); - BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); this->transport->afterStateChange.connectSingleShot([this] (TransportState oldState, TransportState newState) { BOOST_CHECK_EQUAL(oldState, TransportState::CLOSING); @@ -211,7 +211,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, T, StreamTransportFixtures, T) this->limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_FIXTURE_TEST_CASE_TEMPLATE(SendQueueLength, T, StreamTransportFixtures, T) diff --git a/tests/daemon/face/tcp-channel.t.cpp b/tests/daemon/face/tcp-channel.t.cpp index 1c2b170f..6789966f 100644 --- a/tests/daemon/face/tcp-channel.t.cpp +++ b/tests/daemon/face/tcp-channel.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -55,9 +55,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ConnectTimeout, F, AddressFamilies) BOOST_CHECK_EQUAL(reason.empty(), false); this->limitedIo.afterOp(); }, - time::seconds(1)); + 1_s); - BOOST_CHECK_EQUAL(this->limitedIo.run(1, time::seconds(2)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(1, 2_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(channel->size(), 0); } diff --git a/tests/daemon/face/tcp-transport-fixture.hpp b/tests/daemon/face/tcp-transport-fixture.hpp index 631abe1f..dd77a957 100644 --- a/tests/daemon/face/tcp-transport-fixture.hpp +++ b/tests/daemon/face/tcp-transport-fixture.hpp @@ -86,7 +86,7 @@ protected: limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS); localEp = sock.local_endpoint(); @@ -115,7 +115,7 @@ protected: BOOST_REQUIRE_EQUAL(error, boost::system::errc::success); } }); - limitedIo.defer(time::seconds(1)); + limitedIo.defer(1_s); } protected: diff --git a/tests/daemon/face/tcp-udp-channel.t.cpp b/tests/daemon/face/tcp-udp-channel.t.cpp index f883f221..5b86e9d7 100644 --- a/tests/daemon/face/tcp-udp-channel.t.cpp +++ b/tests/daemon/face/tcp-udp-channel.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2017, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -83,7 +83,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(MultipleAccepts, T, FixtureAndAddressList, T::F auto ch1 = this->makeChannel(typename T::Address()); this->connect(*ch1); - BOOST_CHECK_EQUAL(this->limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->listenerChannel->size(), 1); BOOST_CHECK_EQUAL(ch1->size(), 1); @@ -94,7 +94,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(MultipleAccepts, T, FixtureAndAddressList, T::F this->connect(*ch2); this->connect(*ch3); - BOOST_CHECK_EQUAL(this->limitedIo.run(4, time::seconds(2)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(4, 2_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->listenerChannel->size(), 3); BOOST_CHECK_EQUAL(ch1->size(), 1); @@ -113,7 +113,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(MultipleAccepts, T, FixtureAndAddressList, T::F // connect twice to the same endpoint this->connect(*ch3); - BOOST_CHECK_EQUAL(this->limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->listenerChannel->size(), 3); BOOST_CHECK_EQUAL(ch1->size(), 1); @@ -132,14 +132,14 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(FaceClosure, T, FixtureAndAddressList, T::Fixtu auto clientChannel = this->makeChannel(typename T::Address()); this->connect(*clientChannel); - BOOST_CHECK_EQUAL(this->limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->listenerChannel->size(), 1); BOOST_CHECK_EQUAL(clientChannel->size(), 1); this->clientFaces.at(0)->close(); - BOOST_CHECK_EQUAL(this->limitedIo.run(2, time::seconds(5)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(this->limitedIo.run(2, 5_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->listenerChannel->size(), 0); BOOST_CHECK_EQUAL(clientChannel->size(), 0); diff --git a/tests/daemon/face/transport.t.cpp b/tests/daemon/face/transport.t.cpp index d586c201..747622e2 100644 --- a/tests/daemon/face/transport.t.cpp +++ b/tests/daemon/face/transport.t.cpp @@ -45,6 +45,7 @@ namespace face { namespace tests { namespace mpl = boost::mpl; +using namespace nfd::tests; BOOST_AUTO_TEST_SUITE(Face) BOOST_AUTO_TEST_SUITE(TestTransport) @@ -211,7 +212,7 @@ BOOST_AUTO_TEST_CASE(NoExpirationTime) BOOST_CHECK_EQUAL(transport->getExpirationTime(), time::steady_clock::TimePoint::max()); } -class DummyTransportFixture : public nfd::tests::GlobalIoFixture +class DummyTransportFixture : public GlobalIoFixture { protected: DummyTransportFixture() diff --git a/tests/daemon/face/udp-channel-fixture.hpp b/tests/daemon/face/udp-channel-fixture.hpp index 708813a5..81d75f36 100644 --- a/tests/daemon/face/udp-channel-fixture.hpp +++ b/tests/daemon/face/udp-channel-fixture.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -44,7 +44,7 @@ protected: if (port == 0) port = getNextPort(); - return make_unique(udp::Endpoint(addr, port), time::seconds(2), false); + return make_unique(udp::Endpoint(addr, port), 2_s, false); } void diff --git a/tests/daemon/face/unicast-ethernet-transport.t.cpp b/tests/daemon/face/unicast-ethernet-transport.t.cpp index a95c3fb6..0a4885d0 100644 --- a/tests/daemon/face/unicast-ethernet-transport.t.cpp +++ b/tests/daemon/face/unicast-ethernet-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(Close) limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_AUTO_TEST_CASE(IdleClose) @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(IdleClose) limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(2, time::seconds(5)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(2, 5_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(nStateChanges, 2); } diff --git a/tests/daemon/face/unicast-udp-transport-fixture.hpp b/tests/daemon/face/unicast-udp-transport-fixture.hpp index 08acd46d..dcd99ef1 100644 --- a/tests/daemon/face/unicast-udp-transport-fixture.hpp +++ b/tests/daemon/face/unicast-udp-transport-fixture.hpp @@ -63,7 +63,7 @@ protected: face = make_unique( make_unique(), - make_unique(std::move(sock), persistency, time::seconds(3))); + make_unique(std::move(sock), persistency, 3_s)); transport = static_cast(face->getTransport()); receivedPackets = &static_cast(face->getLinkService())->receivedPackets; @@ -90,7 +90,7 @@ protected: } limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } void @@ -102,7 +102,7 @@ protected: BOOST_REQUIRE_EQUAL(error, boost::system::errc::success); } }); - limitedIo.defer(time::seconds(1)); + limitedIo.defer(1_s); } protected: diff --git a/tests/daemon/face/unicast-udp-transport.t.cpp b/tests/daemon/face/unicast-udp-transport.t.cpp index a2a3e799..9ef5b95d 100644 --- a/tests/daemon/face/unicast-udp-transport.t.cpp +++ b/tests/daemon/face/unicast-udp-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(IdleClose) limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(2, time::seconds(8)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(2, 8_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(nStateChanges, 2); } @@ -124,7 +124,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, Persistency, RemoteClosePersistenc remoteSocket.close(); Transport::Packet pkt(ndn::encoding::makeStringBlock(300, "hello")); transport->send(std::move(pkt)); // trigger ICMP error - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); transport->afterStateChange.connectSingleShot([this] (TransportState oldState, TransportState newState) { BOOST_CHECK_EQUAL(oldState, TransportState::FAILED); @@ -132,7 +132,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, Persistency, RemoteClosePersistenc this->limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); } BOOST_FIXTURE_TEST_CASE(RemoteClosePermanent, RemoteCloseFixture) @@ -146,7 +146,7 @@ BOOST_FIXTURE_TEST_CASE(RemoteClosePermanent, RemoteCloseFixture) BOOST_CHECK_EQUAL(transport->getCounters().nOutPackets, 1); BOOST_CHECK_EQUAL(transport->getCounters().nOutBytes, block1.size()); - limitedIo.defer(time::seconds(1)); + limitedIo.defer(1_s); BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP); remoteConnect(); @@ -161,7 +161,7 @@ BOOST_FIXTURE_TEST_CASE(RemoteClosePermanent, RemoteCloseFixture) BOOST_REQUIRE_EQUAL(error, boost::system::errc::success); limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.end(), block1.begin(), block1.end()); diff --git a/tests/daemon/face/unix-stream-channel.t.cpp b/tests/daemon/face/unix-stream-channel.t.cpp index 8e20a265..fe9d4be9 100644 --- a/tests/daemon/face/unix-stream-channel.t.cpp +++ b/tests/daemon/face/unix-stream-channel.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(MultipleAccepts) local::stream_protocol::socket client1(g_io); this->clientConnect(client1); - BOOST_CHECK_EQUAL(limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(listenerChannel->size(), 1); local::stream_protocol::socket client2(g_io); @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(MultipleAccepts) this->clientConnect(client2); this->clientConnect(client3); - BOOST_CHECK_EQUAL(limitedIo.run(4, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_CHECK_EQUAL(limitedIo.run(4, 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(listenerChannel->size(), 3); BOOST_CHECK_EQUAL(listenerFaces.size(), 3); diff --git a/tests/daemon/face/unix-stream-transport-fixture.hpp b/tests/daemon/face/unix-stream-transport-fixture.hpp index 582db482..74c1b45b 100644 --- a/tests/daemon/face/unix-stream-transport-fixture.hpp +++ b/tests/daemon/face/unix-stream-transport-fixture.hpp @@ -109,7 +109,7 @@ protected: limitedIo.afterOp(); }); - BOOST_REQUIRE_EQUAL(limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS); + BOOST_REQUIRE_EQUAL(limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS); localEp = sock.local_endpoint(); face = make_unique(make_unique(), @@ -129,7 +129,7 @@ protected: BOOST_REQUIRE_EQUAL(error, boost::system::errc::success); } }); - limitedIo.defer(time::seconds(1)); + limitedIo.defer(1_s); } protected: diff --git a/tests/daemon/face/websocket-transport-fixture.hpp b/tests/daemon/face/websocket-transport-fixture.hpp index 8b8ee427..07763cdd 100644 --- a/tests/daemon/face/websocket-transport-fixture.hpp +++ b/tests/daemon/face/websocket-transport-fixture.hpp @@ -56,7 +56,7 @@ protected: */ void serverListen(const ip::tcp::endpoint& ep, - const time::milliseconds& pongTimeout = time::seconds(1)) + const time::milliseconds& pongTimeout = 1_s) { server.clear_access_channels(websocketpp::log::alevel::all); server.clear_error_channels(websocketpp::log::elevel::all); @@ -99,15 +99,15 @@ protected: */ void initialize(ip::address address, - time::milliseconds pingInterval = time::seconds(10), - time::milliseconds pongTimeout = time::seconds(1)) + time::milliseconds pingInterval = 10_s, + time::milliseconds pongTimeout = 1_s) { ip::tcp::endpoint ep(address, 20070); serverListen(ep, pongTimeout); clientConnect(FaceUri(ep, "ws").toString()); BOOST_REQUIRE_EQUAL(limitedIo.run(2, // serverHandleOpen, clientHandleOpen - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); face = make_unique( make_unique(), diff --git a/tests/daemon/face/websocket-transport.t.cpp b/tests/daemon/face/websocket-transport.t.cpp index 66a3d43f..657df719 100644 --- a/tests/daemon/face/websocket-transport.t.cpp +++ b/tests/daemon/face/websocket-transport.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -92,10 +92,10 @@ BOOST_AUTO_TEST_CASE(PersistencyChange) BOOST_FIXTURE_TEST_CASE_TEMPLATE(PingPong, T, WebSocketTransportFixtures, T) { - TRANSPORT_TEST_INIT(time::milliseconds(500), time::milliseconds(300)); + TRANSPORT_TEST_INIT(500_ms, 300_ms); BOOST_CHECK_EQUAL(this->limitedIo.run(2, // clientHandlePing, serverHandlePong - time::milliseconds(1500)), LimitedIo::EXCEED_OPS); + 1500_ms), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPings, 1); @@ -103,7 +103,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(PingPong, T, WebSocketTransportFixtures, T) this->clientShouldPong = false; BOOST_CHECK_EQUAL(this->limitedIo.run(2, // clientHandlePing, serverHandlePongTimeout - time::seconds(2)), LimitedIo::EXCEED_OPS); + 2_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_MESSAGE(this->transport->getState() == TransportState::FAILED || this->transport->getState() == TransportState::CLOSED, @@ -119,14 +119,14 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Send, T, WebSocketTransportFixtures, T) auto block1 = ndn::encoding::makeStringBlock(300, "hello"); this->transport->send(Transport::Packet{Block{block1}}); // make a copy of the block BOOST_CHECK_EQUAL(this->limitedIo.run(1, // clientHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPackets, 1); BOOST_CHECK_EQUAL(this->transport->getCounters().nOutBytes, block1.size()); auto block2 = ndn::encoding::makeStringBlock(301, "world"); this->transport->send(Transport::Packet{Block{block2}}); // make a copy of the block BOOST_CHECK_EQUAL(this->limitedIo.run(1, // clientHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPackets, 2); BOOST_CHECK_EQUAL(this->transport->getCounters().nOutBytes, block1.size() + block2.size()); @@ -149,12 +149,12 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveNormal, T, WebSocketTransportFixtures, T Block pkt1 = ndn::encoding::makeStringBlock(300, "hello"); this->client.send(this->clientHdl, pkt1.wire(), pkt1.size(), websocketpp::frame::opcode::binary); BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); Block pkt2 = ndn::encoding::makeStringBlock(301, "world!"); this->client.send(this->clientHdl, pkt2.wire(), pkt2.size(), websocketpp::frame::opcode::binary); BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(this->transport->getCounters().nInPackets, 2); BOOST_CHECK_EQUAL(this->transport->getCounters().nInBytes, pkt1.size() + pkt2.size()); @@ -175,7 +175,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveMalformed, T, WebSocketTransportFixtures this->client.send(this->clientHdl, pkt1.wire(), pkt1.size() - 1, // truncated websocketpp::frame::opcode::binary); BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); // bad packet is dropped BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); @@ -184,7 +184,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveMalformed, T, WebSocketTransportFixtures Block pkt2 = ndn::encoding::makeStringBlock(301, "world!"); this->client.send(this->clientHdl, pkt2.wire(), pkt2.size(), websocketpp::frame::opcode::binary); BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); // next valid packet is still received normally BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); @@ -242,7 +242,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, T, WebSocketTransportFixtures, T) this->client.close(this->clientHdl, websocketpp::close::status::going_away, ""); BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleClose - time::seconds(1)), LimitedIo::EXCEED_OPS); + 1_s), LimitedIo::EXCEED_OPS); BOOST_CHECK_EQUAL(nStateChanges, 2); } diff --git a/tests/daemon/fw/access-strategy.t.cpp b/tests/daemon/fw/access-strategy.t.cpp index d950fc22..afa73b6a 100644 --- a/tests/daemon/fw/access-strategy.t.cpp +++ b/tests/daemon/fw/access-strategy.t.cpp @@ -32,10 +32,8 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - // The tester is unused in this file, but it's used in various templated test suites. -typedef StrategyTester AccessStrategyTester; +using AccessStrategyTester = StrategyTester; NFD_REGISTER_STRATEGY(AccessStrategyTester); // This test suite tests AccessStrategy's behavior as a black box, @@ -73,8 +71,8 @@ protected: topo.setStrategy(router); - linkA = topo.addLink("RA", time::milliseconds(10), {router, laptopA}); - linkB = topo.addLink("RB", time::milliseconds(20), {router, laptopB}); + linkA = topo.addLink("RA", 10_ms, {router, laptopA}); + linkB = topo.addLink("RB", 20_ms, {router, laptopB}); } protected: @@ -124,10 +122,9 @@ BOOST_AUTO_TEST_CASE(OneProducer) topo.addEchoProducer(producer->getClientFace()); shared_ptr consumer = topo.addAppFace("c", router); - topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A", - time::milliseconds(100), 100); + topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A", 100_ms, 100); - this->advanceClocks(time::milliseconds(5), time::seconds(12)); + this->advanceClocks(5_ms, 12_s); // most Interests should be satisfied, and few Interests can go to wrong laptop BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97); @@ -171,10 +168,9 @@ BOOST_AUTO_TEST_CASE(FastSlowProducer) topo.addEchoProducer(producerB->getClientFace()); shared_ptr consumer = topo.addAppFace("c", router); - topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH", - time::milliseconds(100), 100); + topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH", 100_ms, 100); - this->advanceClocks(time::milliseconds(5), time::seconds(12)); + this->advanceClocks(5_ms, 12_s); // most Interests should be satisfied, and few Interests can go to slower laptopB BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97); @@ -218,12 +214,11 @@ BOOST_AUTO_TEST_CASE(ProducerMobility) topo.addEchoProducer(producerB->getClientFace()); shared_ptr consumer = topo.addAppFace("c", router); - topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M", - time::milliseconds(100), 100); + topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M", 100_ms, 100); // producer is initially on laptopA producerB->fail(); - this->advanceClocks(time::milliseconds(5), time::seconds(6)); + this->advanceClocks(5_ms, 6_s); // few Interests can go to laptopB BOOST_CHECK_LE(linkB->getFace(router).getCounters().nOutInterests, 5); @@ -232,7 +227,7 @@ BOOST_AUTO_TEST_CASE(ProducerMobility) producerA->fail(); producerB->recover(); PacketCounter::rep nInterestsToA_beforeMove = linkA->getFace(router).getCounters().nOutInterests; - this->advanceClocks(time::milliseconds(5), time::seconds(6)); + this->advanceClocks(5_ms, 6_s); // few additional Interests can go to laptopA BOOST_CHECK_LE(linkA->getFace(router).getCounters().nOutInterests - nInterestsToA_beforeMove, 5); @@ -274,13 +269,11 @@ BOOST_AUTO_TEST_CASE(Bidirectional) topo.addEchoProducer(producerB->getClientFace()); shared_ptr consumerAB = topo.addAppFace("cAB", laptopA); - topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B", - time::milliseconds(100), 100); + topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B", 100_ms, 100); shared_ptr consumerBA = topo.addAppFace("cBA", laptopB); - topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A", - time::milliseconds(100), 100); + topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A", 100_ms, 100); - this->advanceClocks(time::milliseconds(5), time::seconds(12)); + this->advanceClocks(5_ms, 12_s); // most Interests should be satisfied BOOST_CHECK_GE(consumerAB->getForwarderFace().getCounters().nOutData, 97); @@ -324,7 +317,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss) consumer->getClientFace().expressInterest(*interest1, bind([&hasData1] { hasData1 = true; }), nullptr, nullptr); - this->advanceClocks(time::milliseconds(5), time::seconds(1)); + this->advanceClocks(5_ms, 1_s); BOOST_CHECK_EQUAL(hasData1, true); // Interest 2 experiences a packet loss on initial transmission @@ -335,7 +328,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss) nullptr, bind([&hasTimeout2a] { hasTimeout2a = true; })); producerA->fail(); - this->advanceClocks(time::milliseconds(5), time::milliseconds(60)); + this->advanceClocks(5_ms, 60_ms); BOOST_CHECK_EQUAL(hasData2a, false); BOOST_CHECK_EQUAL(hasTimeout2a, false); @@ -346,7 +339,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss) bind([&hasData2b] { hasData2b = true; }), nullptr, nullptr); producerA->recover(); - this->advanceClocks(time::milliseconds(5), time::seconds(1)); + this->advanceClocks(5_ms, 1_s); BOOST_CHECK_EQUAL(hasData2b, false); // Interest 2 retransmission gets through, and is answered @@ -355,7 +348,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss) consumer->getClientFace().expressInterest(*interest2c, bind([&hasData2c] { hasData2c = true; }), nullptr, nullptr); - this->advanceClocks(time::milliseconds(5), time::seconds(1)); + this->advanceClocks(5_ms, 1_s); BOOST_CHECK_EQUAL(hasData2c, true); } @@ -367,10 +360,9 @@ BOOST_AUTO_TEST_CASE(Bug2831) // send Interests from laptopA to router shared_ptr consumer = topo.addAppFace("c", laptopA); - topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net", - time::milliseconds(100), 10); + topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net", 100_ms, 10); - this->advanceClocks(time::milliseconds(5), time::seconds(2)); + this->advanceClocks(5_ms, 2_s); // Interest shouldn't loop back from router BOOST_CHECK_EQUAL(linkA->getFace(router).getCounters().nOutInterests, 0); diff --git a/tests/daemon/fw/ad-hoc-forwarding.t.cpp b/tests/daemon/fw/ad-hoc-forwarding.t.cpp index 5ef50cfe..7ec07c7e 100644 --- a/tests/daemon/fw/ad-hoc-forwarding.t.cpp +++ b/tests/daemon/fw/ad-hoc-forwarding.t.cpp @@ -42,8 +42,6 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - template class AdHocForwardingFixture : public GlobalIoTimeFixture { @@ -58,7 +56,7 @@ protected: topo.setStrategy(node); } - auto wireless = topo.addLink("ABC", time::milliseconds(10), {nodeA, nodeB, nodeC}, + auto wireless = topo.addLink("ABC", 10_ms, {nodeA, nodeB, nodeC}, ndn::nfd::LINK_TYPE_AD_HOC); wireless->block(nodeA, nodeC); wireless->block(nodeC, nodeA); @@ -103,8 +101,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(SingleNexthop, S, Strategies, // B should relay Interest/Data between A and C. this->topo.registerPrefix(this->nodeB, *this->faceB, "/P"); - this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 10); - this->advanceClocks(time::milliseconds(5), time::milliseconds(1200)); + this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 10); + this->advanceClocks(5_ms, 1200_ms); // Consumer should receive Data, and B should be relaying. BOOST_CHECK_EQUAL(this->faceB->getCounters().nInInterests, 10); @@ -127,17 +125,17 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(SecondNexthop, S, Strategies, // B's first nexthop is D, but B-D link has failed, so B should relay Interest/Data between A and C. TopologyNode nodeD = this->topo.addForwarder("D"); - shared_ptr linkBD = this->topo.addLink("BD", time::milliseconds(5), {this->nodeB, nodeD}); + shared_ptr linkBD = this->topo.addLink("BD", 5_ms, {this->nodeB, nodeD}); this->topo.registerPrefix(this->nodeB, linkBD->getFace(this->nodeB), "/P", 5); linkBD->fail(); this->topo.registerPrefix(this->nodeB, *this->faceB, "/P", 10); // Two interval consumers are expressing Interests with same name 40ms apart, // so that Interests from the second interval consumer are considered retransmission. - this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 50, 1); - this->advanceClocks(time::milliseconds(5), time::milliseconds(40)); - this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", time::milliseconds(100), 50, 1); - this->advanceClocks(time::milliseconds(5), time::milliseconds(5400)); + this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 50, 1); + this->advanceClocks(5_ms, 40_ms); + this->topo.addIntervalConsumer(this->appA->getClientFace(), "/P", 100_ms, 50, 1); + this->advanceClocks(5_ms, 5400_ms); // Consumer should receive Data, and B should be relaying at least some Interest/Data. BOOST_CHECK_GE(this->faceB->getCounters().nInInterests, 50); diff --git a/tests/daemon/fw/algorithm.t.cpp b/tests/daemon/fw/algorithm.t.cpp index cb32efc8..96284f3e 100644 --- a/tests/daemon/fw/algorithm.t.cpp +++ b/tests/daemon/fw/algorithm.t.cpp @@ -216,7 +216,7 @@ BOOST_FIXTURE_TEST_CASE(GetLastOutgoing, GlobalIoTimeFixture) time::steady_clock::TimePoint before = time::steady_clock::now(); entry.insertOrUpdateOutRecord(*face1, 0, *interest); - this->advanceClocks(time::milliseconds(1000)); + this->advanceClocks(1_s); BOOST_CHECK_EQUAL(getLastOutgoing(entry), before); diff --git a/tests/daemon/fw/asf-measurements.t.cpp b/tests/daemon/fw/asf-measurements.t.cpp index a5fee3f6..d08f7614 100644 --- a/tests/daemon/fw/asf-measurements.t.cpp +++ b/tests/daemon/fw/asf-measurements.t.cpp @@ -50,7 +50,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, GlobalIoFixture) BOOST_CHECK_EQUAL(stats.getSrtt(), RttStats::RTT_NO_MEASUREMENT); // Receive Data back in 50ms - RttEstimator::Duration rtt(time::milliseconds(50)); + RttEstimator::Duration rtt(50_ms); stats.addRttMeasurement(rtt); BOOST_CHECK_EQUAL(stats.getRtt(), rtt); @@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, GlobalIoFixture) BOOST_CHECK_EQUAL(stats.getSrtt(), rtt); // Receive Data back with a higher RTT - RttEstimator::Duration higherRtt(time::milliseconds(100)); + RttEstimator::Duration higherRtt(100_ms); stats.addRttMeasurement(higherRtt); BOOST_CHECK_EQUAL(stats.getRtt(), higherRtt); @@ -105,7 +105,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, GlobalIoTimeFixture) pitEntry->insertOrUpdateOutRecord(*face, 0, *interest); RttEstimator::Duration rtt(50); - this->advanceClocks(time::milliseconds(5), rtt); + this->advanceClocks(5_ms, rtt); info.recordRtt(pitEntry, *face); info.cancelTimeoutEvent(interestName); diff --git a/tests/daemon/fw/asf-strategy.t.cpp b/tests/daemon/fw/asf-strategy.t.cpp index d363880f..27ed2aac 100644 --- a/tests/daemon/fw/asf-strategy.t.cpp +++ b/tests/daemon/fw/asf-strategy.t.cpp @@ -36,7 +36,7 @@ namespace tests { using namespace nfd::fw::tests; // The tester is unused in this file, but it's used in various templated test suites. -typedef StrategyTester AsfStrategyTester; +using AsfStrategyTester = StrategyTester; NFD_REGISTER_STRATEGY(AsfStrategyTester); BOOST_AUTO_TEST_SUITE(Fw) @@ -45,8 +45,9 @@ BOOST_FIXTURE_TEST_SUITE(TestAsfStrategy, GlobalIoTimeFixture) class AsfGridFixture : public GlobalIoTimeFixture { protected: - AsfGridFixture(Name parameters = AsfStrategy::getStrategyName()) - : parameters(parameters) + explicit + AsfGridFixture(const Name& params = AsfStrategy::getStrategyName()) + : parameters(params) { /* * +---------+ @@ -74,10 +75,10 @@ protected: topo.setStrategy(nodeC, Name("ndn:/"), parameters); topo.setStrategy(nodeD, Name("ndn:/"), parameters); - linkAB = topo.addLink("AB", time::milliseconds(10), {nodeA, nodeB}); - linkAD = topo.addLink("AD", time::milliseconds(100), {nodeA, nodeD}); - linkBC = topo.addLink("BC", time::milliseconds(10), {nodeB, nodeC}); - linkCD = topo.addLink("CD", time::milliseconds(100), {nodeC, nodeD}); + linkAB = topo.addLink("AB", 10_ms, {nodeA, nodeB}); + linkAD = topo.addLink("AD", 100_ms, {nodeA, nodeD}); + linkBC = topo.addLink("BC", 10_ms, {nodeB, nodeC}); + linkCD = topo.addLink("CD", 100_ms, {nodeC, nodeD}); consumer = topo.addAppFace("c", nodeA); producer = topo.addAppFace("p", nodeC, PRODUCER_PREFIX); @@ -91,8 +92,8 @@ protected: void runConsumer(int numInterests = 30) { - topo.addIntervalConsumer(consumer->getClientFace(), PRODUCER_PREFIX, time::seconds(1), numInterests); - this->advanceClocks(time::milliseconds(10), time::seconds(numInterests)); + topo.addIntervalConsumer(consumer->getClientFace(), PRODUCER_PREFIX, 1_s, numInterests); + this->advanceClocks(10_ms, time::seconds(numInterests)); } protected: @@ -160,7 +161,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, AsfGridFixture) linkAB->recover(); // Advance time to ensure probing is due - this->advanceClocks(time::milliseconds(10), time::seconds(10)); + this->advanceClocks(10_ms, 10_s); runConsumer(); @@ -229,10 +230,10 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce) topo.setStrategy(node); } - shared_ptr linkAB = topo.addLink("AB", time::milliseconds(15), {nodeA, nodeB}), - linkAC = topo.addLink("AC", time::milliseconds(14), {nodeA, nodeC}), - linkBC = topo.addLink("BC", time::milliseconds(16), {nodeB, nodeC}), - linkBD = topo.addLink("BD", time::milliseconds(80), {nodeB, nodeD}); + shared_ptr linkAB = topo.addLink("AB", 15_ms, {nodeA, nodeB}), + linkAC = topo.addLink("AC", 14_ms, {nodeA, nodeC}), + linkBC = topo.addLink("BC", 16_ms, {nodeB, nodeC}), + linkBD = topo.addLink("BD", 80_ms, {nodeB, nodeD}); shared_ptr ping = topo.addAppFace("c", nodeA), pingServer = topo.addAppFace("p", nodeD, PRODUCER_PREFIX); @@ -257,14 +258,8 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce) // Don't know when the probe will be triggered since it is random between 0-5 seconds // or whether it will be triggered for this interest - int j = 1; - while (linkAB->getFace(nodeA).getCounters().nOutInterests != 1) { - this->advanceClocks(time::milliseconds(1)); - ++j; - // Probe was not scheduled with this ping interest - if (j > 1000) { - break; - } + for (int j = 1; j <= 1000 && linkAB->getFace(nodeA).getCounters().nOutInterests != 1; ++j) { + this->advanceClocks(1_ms); } // Check if probe is sent to B else send another ping @@ -286,7 +281,7 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce) BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nOutInterests, i - 1); // After 15ms, B should get the probe interest - this->advanceClocks(time::milliseconds(1), time::milliseconds(15)); + this->advanceClocks(1_ms, 15_ms); BOOST_CHECK_EQUAL(linkAB->getFace(nodeB).getCounters().nInInterests, 1); BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nOutInterests, i); @@ -298,7 +293,7 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce) BOOST_CHECK(outRecord != pitEntry->out_end()); // RTT between B and D - this->advanceClocks(time::milliseconds(5), time::milliseconds(160)); + this->advanceClocks(5_ms, 160_ms); outRecord = pitEntry->getOutRecord(linkBD->getFace(nodeB), 0); BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nInData, i); @@ -308,7 +303,7 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce) // Data is returned for the ping after 15 ms - will result in false measurement // 14+16-15 = 15ms // Since outRecord == pitEntry->out_end() - this->advanceClocks(time::milliseconds(1), time::milliseconds(15)); + this->advanceClocks(1_ms, 15_ms); BOOST_CHECK_EQUAL(linkBD->getFace(nodeB).getCounters().nInData, i+1); break; @@ -352,7 +347,7 @@ BOOST_FIXTURE_TEST_CASE(ProbingInterval, AsfStrategyParametersGridFixture) // Send 6 interests let it change to use the 10 ms link runConsumer(6); - shared_ptr linkAC = topo.addLink("AC", time::milliseconds(5), {nodeA, nodeD}); + shared_ptr linkAC = topo.addLink("AC", 5_ms, {nodeA, nodeD}); topo.registerPrefix(nodeA, linkAC->getFace(nodeA), PRODUCER_PREFIX, 1); BOOST_CHECK_EQUAL(linkAC->getFace(nodeA).getCounters().nOutInterests, 0); diff --git a/tests/daemon/fw/best-route-strategy.t.cpp b/tests/daemon/fw/best-route-strategy.t.cpp index 7a2db756..b11cdae1 100644 --- a/tests/daemon/fw/best-route-strategy.t.cpp +++ b/tests/daemon/fw/best-route-strategy.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2016, Regents of the University of California, +/* + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -32,10 +32,8 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - // The tester is unused in this file, but it's used in various templated test suites. -typedef StrategyTester BestRouteStrategyTester; +using BestRouteStrategyTester = StrategyTester; NFD_REGISTER_STRATEGY(BestRouteStrategyTester); } // namespace tests diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp index 4101464a..5776f6cd 100644 --- a/tests/daemon/fw/best-route-strategy2.t.cpp +++ b/tests/daemon/fw/best-route-strategy2.t.cpp @@ -34,9 +34,7 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - -typedef StrategyTester BestRouteStrategy2Tester; +using BestRouteStrategy2Tester = StrategyTester; NFD_REGISTER_STRATEGY(BestRouteStrategy2Tester); BOOST_AUTO_TEST_SUITE(Fw) diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp index 8e3bae3c..59b5ef3c 100644 --- a/tests/daemon/fw/forwarder.t.cpp +++ b/tests/daemon/fw/forwarder.t.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(SimpleExchange) Forwarder forwarder; shared_ptr interestAB = makeInterest("/A/B"); - interestAB->setInterestLifetime(time::seconds(4)); + interestAB->setInterestLifetime(4_s); shared_ptr dataABC = makeData("/A/B/C"); auto face1 = make_shared(); @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(SimpleExchange) BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0); BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0); face1->receiveInterest(*interestAB); - this->advanceClocks(time::milliseconds(100), time::seconds(1)); + this->advanceClocks(100_ms, 1_s); BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1); BOOST_CHECK_EQUAL(face2->sentInterests[0].getName(), "/A/B"); BOOST_REQUIRE(face2->sentInterests[0].getTag() != nullptr); @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(SimpleExchange) BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 0); BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 0); face2->receiveData(*dataABC); - this->advanceClocks(time::milliseconds(100), time::seconds(1)); + this->advanceClocks(100_ms, 1_s); BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1); BOOST_CHECK_EQUAL(face1->sentData[0].getName(), "/A/B/C"); BOOST_REQUIRE(face1->sentData[0].getTag() != nullptr); @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(CsMatched) forwarder.addFace(face3); shared_ptr interestA = makeInterest("/A"); - interestA->setInterestLifetime(time::seconds(4)); + interestA->setInterestLifetime(4_s); shared_ptr dataA = makeData("/A"); dataA->setTag(make_shared(face3->getId())); @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(CsMatched) BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0); BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0); face1->receiveInterest(*interestA); - this->advanceClocks(time::milliseconds(1), time::milliseconds(5)); + this->advanceClocks(1_ms, 5_ms); // Interest matching ContentStore should not be forwarded BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 0); BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 1); @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(CsMatched) BOOST_REQUIRE(face1->sentData[0].getTag() != nullptr); BOOST_CHECK_EQUAL(*face1->sentData[0].getTag(), face::FACEID_CONTENT_STORE); - this->advanceClocks(time::milliseconds(100), time::milliseconds(500)); + this->advanceClocks(100_ms, 500_ms); // PIT entry should not be left behind BOOST_CHECK_EQUAL(pit.size(), 0); } @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(NextHopFaceId) interest->setTag(make_shared(face2->getId())); face1->receiveInterest(*interest); - this->advanceClocks(time::milliseconds(100), time::seconds(1)); + this->advanceClocks(100_ms, 1_s); BOOST_CHECK_EQUAL(face3->sentInterests.size(), 0); BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1); BOOST_CHECK_EQUAL(face2->sentInterests.front().getName(), "/A/B"); @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(IncomingInterestStrategyDispatch) forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest2); BOOST_CHECK_EQUAL(strategyB.afterReceiveInterest_count, 1); - this->advanceClocks(time::milliseconds(1), time::milliseconds(5)); + this->advanceClocks(1_ms, 5_ms); shared_ptr data1 = makeData("ndn:/A/1/a"); strategyA.beforeSatisfyInterest_count = 0; @@ -295,10 +295,10 @@ BOOST_AUTO_TEST_CASE(IncomingInterestStrategyDispatch) BOOST_CHECK_EQUAL(strategyB.beforeSatisfyInterest_count, 1); shared_ptr interest3 = makeInterest("ndn:/A/3"); - interest3->setInterestLifetime(time::milliseconds(30)); + interest3->setInterestLifetime(30_ms); forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest3); shared_ptr interest4 = makeInterest("ndn:/B/4"); - interest4->setInterestLifetime(time::milliseconds(5000)); + interest4->setInterestLifetime(5_s); forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest4); } @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(IncomingData) shared_ptr dataD = makeData("ndn:/A/B/C/D"); forwarder.onIncomingData(FaceEndpoint(*face3, 0), *dataD); - this->advanceClocks(time::milliseconds(1), time::milliseconds(5)); + this->advanceClocks(1_ms, 5_ms); BOOST_CHECK_EQUAL(face1->sentData.size(), 1); BOOST_CHECK_EQUAL(face2->sentData.size(), 1); @@ -557,12 +557,12 @@ BOOST_AUTO_TEST_CASE(InterestLoopWithShortLifetime) // Bug 1953 // receive an Interest shared_ptr interest = makeInterest("ndn:/A/1"); interest->setNonce(82101183); - interest->setInterestLifetime(time::milliseconds(50)); + interest->setInterestLifetime(50_ms); face1->receiveInterest(*interest); // interest should be forwarded only once, as long as Nonce is in Dead Nonce List - BOOST_ASSERT(time::milliseconds(25) * 40 < forwarder.getDeadNonceList().getLifetime()); - this->advanceClocks(time::milliseconds(25), 40); + BOOST_ASSERT(25_ms * 40 < forwarder.getDeadNonceList().getLifetime()); + this->advanceClocks(25_ms, 40); BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1); @@ -581,7 +581,7 @@ BOOST_AUTO_TEST_CASE(PitLeak) // Bug 3484 shared_ptr interest = makeInterest("ndn:/hcLSAsQ9A"); interest->setNonce(61883075); - interest->setInterestLifetime(time::seconds(2)); + interest->setInterestLifetime(2_s); DeadNonceList& dnl = forwarder.getDeadNonceList(); dnl.add(interest->getName(), interest->getNonce()); @@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE(PitLeak) // Bug 3484 BOOST_REQUIRE_EQUAL(pit.size(), 0); forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest); - this->advanceClocks(time::milliseconds(100), time::seconds(20)); + this->advanceClocks(100_ms, 20_s); BOOST_CHECK_EQUAL(pit.size(), 0); } diff --git a/tests/daemon/fw/forwarding-hint.t.cpp b/tests/daemon/fw/forwarding-hint.t.cpp index e37c267c..7e9dbdcb 100644 --- a/tests/daemon/fw/forwarding-hint.t.cpp +++ b/tests/daemon/fw/forwarding-hint.t.cpp @@ -77,12 +77,12 @@ public: topo.getForwarder(nodeS).getNetworkRegionTable().insert("/ucla/cs/spurs"); // NetworkRegionTable configuration is unnecessary on end hosts - linkAH = topo.addLink("AH", time::milliseconds(10), {nodeA, nodeH}); - linkHT = topo.addLink("HT", time::milliseconds(10), {nodeH, nodeT}); - linkTP = topo.addLink("TP", time::milliseconds(10), {nodeT, nodeP}); - linkHC = topo.addLink("HC", time::milliseconds(10), {nodeH, nodeC}); - linkCS = topo.addLink("CS", time::milliseconds(10), {nodeC, nodeS}); - linkSQ = topo.addLink("SQ", time::milliseconds(10), {nodeS, nodeQ}); + linkAH = topo.addLink("AH", 10_ms, {nodeA, nodeH}); + linkHT = topo.addLink("HT", 10_ms, {nodeH, nodeT}); + linkTP = topo.addLink("TP", 10_ms, {nodeT, nodeP}); + linkHC = topo.addLink("HC", 10_ms, {nodeH, nodeC}); + linkCS = topo.addLink("CS", 10_ms, {nodeC, nodeS}); + linkSQ = topo.addLink("SQ", 10_ms, {nodeS, nodeQ}); consumerA = topo.addAppFace("avenir", nodeA); producerP = topo.addAppFace("ndnsimP", nodeP, "/net/ndnsim"); producerQ = topo.addAppFace("ndnsimQ", nodeQ, "/net/ndnsim"); @@ -123,7 +123,7 @@ BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture BOOST_AUTO_TEST_CASE(FetchTelia) { this->consumerExpressInterest(1); - this->advanceClocks(time::milliseconds(11), 20); + this->advanceClocks(11_ms, 20); // A forwards Interest according to default route, no change to forwarding hint BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1); @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(FetchUcla) topo.getForwarder(nodeH).getFib().erase("/telia"); this->consumerExpressInterest(1); - this->advanceClocks(time::milliseconds(11), 20); + this->advanceClocks(11_ms, 20); // A forwards Interest according to default route, no change to forwarding hint BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1); diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp index a6d9be62..e1c40271 100644 --- a/tests/daemon/fw/multicast-strategy.t.cpp +++ b/tests/daemon/fw/multicast-strategy.t.cpp @@ -34,9 +34,7 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - -typedef StrategyTester MulticastStrategyTester; +using MulticastStrategyTester = StrategyTester; NFD_REGISTER_STRATEGY(MulticastStrategyTester); class MulticastStrategyFixture : public GlobalIoTimeFixture diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp index 86238af7..d7172e31 100644 --- a/tests/daemon/fw/ncc-strategy.t.cpp +++ b/tests/daemon/fw/ncc-strategy.t.cpp @@ -33,9 +33,7 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - -typedef StrategyTester NccStrategyTester; +using NccStrategyTester = StrategyTester; NFD_REGISTER_STRATEGY(NccStrategyTester); BOOST_AUTO_TEST_SUITE(Fw) @@ -69,7 +67,7 @@ BOOST_AUTO_TEST_CASE(FavorRespondingUpstream) // first Interest: strategy knows nothing and follows routing shared_ptr interest1p = makeInterest("ndn:/0Jm1ajrW/%00"); Interest& interest1 = *interest1p; - interest1.setInterestLifetime(time::milliseconds(8000)); + interest1.setInterestLifetime(8_s); shared_ptr pitEntry1 = pit.insert(interest1).first; pitEntry1->insertOrUpdateInRecord(*face3, 0, interest1); @@ -81,7 +79,7 @@ BOOST_AUTO_TEST_CASE(FavorRespondingUpstream) BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId()); // forwards to face2 because face1 doesn't respond - limitedIo.run(1, time::milliseconds(500), time::milliseconds(10)); + limitedIo.run(1, 500_ms, 10_ms); BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId()); @@ -89,19 +87,19 @@ BOOST_AUTO_TEST_CASE(FavorRespondingUpstream) shared_ptr data1p = makeData("ndn:/0Jm1ajrW/%00"); Data& data1 = *data1p; strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), data1); - this->advanceClocks(time::milliseconds(10), time::milliseconds(500)); + this->advanceClocks(10_ms, 500_ms); // second Interest: strategy knows face2 is best shared_ptr interest2p = makeInterest("ndn:/0Jm1ajrW/%00%01"); Interest& interest2 = *interest2p; - interest2.setInterestLifetime(time::milliseconds(8000)); + interest2.setInterestLifetime(8_s); shared_ptr pitEntry2 = pit.insert(interest2).first; pitEntry2->insertOrUpdateInRecord(*face3, 0, interest2); strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), interest2, pitEntry2); // forwards to face2 because it responds previously - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face2->getId()); } @@ -126,25 +124,25 @@ BOOST_AUTO_TEST_CASE(Bug1853) // first Interest: strategy follows routing and forwards to face1 shared_ptr interest1 = makeInterest("ndn:/nztwIvHX/%00"); - interest1->setInterestLifetime(time::milliseconds(8000)); + interest1->setInterestLifetime(8_s); shared_ptr pitEntry1 = pit.insert(*interest1).first; pitEntry1->insertOrUpdateInRecord(*face3, 0, *interest1); strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest1, pitEntry1); - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId()); // face1 responds shared_ptr data1 = makeData("ndn:/nztwIvHX/%00"); strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face1, 0), *data1); - this->advanceClocks(time::milliseconds(10), time::milliseconds(500)); + this->advanceClocks(10_ms, 500_ms); // second Interest: bestFace is face1, nUpstreams becomes 0, // therefore pitEntryInfo->maxInterval cannot be calculated from deferRange and nUpstreams shared_ptr interest2 = makeInterest("ndn:/nztwIvHX/%01"); - interest2->setInterestLifetime(time::milliseconds(8000)); + interest2->setInterestLifetime(8_s); shared_ptr pitEntry2 = pit.insert(*interest2).first; pitEntry2->insertOrUpdateInRecord(*face3, 0, *interest2); @@ -152,7 +150,7 @@ BOOST_AUTO_TEST_CASE(Bug1853) // FIB entry is changed before doPropagate executes fibEntry.addOrUpdateNextHop(*face2, 0, 20); - this->advanceClocks(time::milliseconds(10), time::milliseconds(1000));// should not crash + this->advanceClocks(10_ms, 1_s);// should not crash } BOOST_AUTO_TEST_CASE(Bug1961) @@ -178,13 +176,12 @@ BOOST_AUTO_TEST_CASE(Bug1961) // first Interest: strategy forwards to face1 and face2 shared_ptr interest1 = makeInterest("ndn:/seRMz5a6/%00"); - interest1->setInterestLifetime(time::milliseconds(2000)); + interest1->setInterestLifetime(2_s); shared_ptr pitEntry1 = pit.insert(*interest1).first; pitEntry1->insertOrUpdateInRecord(*face3, 0, *interest1); strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest1, pitEntry1); - limitedIo.run(2 - strategy.sendInterestHistory.size(), - time::milliseconds(2000), time::milliseconds(10)); + limitedIo.run(2 - strategy.sendInterestHistory.size(), 2_s, 10_ms); BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId()); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId()); @@ -193,20 +190,19 @@ BOOST_AUTO_TEST_CASE(Bug1961) shared_ptr data1 = makeData("ndn:/seRMz5a6/%00"); strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face1, 0), *data1); pitEntry1->clearInRecords(); - this->advanceClocks(time::milliseconds(10)); + this->advanceClocks(10_ms); // face2 also responds strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), *data1); - this->advanceClocks(time::milliseconds(10)); + this->advanceClocks(10_ms); // second Interest: bestFace should be face 1 shared_ptr interest2 = makeInterest("ndn:/seRMz5a6/%01"); - interest2->setInterestLifetime(time::milliseconds(2000)); + interest2->setInterestLifetime(2_s); shared_ptr pitEntry2 = pit.insert(*interest2).first; pitEntry2->insertOrUpdateInRecord(*face3, 0, *interest2); strategy.afterReceiveInterest(FaceEndpoint(*face3, 0), *interest2, pitEntry2); - limitedIo.run(3 - strategy.sendInterestHistory.size(), - time::milliseconds(2000), time::milliseconds(10)); + limitedIo.run(3 - strategy.sendInterestHistory.size(), 2_s, 10_ms); BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face1->getId()); @@ -232,29 +228,27 @@ BOOST_AUTO_TEST_CASE(Bug1971) // first Interest: strategy forwards to face2 shared_ptr interest1 = makeInterest("ndn:/M4mBXCsd"); - interest1->setInterestLifetime(time::milliseconds(2000)); + interest1->setInterestLifetime(2_s); shared_ptr pitEntry1 = pit.insert(*interest1).first; pitEntry1->insertOrUpdateInRecord(*face1, 0, *interest1); strategy.afterReceiveInterest(FaceEndpoint(*face1, 0), *interest1, pitEntry1); - limitedIo.run(1 - strategy.sendInterestHistory.size(), - time::milliseconds(2000), time::milliseconds(10)); + limitedIo.run(1 - strategy.sendInterestHistory.size(), 2_s, 10_ms); BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId()); // face2 responds shared_ptr data1 = makeData("ndn:/M4mBXCsd"); - data1->setFreshnessPeriod(time::milliseconds(5)); + data1->setFreshnessPeriod(5_ms); strategy.beforeSatisfyInterest(pitEntry1, FaceEndpoint(*face2, 0), *data1); pitEntry1->deleteOutRecord(*face2, 0); pitEntry1->clearInRecords(); - this->advanceClocks(time::milliseconds(10)); + this->advanceClocks(10_ms); // similar Interest: strategy should still forward it pitEntry1->insertOrUpdateInRecord(*face1, 0, *interest1); strategy.afterReceiveInterest(FaceEndpoint(*face1, 0), *interest1, pitEntry1); - limitedIo.run(2 - strategy.sendInterestHistory.size(), - time::milliseconds(2000), time::milliseconds(10)); + limitedIo.run(2 - strategy.sendInterestHistory.size(), 2_s, 10_ms); BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2); BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId()); } @@ -323,10 +317,10 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 topo.setStrategy(node); } - shared_ptr linkAB = topo.addLink("AB", time::milliseconds( 5), {nodeA, nodeB}), - linkAC = topo.addLink("AC", time::milliseconds( 5), {nodeA, nodeC}), - linkBD = topo.addLink("BD", time::milliseconds(15), {nodeB, nodeD}), - linkCD = topo.addLink("CD", time::milliseconds(15), {nodeC, nodeD}); + shared_ptr linkAB = topo.addLink("AB", 5_ms, {nodeA, nodeB}), + linkAC = topo.addLink("AC", 5_ms, {nodeA, nodeC}), + linkBD = topo.addLink("BD", 15_ms, {nodeB, nodeD}), + linkCD = topo.addLink("CD", 15_ms, {nodeC, nodeD}); topo.registerPrefix(nodeA, linkAB->getFace(nodeA), "ndn:/P"); topo.registerPrefix(nodeA, linkAC->getFace(nodeA), "ndn:/P"); @@ -338,7 +332,7 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 shared_ptr consumer = topo.addAppFace("consumer", nodeA); topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/P", - time::milliseconds(100), 300); + 100_ms, 300); auto getMeInfo = [&] () -> NccStrategy::MeasurementsEntryInfo* { Measurements& measurements = topo.getForwarder(nodeA).getMeasurements(); @@ -353,7 +347,7 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 bool isLastPredictionUnder = true; int nPredictionCrossings = 0; for (int i = 0; i < 10000; ++i) { - this->advanceClocks(time::milliseconds(5)); + this->advanceClocks(5_ms); auto meInfo = getMeInfo(); if (meInfo == nullptr) { continue; @@ -369,7 +363,7 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 } } } - BOOST_REQUIRE_MESSAGE(isExplorationFinished, "exploration does not finish in 50000ms"); + BOOST_REQUIRE_MESSAGE(isExplorationFinished, "exploration did not finish within 50s"); // NccStrategy has selected one path as the best. // When we reduce the RTT of the other path, ideally it should be selected as the best face. @@ -377,10 +371,10 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 // See https://redmine.named-data.net/issues/3411#note-4 shared_ptr bestFace1 = getMeInfo()->bestFace.lock(); if (bestFace1.get() == &linkAB->getFace(nodeA)) { - linkCD->setDelay(time::milliseconds(5)); + linkCD->setDelay(5_ms); } else if (bestFace1.get() == &linkAC->getFace(nodeA)) { - linkBD->setDelay(time::milliseconds(5)); + linkBD->setDelay(5_ms); } else { BOOST_FAIL("unexpected best face"); @@ -388,7 +382,7 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411 bool isNewBestChosen = false; for (int i = 0; i < 10000; ++i) { - this->advanceClocks(time::milliseconds(5)); + this->advanceClocks(5_ms); auto meInfo = getMeInfo(); if (meInfo == nullptr) { continue; diff --git a/tests/daemon/fw/retx-suppression.t.cpp b/tests/daemon/fw/retx-suppression.t.cpp index a0aab025..de4c2066 100644 --- a/tests/daemon/fw/retx-suppression.t.cpp +++ b/tests/daemon/fw/retx-suppression.t.cpp @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(Exponential) { Forwarder forwarder; Pit& pit = forwarder.getPit(); - RetxSuppressionExponential rs(time::milliseconds(10), 3.0, time::milliseconds(100)); + RetxSuppressionExponential rs(10_ms, 3.0, 100_ms); shared_ptr face1 = make_shared(); shared_ptr face2 = make_shared(); @@ -109,12 +109,12 @@ BOOST_AUTO_TEST_CASE(Exponential) pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest); // suppression interval is 10ms, until 10ms - this->advanceClocks(time::milliseconds(5)); // @ 5ms + this->advanceClocks(5_ms); // @ 5ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS); // suppression interval is 10ms, until 10ms - this->advanceClocks(time::milliseconds(6)); // @ 11ms + this->advanceClocks(6_ms); // @ 11ms // note: what happens at *exactly* 10ms does not matter so it's untested, // because in reality network timing won't be exact: // incoming Interest is processed either before or after 10ms point @@ -123,34 +123,34 @@ BOOST_AUTO_TEST_CASE(Exponential) pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest); // suppression interval is 30ms, until 41ms - this->advanceClocks(time::milliseconds(25)); // @ 36ms + this->advanceClocks(25_ms); // @ 36ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS); // suppression interval is 30ms, until 41ms - this->advanceClocks(time::milliseconds(6)); // @ 42ms + this->advanceClocks(6_ms); // @ 42ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD); // strategy decides not to forward, but suppression interval is increased nevertheless // suppression interval is 90ms, until 101ms - this->advanceClocks(time::milliseconds(58)); // @ 100ms + this->advanceClocks(58_ms); // @ 100ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS); // suppression interval is 90ms, until 101ms - this->advanceClocks(time::milliseconds(3)); // @ 103ms + this->advanceClocks(3_ms); // @ 103ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD); pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest); // suppression interval is 100ms, until 203ms - this->advanceClocks(time::milliseconds(99)); // @ 202ms + this->advanceClocks(99_ms); // @ 202ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::SUPPRESS); // suppression interval is 100ms, until 203ms - this->advanceClocks(time::milliseconds(2)); // @ 204ms + this->advanceClocks(2_ms); // @ 204ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerPitEntry(*pitEntry) == RetxSuppressionResult::FORWARD); pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest); @@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(ExponentialPerUpstream) { Forwarder forwarder; Pit& pit = forwarder.getPit(); - RetxSuppressionExponential rs(time::milliseconds(10), 3.0, time::milliseconds(100)); + RetxSuppressionExponential rs(10_ms, 3.0, 100_ms); shared_ptr face1 = make_shared(); shared_ptr face2 = make_shared(); @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(ExponentialPerUpstream) // Simluate forwarding an interest to face2 pitEntry->insertOrUpdateOutRecord(*face2, 0, *interest); - this->advanceClocks(time::milliseconds(5)); // @ 5ms + this->advanceClocks(5_ms); // @ 5ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face2) == RetxSuppressionResult::SUPPRESS); @@ -186,7 +186,7 @@ BOOST_AUTO_TEST_CASE(ExponentialPerUpstream) pitEntry->insertOrUpdateInRecord(*face2, 0, *interest); BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face1) == RetxSuppressionResult::NEW); - this->advanceClocks(time::milliseconds(6)); // @ 11ms + this->advanceClocks(6_ms); // @ 11ms pitEntry->insertOrUpdateInRecord(*face1, 0, *interest); BOOST_CHECK(rs.decidePerUpstream(*pitEntry, *face2) == RetxSuppressionResult::FORWARD); diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp index 2708710a..c9a66c2b 100644 --- a/tests/daemon/fw/strategy-nack-return.t.cpp +++ b/tests/daemon/fw/strategy-nack-return.t.cpp @@ -42,8 +42,6 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - BOOST_AUTO_TEST_SUITE(Fw) template @@ -168,17 +166,17 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Timeout, fibEntry.addOrUpdateNextHop(*this->face5, 0, 30); shared_ptr interest1 = makeInterest("/sIYw0TXWDj", 115); - interest1->setInterestLifetime(time::milliseconds(400)); + interest1->setInterestLifetime(400_ms); shared_ptr pitEntry = this->pit.insert(*interest1).first; pitEntry->insertOrUpdateInRecord(*this->face1, 0, *interest1); pitEntry->insertOrUpdateOutRecord(*this->face3, 0, *interest1); - this->advanceClocks(time::milliseconds(300)); + this->advanceClocks(300_ms); shared_ptr interest2 = makeInterest("/sIYw0TXWDj", 223); pitEntry->insertOrUpdateInRecord(*this->face1, 0, *interest2); pitEntry->insertOrUpdateOutRecord(*this->face4, 0, *interest2); - this->advanceClocks(time::milliseconds(200)); // face3 has timed out + this->advanceClocks(200_ms); // face3 has timed out lp::Nack nack4 = makeNack("/sIYw0TXWDj", 223, lp::NackReason::CONGESTION); pitEntry->getOutRecord(*this->face4, 0)->setIncomingNack(nack4); @@ -257,12 +255,12 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LiveDeadlock, ndn::Face& appD = topo.addAppFace("D", nodeD)->getClientFace(); int nNacksA = 0, nNacksD = 0; - appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA]{ ++nNacksA; }), nullptr); - appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD]{ ++nNacksD; }), nullptr); - this->advanceClocks(time::milliseconds(1), time::milliseconds(5)); - appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA]{ ++nNacksA; }), nullptr); - appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD]{ ++nNacksD; }), nullptr); - this->advanceClocks(time::milliseconds(1), time::milliseconds(100)); + appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr); + appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr); + this->advanceClocks(1_ms, 5_ms); + appA.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr); + appD.expressInterest(Interest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr); + this->advanceClocks(1_ms, 100_ms); // As long as at least one Nack arrives at each client, strategy behavior is correct. // Whether both Interests are Nacked is a client face behavior, not strategy behavior. diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp index daf3f2a3..43c57d0c 100644 --- a/tests/daemon/fw/strategy-no-route.t.cpp +++ b/tests/daemon/fw/strategy-no-route.t.cpp @@ -46,8 +46,6 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - template class StrategyNoRouteFixture : public GlobalIoTimeFixture { diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp index 29808347..4b83e469 100644 --- a/tests/daemon/fw/strategy-scope-control.t.cpp +++ b/tests/daemon/fw/strategy-scope-control.t.cpp @@ -47,8 +47,6 @@ namespace nfd { namespace fw { namespace tests { -using namespace nfd::tests; - template class StrategyScopeControlFixture : public GlobalIoTimeFixture { diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp index f2ac93d2..3ddf8f66 100644 --- a/tests/daemon/fw/strategy-tester.hpp +++ b/tests/daemon/fw/strategy-tester.hpp @@ -34,14 +34,16 @@ namespace nfd { namespace fw { namespace tests { -/** \brief extends strategy S for unit testing +using namespace nfd::tests; + +/** \brief Extends strategy S for unit testing. * - * Actions invoked by S are recorded but not passed to forwarder + * Actions invoked by S are recorded but not passed to forwarder. * * StrategyTester should be registered into the strategy registry prior to use. * \code * // appears in or included by every .cpp MyStrategyTester is used - * typedef StrategyTester MyStrategyTester; + * using MyStrategyTester = StrategyTester; * * // appears in only one .cpp * NFD_REGISTER_STRATEGY(MyStrategyTester); @@ -82,9 +84,9 @@ public: * \note The actions may occur either during f() invocation or afterwards. * \return whether expected number of actions have occurred */ + template bool - waitForAction(const std::function& f, - nfd::tests::LimitedIo& limitedIo, int nExpectedActions = 1) + waitForAction(F&& f, LimitedIo& limitedIo, int nExpectedActions = 1) { int nActions = 0; @@ -99,8 +101,7 @@ public: // A correctly implemented strategy is required to invoke reject pending Interest action if it // decides to not forward an Interest. If a test case is stuck in the call below, check that // rejectPendingInterest is invoked under proper condition. - return limitedIo.run(nExpectedActions - nActions, nfd::tests::LimitedIo::UNLIMITED_TIME) == - nfd::tests::LimitedIo::EXCEED_OPS; + return limitedIo.run(nExpectedActions - nActions, LimitedIo::UNLIMITED_TIME) == LimitedIo::EXCEED_OPS; } return nActions == nExpectedActions; } diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp index 1002e446..5d61168b 100644 --- a/tests/daemon/mgmt/fib-manager.t.cpp +++ b/tests/daemon/mgmt/fib-manager.t.cpp @@ -65,7 +65,7 @@ public: // for test { auto face = make_shared(); m_faceTable.add(face); - advanceClocks(time::milliseconds(1), 10); + advanceClocks(1_ms, 10); m_responses.clear(); // clear all event notifications, if any return face->getId(); } diff --git a/tests/daemon/mgmt/forwarder-status-manager.t.cpp b/tests/daemon/mgmt/forwarder-status-manager.t.cpp index bb728f27..e40e20d4 100644 --- a/tests/daemon/mgmt/forwarder-status-manager.t.cpp +++ b/tests/daemon/mgmt/forwarder-status-manager.t.cpp @@ -53,7 +53,7 @@ BOOST_FIXTURE_TEST_SUITE(TestForwarderStatusManager, ForwarderStatusManagerFixtu BOOST_AUTO_TEST_CASE(GeneralStatusDataset) { // cause counters to be non-zero - this->advanceClocks(time::seconds(3600)); + this->advanceClocks(1_h); m_forwarder.getFib().insert("ndn:/fib1"); m_forwarder.getPit().insert(*makeInterest("ndn:/pit1")); m_forwarder.getPit().insert(*makeInterest("ndn:/pit2")); diff --git a/tests/daemon/mgmt/manager-base.t.cpp b/tests/daemon/mgmt/manager-base.t.cpp index 3aeeb9eb..0dace4eb 100644 --- a/tests/daemon/mgmt/manager-base.t.cpp +++ b/tests/daemon/mgmt/manager-base.t.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(RegisterNotificationStream) const uint8_t buf[] = {0x82, 0x01, 0x02}; post(Block(buf, sizeof(buf))); - advanceClocks(time::milliseconds(1)); + advanceClocks(1_ms); BOOST_REQUIRE_EQUAL(m_responses.size(), 1); BOOST_CHECK_EQUAL(m_responses[0].getName(), diff --git a/tests/daemon/rib/fib-updates-common.hpp b/tests/daemon/rib/fib-updates-common.hpp index 77348be2..9afd4a5c 100644 --- a/tests/daemon/rib/fib-updates-common.hpp +++ b/tests/daemon/rib/fib-updates-common.hpp @@ -38,30 +38,9 @@ namespace nfd { namespace rib { namespace tests { -inline bool -compareNameFaceIdCostAction(const FibUpdate& lhs, const FibUpdate& rhs) -{ - if (lhs.name < rhs.name) { - return true; - } - else if (lhs.name == rhs.name) { - if (lhs.faceId < rhs.faceId) { - return true; - } - else if (lhs.faceId == rhs.faceId) { - if (lhs.cost < rhs.cost) { - return true; - } - else if (lhs.cost == rhs.cost) { - return lhs.action < rhs.action; - } - } - } +using namespace nfd::tests; - return false; -} - -class FibUpdatesFixture : public nfd::tests::GlobalIoFixture, public nfd::tests::KeyChainFixture +class FibUpdatesFixture : public GlobalIoFixture, public KeyChainFixture { public: FibUpdatesFixture() @@ -125,7 +104,10 @@ public: getSortedFibUpdates() { FibUpdater::FibUpdateList updates = getFibUpdates(); - updates.sort(&compareNameFaceIdCostAction); + updates.sort([] (const auto& lhs, const auto& rhs) { + return std::tie(lhs.name, lhs.faceId, lhs.cost, lhs.action) < + std::tie(rhs.name, rhs.faceId, rhs.cost, rhs.action); + }); return updates; } diff --git a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp index 94120c00..494eac2d 100644 --- a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp +++ b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp @@ -96,16 +96,16 @@ BOOST_AUTO_TEST_CASE(DontReadvertise) BOOST_AUTO_TEST_CASE(LoadRefreshInterval) { auto policy = makePolicy(); - BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // default setting is 25 + BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 25_s); // default setting is 25 ConfigSection section; section.put("refresh_interval_wrong", 10); policy = makePolicy(section); - BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // wrong formate + BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 25_s); // wrong formate section.put("refresh_interval", 10); policy = makePolicy(section); - BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(10)); + BOOST_CHECK_EQUAL(policy->getRefreshInterval(), 10_s); } BOOST_AUTO_TEST_SUITE_END() // TestHostToGatewayReadvertisePolicy diff --git a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp index 690a53b9..5a64bbea 100644 --- a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp +++ b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Advertise, Scenario, AdvertiseScenarios) const Name RIB_REGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/register"); dest.advertise(rr, successCallback, failureCallback); - advanceClocks(time::milliseconds(100)); + advanceClocks(100_ms); // Retrieve the sent Interest to build the response BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Advertise, Scenario, AdvertiseScenarios) auto responseData = makeData(sentInterest.getName()); responseData->setContent(responsePayload.wireEncode()); face.receive(*responseData); - this->advanceClocks(time::milliseconds(10)); + this->advanceClocks(10_ms); scenario.checkCommandOutcome(this); } @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Withdraw, Scenario, WithdrawScenarios) const Name RIB_UNREGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/unregister"); dest.withdraw(rr, successCallback, failureCallback); - this->advanceClocks(time::milliseconds(10)); + this->advanceClocks(10_ms); // Retrieve the sent Interest to build the response BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Withdraw, Scenario, WithdrawScenarios) responseData->setContent(responsePayload.wireEncode()); face.receive(*responseData); - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); scenario.checkCommandOutcome(this); } @@ -236,13 +236,13 @@ BOOST_AUTO_TEST_CASE(DestinationAvailability) BOOST_CHECK_EQUAL(dest.isAvailable(), false); rib.insert(commandPrefix, route); - this->advanceClocks(time::milliseconds(100)); + this->advanceClocks(100_ms); BOOST_CHECK_EQUAL(dest.isAvailable(), true); BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 1); BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), true); rib.erase(commandPrefix, route); - this->advanceClocks(time::milliseconds(100)); + this->advanceClocks(100_ms); BOOST_CHECK_EQUAL(dest.isAvailable(), false); BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 2); BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), false); diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp index 090bd5a1..1988a203 100644 --- a/tests/daemon/rib/readvertise/readvertise.t.cpp +++ b/tests/daemon/rib/readvertise/readvertise.t.cpp @@ -133,7 +133,7 @@ public: route.faceId = faceId; route.origin = origin; m_rib.insert(prefix, route); - this->advanceClocks(time::milliseconds(6)); + this->advanceClocks(6_ms); } void @@ -143,14 +143,14 @@ public: route.faceId = faceId; route.origin = origin; m_rib.erase(prefix, route); - this->advanceClocks(time::milliseconds(6)); + this->advanceClocks(6_ms); } void setDestinationAvailability(bool isAvailable) { destination->setAvailability(isAvailable); - this->advanceClocks(time::milliseconds(6)); + this->advanceClocks(6_ms); } protected: @@ -181,7 +181,7 @@ BOOST_AUTO_TEST_CASE(AddRemoveRoute) // refresh every 60 seconds destination->advertiseHistory.clear(); - this->advanceClocks(time::seconds(61), 5); + this->advanceClocks(61_s, 5); BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 5); // /A is still needed by /A/2 route @@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(AdvertiseRetryInterval) policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()}; this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT); - this->advanceClocks(time::seconds(10), time::seconds(3600)); + this->advanceClocks(10_s, 1_h); BOOST_REQUIRE_GT(destination->advertiseHistory.size(), 2); // destination->advertise keeps failing, so interval should increase @@ -260,12 +260,12 @@ BOOST_AUTO_TEST_CASE(AdvertiseRetryInterval) } destination->shouldSucceed = true; - this->advanceClocks(time::seconds(3600)); + this->advanceClocks(1_h); destination->advertiseHistory.clear(); // destination->advertise has succeeded, retry interval should reset to initial destination->shouldSucceed = false; - this->advanceClocks(time::seconds(10), time::seconds(300)); + this->advanceClocks(10_s, 300_s); BOOST_REQUIRE_GE(destination->advertiseHistory.size(), 2); FloatInterval restartInterval = destination->advertiseHistory[1].timestamp - destination->advertiseHistory[0].timestamp; @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(ChangeDuringRetry) destination->shouldSucceed = false; policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()}; this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT); - this->advanceClocks(time::seconds(10), time::seconds(300)); + this->advanceClocks(10_s, 300_s); BOOST_CHECK_GT(destination->advertiseHistory.size(), 0); BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0); @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(ChangeDuringRetry) destination->advertiseHistory.clear(); destination->withdrawHistory.clear(); this->eraseRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT); - this->advanceClocks(time::seconds(10), time::seconds(300)); + this->advanceClocks(10_s, 300_s); BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 0); // don't try to advertise BOOST_CHECK_GT(destination->withdrawHistory.size(), 0); // try to withdraw @@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(ChangeDuringRetry) destination->advertiseHistory.clear(); destination->withdrawHistory.clear(); this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT); - this->advanceClocks(time::seconds(10), time::seconds(300)); + this->advanceClocks(10_s, 300_s); BOOST_CHECK_GT(destination->advertiseHistory.size(), 0); // try to advertise BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0); // don't try to withdraw } diff --git a/tests/daemon/rib/rib-update.t.cpp b/tests/daemon/rib/rib-update.t.cpp index a4feca13..81ee10ee 100644 --- a/tests/daemon/rib/rib-update.t.cpp +++ b/tests/daemon/rib/rib-update.t.cpp @@ -34,7 +34,9 @@ namespace nfd { namespace rib { namespace tests { -BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, nfd::tests::GlobalIoFixture) +using namespace nfd::tests; + +BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, GlobalIoFixture) BOOST_AUTO_TEST_CASE(BatchBasic) { diff --git a/tests/daemon/rib/rib.t.cpp b/tests/daemon/rib/rib.t.cpp index a1b83631..7de4ebe1 100644 --- a/tests/daemon/rib/rib.t.cpp +++ b/tests/daemon/rib/rib.t.cpp @@ -33,7 +33,9 @@ namespace nfd { namespace rib { namespace tests { -BOOST_FIXTURE_TEST_SUITE(TestRib, nfd::tests::GlobalIoFixture) +using namespace nfd::tests; + +BOOST_FIXTURE_TEST_SUITE(TestRib, GlobalIoFixture) BOOST_AUTO_TEST_CASE(Parent) { @@ -170,7 +172,7 @@ BOOST_AUTO_TEST_CASE(Basic) route1.faceId = 1; route1.cost = 10; route1.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE; - route1.expires = time::steady_clock::now() + time::milliseconds(1500); + route1.expires = time::steady_clock::now() + 1500_ms; rib.insert(name1, route1); BOOST_CHECK_EQUAL(rib.size(), 1); @@ -183,7 +185,7 @@ BOOST_AUTO_TEST_CASE(Basic) route2.faceId = 1; route2.cost = 100; route2.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT; - route2.expires = time::steady_clock::now() + time::seconds(0); + route2.expires = time::steady_clock::now() + 0_s; rib.insert(name2, route2); BOOST_CHECK_EQUAL(rib.size(), 1); diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp index 156257ba..e732e073 100644 --- a/tests/daemon/rib/service.t.cpp +++ b/tests/daemon/rib/service.t.cpp @@ -33,7 +33,9 @@ namespace nfd { namespace rib { namespace tests { -BOOST_FIXTURE_TEST_SUITE(TestService, nfd::tests::RibIoFixture) +using namespace nfd::tests; + +BOOST_FIXTURE_TEST_SUITE(TestService, RibIoFixture) BOOST_AUTO_TEST_CASE(Basic) { diff --git a/tests/daemon/table/cs-policy-priority-fifo.t.cpp b/tests/daemon/table/cs-policy-priority-fifo.t.cpp index cd71b5b2..37fcbc73 100644 --- a/tests/daemon/table/cs-policy-priority-fifo.t.cpp +++ b/tests/daemon/table/cs-policy-priority-fifo.t.cpp @@ -50,25 +50,25 @@ BOOST_FIXTURE_TEST_CASE(EvictOne, GlobalIoTimeFixture) cs.setPolicy(make_unique()); shared_ptr dataA = makeData("ndn:/A"); - dataA->setFreshnessPeriod(time::milliseconds(99999)); + dataA->setFreshnessPeriod(99999_ms); dataA->wireEncode(); cs.insert(*dataA); shared_ptr dataB = makeData("ndn:/B"); - dataB->setFreshnessPeriod(time::milliseconds(10)); + dataB->setFreshnessPeriod(10_ms); dataB->wireEncode(); cs.insert(*dataB); shared_ptr dataC = makeData("ndn:/C"); - dataC->setFreshnessPeriod(time::milliseconds(99999)); + dataC->setFreshnessPeriod(99999_ms); dataC->wireEncode(); cs.insert(*dataC, true); - this->advanceClocks(time::milliseconds(11)); + this->advanceClocks(11_ms); // evict unsolicited shared_ptr dataD = makeData("ndn:/D"); - dataD->setFreshnessPeriod(time::milliseconds(99999)); + dataD->setFreshnessPeriod(99999_ms); dataD->wireEncode(); cs.insert(*dataD); BOOST_CHECK_EQUAL(cs.size(), 3); @@ -78,7 +78,7 @@ BOOST_FIXTURE_TEST_CASE(EvictOne, GlobalIoTimeFixture) // evict stale shared_ptr dataE = makeData("ndn:/E"); - dataE->setFreshnessPeriod(time::milliseconds(99999)); + dataE->setFreshnessPeriod(99999_ms); dataE->wireEncode(); cs.insert(*dataE); BOOST_CHECK_EQUAL(cs.size(), 3); @@ -88,7 +88,7 @@ BOOST_FIXTURE_TEST_CASE(EvictOne, GlobalIoTimeFixture) // evict fifo shared_ptr dataF = makeData("ndn:/F"); - dataF->setFreshnessPeriod(time::milliseconds(99999)); + dataF->setFreshnessPeriod(99999_ms); dataF->wireEncode(); cs.insert(*dataF); BOOST_CHECK_EQUAL(cs.size(), 3); @@ -103,21 +103,21 @@ BOOST_FIXTURE_TEST_CASE(Refresh, GlobalIoTimeFixture) cs.setPolicy(make_unique()); shared_ptr dataA = makeData("ndn:/A"); - dataA->setFreshnessPeriod(time::milliseconds(99999)); + dataA->setFreshnessPeriod(99999_ms); dataA->wireEncode(); cs.insert(*dataA); shared_ptr dataB = makeData("ndn:/B"); - dataB->setFreshnessPeriod(time::milliseconds(10)); + dataB->setFreshnessPeriod(10_ms); dataB->wireEncode(); cs.insert(*dataB); shared_ptr dataC = makeData("ndn:/C"); - dataC->setFreshnessPeriod(time::milliseconds(10)); + dataC->setFreshnessPeriod(10_ms); dataC->wireEncode(); cs.insert(*dataC); - this->advanceClocks(time::milliseconds(11)); + this->advanceClocks(11_ms); // refresh dataB shared_ptr dataB2 = make_shared(*dataB); @@ -138,7 +138,7 @@ BOOST_FIXTURE_TEST_CASE(Refresh, GlobalIoTimeFixture) // evict dataC stale shared_ptr dataD = makeData("ndn:/D"); - dataD->setFreshnessPeriod(time::milliseconds(99999)); + dataD->setFreshnessPeriod(99999_ms); dataD->wireEncode(); cs.insert(*dataD); BOOST_CHECK_EQUAL(cs.size(), 3); diff --git a/tests/daemon/table/cs.t.cpp b/tests/daemon/table/cs.t.cpp index bcfd3a58..db980d22 100644 --- a/tests/daemon/table/cs.t.cpp +++ b/tests/daemon/table/cs.t.cpp @@ -272,28 +272,28 @@ BOOST_AUTO_TEST_CASE(MaxSuffixComponents) BOOST_AUTO_TEST_CASE(MustBeFresh) { insert(1, "/A/1"); // omitted FreshnessPeriod means FreshnessPeriod = 0 ms - insert(2, "/A/2", [] (Data& data) { data.setFreshnessPeriod(time::seconds(0)); }); - insert(3, "/A/3", [] (Data& data) { data.setFreshnessPeriod(time::seconds(1)); }); - insert(4, "/A/4", [] (Data& data) { data.setFreshnessPeriod(time::seconds(3600)); }); + insert(2, "/A/2", [] (Data& data) { data.setFreshnessPeriod(0_s); }); + insert(3, "/A/3", [] (Data& data) { data.setFreshnessPeriod(1_s); }); + insert(4, "/A/4", [] (Data& data) { data.setFreshnessPeriod(1_h); }); // lookup at exact same moment as insertion is not tested because this won't happen in reality - this->advanceClocks(time::milliseconds(500)); // @500ms + this->advanceClocks(500_ms); // @500ms startInterest("/A") .setMustBeFresh(true); CHECK_CS_FIND(3); - this->advanceClocks(time::milliseconds(1500)); // @2s + this->advanceClocks(1500_ms); // @2s startInterest("/A") .setMustBeFresh(true); CHECK_CS_FIND(4); - this->advanceClocks(time::seconds(3500)); // @3502s + this->advanceClocks(3500_s); // @3502s startInterest("/A") .setMustBeFresh(true); CHECK_CS_FIND(4); - this->advanceClocks(time::seconds(3500)); // @7002s + this->advanceClocks(3500_s); // @7002s startInterest("/A") .setMustBeFresh(true); CHECK_CS_FIND(0); diff --git a/tests/daemon/table/dead-nonce-list.t.cpp b/tests/daemon/table/dead-nonce-list.t.cpp index ea7866c9..1cd32eb9 100644 --- a/tests/daemon/table/dead-nonce-list.t.cpp +++ b/tests/daemon/table/dead-nonce-list.t.cpp @@ -110,7 +110,7 @@ protected: scheduler::ScopedEventId addNonceEvent; }; -const time::nanoseconds PeriodicalInsertionFixture::LIFETIME = time::milliseconds(200); +const time::nanoseconds PeriodicalInsertionFixture::LIFETIME = 200_ms; BOOST_FIXTURE_TEST_CASE(Lifetime, PeriodicalInsertionFixture) { diff --git a/tests/daemon/table/measurements.t.cpp b/tests/daemon/table/measurements.t.cpp index 915a0490..23034a32 100644 --- a/tests/daemon/table/measurements.t.cpp +++ b/tests/daemon/table/measurements.t.cpp @@ -208,11 +208,11 @@ BOOST_AUTO_TEST_CASE(Lifetime) Entry& entryC = measurements.get(nameC); BOOST_CHECK_EQUAL(measurements.size(), 3); - const time::nanoseconds EXTEND_A = time::seconds(2); - const time::nanoseconds CHECK1 = time::seconds(3); - const time::nanoseconds CHECK2 = time::seconds(5); - const time::nanoseconds EXTEND_C = time::seconds(6); - const time::nanoseconds CHECK3 = time::seconds(7); + const time::nanoseconds EXTEND_A = 2_s; + const time::nanoseconds CHECK1 = 3_s; + const time::nanoseconds CHECK2 = 5_s; + const time::nanoseconds EXTEND_C = 6_s; + const time::nanoseconds CHECK3 = 7_s; BOOST_ASSERT(EXTEND_A < CHECK1); BOOST_ASSERT(CHECK1 < Measurements::getInitialLifetime()); BOOST_ASSERT(Measurements::getInitialLifetime() < CHECK2); @@ -226,19 +226,19 @@ BOOST_AUTO_TEST_CASE(Lifetime) // B = initial lifetime // C = EXTEND_C - this->advanceClocks(time::milliseconds(100), CHECK1); + this->advanceClocks(100_ms, CHECK1); BOOST_CHECK(measurements.findExactMatch(nameA) != nullptr); BOOST_CHECK(measurements.findExactMatch(nameB) != nullptr); BOOST_CHECK(measurements.findExactMatch(nameC) != nullptr); BOOST_CHECK_EQUAL(measurements.size(), 3); - this->advanceClocks(time::milliseconds(100), CHECK2 - CHECK1); + this->advanceClocks(100_ms, CHECK2 - CHECK1); BOOST_CHECK(measurements.findExactMatch(nameA) == nullptr); BOOST_CHECK(measurements.findExactMatch(nameB) == nullptr); BOOST_CHECK(measurements.findExactMatch(nameC) != nullptr); BOOST_CHECK_EQUAL(measurements.size(), 1); - this->advanceClocks(time::milliseconds(100), CHECK3 - CHECK2); + this->advanceClocks(100_ms, CHECK3 - CHECK2); BOOST_CHECK(measurements.findExactMatch(nameA) == nullptr); BOOST_CHECK(measurements.findExactMatch(nameB) == nullptr); BOOST_CHECK(measurements.findExactMatch(nameC) == nullptr); @@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(EraseNameTreeEntry) measurements.get("/A"); BOOST_CHECK_EQUAL(measurements.size(), 1); - this->advanceClocks(Measurements::getInitialLifetime() + time::milliseconds(10)); + this->advanceClocks(Measurements::getInitialLifetime() + 10_ms); BOOST_CHECK_EQUAL(measurements.size(), 0); BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore); } diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp index 4e325bc2..b42de833 100644 --- a/tests/daemon/table/name-tree.t.cpp +++ b/tests/daemon/table/name-tree.t.cpp @@ -668,7 +668,7 @@ BOOST_AUTO_TEST_CASE(Example) .end(); } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // IteratorPartialEnumerate BOOST_FIXTURE_TEST_CASE(IteratorFindAllMatches, EnumerationFixture) { diff --git a/tests/daemon/table/network-region-table.t.cpp b/tests/daemon/table/network-region-table.t.cpp index 11948bcb..12865c69 100644 --- a/tests/daemon/table/network-region-table.t.cpp +++ b/tests/daemon/table/network-region-table.t.cpp @@ -56,8 +56,8 @@ BOOST_AUTO_TEST_CASE(InProducerRegion) BOOST_CHECK_EQUAL(nrt4.isInProducerRegion(fh), true); } -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestNetworkRegionTable +BOOST_AUTO_TEST_SUITE_END() // Table } // namespace tests } // namespace nfd diff --git a/tests/daemon/table/pit-entry.t.cpp b/tests/daemon/table/pit-entry.t.cpp index a155be20..f46aa38f 100644 --- a/tests/daemon/table/pit-entry.t.cpp +++ b/tests/daemon/table/pit-entry.t.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(CanMatch) BOOST_CHECK_EQUAL(entry.canMatch(*interest2), true); shared_ptr interest3 = makeInterest("/A"); - interest3->setInterestLifetime(time::milliseconds(6210)); + interest3->setInterestLifetime(6210_ms); BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true); shared_ptr interest4 = makeInterest("/A"); @@ -71,16 +71,16 @@ BOOST_AUTO_TEST_CASE(InOutRecords) Name name("ndn:/KuYfjtRq"); shared_ptr interest = makeInterest(name); shared_ptr interest1 = makeInterest(name); - interest1->setInterestLifetime(time::milliseconds(2528)); + interest1->setInterestLifetime(2528_ms); interest1->setNonce(25559); shared_ptr interest2 = makeInterest(name); - interest2->setInterestLifetime(time::milliseconds(6464)); + interest2->setInterestLifetime(6464_ms); interest2->setNonce(19004); shared_ptr interest3 = makeInterest(name); - interest3->setInterestLifetime(time::milliseconds(3585)); + interest3->setInterestLifetime(3585_ms); interest3->setNonce(24216); shared_ptr interest4 = makeInterest(name); - interest4->setInterestLifetime(time::milliseconds(8795)); + interest4->setInterestLifetime(8795_ms); interest4->setNonce(17365); Entry entry(*interest); diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp index 7c6d791e..5b051fb1 100644 --- a/tests/daemon/table/pit.t.cpp +++ b/tests/daemon/table/pit.t.cpp @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(Insert) // A+InterestLifetime shared_ptr interestK = make_shared(*interestA); - interestK->setInterestLifetime(time::milliseconds(1000)); + interestK->setInterestLifetime(1_s); insertResult = pit.insert(*interestK); BOOST_CHECK_EQUAL(insertResult.second, false); // only guiders differ BOOST_CHECK_EQUAL(pit.size(), 9); @@ -391,8 +391,8 @@ BOOST_AUTO_TEST_CASE(Iterator) } } -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestPit +BOOST_AUTO_TEST_SUITE_END() // Table } // namespace tests } // namespace pit diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp index 3ab1ddae..cdda120d 100644 --- a/tests/other/face-benchmark.cpp +++ b/tests/other/face-benchmark.cpp @@ -47,7 +47,7 @@ public: : m_terminationSignalSet{getGlobalIoService()} , m_tcpChannel{tcp::Endpoint{boost::asio::ip::tcp::v4(), 6363}, false, bind([] { return ndn::nfd::FACE_SCOPE_NON_LOCAL; })} - , m_udpChannel{udp::Endpoint{boost::asio::ip::udp::v4(), 6363}, time::minutes{10}, false} + , m_udpChannel{udp::Endpoint{boost::asio::ip::udp::v4(), 6363}, 10_min, false} { m_terminationSignalSet.add(SIGINT); m_terminationSignalSet.add(SIGTERM); diff --git a/tests/tools/ndn-autoconfig/multicast-discovery.t.cpp b/tests/tools/ndn-autoconfig/multicast-discovery.t.cpp index 0e08a36d..62d8bf13 100644 --- a/tests/tools/ndn-autoconfig/multicast-discovery.t.cpp +++ b/tests/tools/ndn-autoconfig/multicast-discovery.t.cpp @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(Normal) }); stage.start(); - face.processEvents(time::seconds(20)); + face.processEvents(20_s); BOOST_CHECK(hasSuccess); } diff --git a/tests/tools/nfdc/forwarder-general-module.t.cpp b/tests/tools/nfdc/forwarder-general-module.t.cpp index ed87b710..ad282a33 100644 --- a/tests/tools/nfdc/forwarder-general-module.t.cpp +++ b/tests/tools/nfdc/forwarder-general-module.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -91,8 +91,8 @@ BOOST_AUTO_TEST_CASE(Status) this->fetchStatus(); ForwarderStatus payload; payload.setNfdVersion("0.4.1-1-g704430c") - .setStartTimestamp(time::fromUnixTimestamp(time::milliseconds(1466781226856))) - .setCurrentTimestamp(time::fromUnixTimestamp(time::milliseconds(1468778154109))) + .setStartTimestamp(time::fromUnixTimestamp(1466781226856_ms)) + .setCurrentTimestamp(time::fromUnixTimestamp(1468778154109_ms)) .setNNameTreeEntries(668) .setNFibEntries(70) .setNPitEntries(7) diff --git a/tests/tools/nfdc/rib-module.t.cpp b/tests/tools/nfdc/rib-module.t.cpp index 919b43ad..624fca60 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-2018, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -53,7 +53,7 @@ protected: .setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT) .setCost(2956) .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE) - .setExpirationPeriod(time::milliseconds(29950035))); + .setExpirationPeriod(29950035_ms)); entry1.addRoute(Route() .setFaceId(6720) .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) @@ -248,10 +248,10 @@ BOOST_AUTO_TEST_CASE(NormalByFaceUri) BOOST_CHECK_EQUAL(req.getFlags(), ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE); BOOST_REQUIRE_EQUAL(req.hasExpirationPeriod(), true); - BOOST_REQUIRE_EQUAL(req.getExpirationPeriod(), time::milliseconds(727411987)); + BOOST_REQUIRE_EQUAL(req.getExpirationPeriod(), 727411987_ms); ControlParameters resp = req; - resp.setExpirationPeriod(time::milliseconds(727411154)); // server side may change expiration + resp.setExpirationPeriod(727411154_ms); // server side may change expiration this->succeedCommand(interest, resp); }; @@ -530,7 +530,7 @@ BOOST_AUTO_TEST_CASE(Status) .setOrigin(ndn::nfd::ROUTE_ORIGIN_STATIC) .setCost(79) .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT) - .setExpirationPeriod(time::milliseconds(47292))); + .setExpirationPeriod(47292_ms)); RibEntry payload2; payload2.setName("/localhost/nfd") .addRoute(Route().setFaceId(258) diff --git a/tests/tools/nfdc/status-fixture.hpp b/tests/tools/nfdc/status-fixture.hpp index e1974b91..f33f6bb4 100644 --- a/tests/tools/nfdc/status-fixture.hpp +++ b/tests/tools/nfdc/status-fixture.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2017, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -28,6 +28,7 @@ #include "mock-nfd-mgmt-fixture.hpp" #include "nfdc/module.hpp" + #include namespace nfd { @@ -87,7 +88,7 @@ protected: // status fetching BOOST_FAIL("fetchStatus failure " << code << " " << reason); }, CommandOptions()); - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); } /** \brief prepare status output as XML and text @@ -96,7 +97,7 @@ protected: // status fetching void prepareStatusOutput() { - this->advanceClocks(time::milliseconds(1)); + this->advanceClocks(1_ms); BOOST_REQUIRE_EQUAL(nFetchStatusSuccess, 1); statusXml.str(""); diff --git a/tests/tools/nfdc/status-report.t.cpp b/tests/tools/nfdc/status-report.t.cpp index 7c8e32c4..5041fb3f 100644 --- a/tests/tools/nfdc/status-report.t.cpp +++ b/tests/tools/nfdc/status-report.t.cpp @@ -52,7 +52,7 @@ public: : m_moduleName(moduleName) , m_scheduler(io) , m_res(0) - , m_delay(time::milliseconds(1)) + , m_delay(1_ms) { } @@ -174,11 +174,11 @@ BOOST_FIXTURE_TEST_SUITE(TestStatusReport, StatusReportModulesFixture) BOOST_AUTO_TEST_CASE(Normal) { DummyModule& m1 = addModule("module1"); - m1.setResult(0, time::milliseconds(10)); + m1.setResult(0, 10_ms); DummyModule& m2 = addModule("module2"); - m2.setResult(0, time::milliseconds(20)); + m2.setResult(0, 20_ms); - this->collect(time::milliseconds(5), 6); + this->collect(5_ms, 6); BOOST_CHECK_EQUAL(m1.nFetchStatusCalls, 1); BOOST_CHECK_EQUAL(m2.nFetchStatusCalls, 1); @@ -191,11 +191,11 @@ BOOST_AUTO_TEST_CASE(Normal) BOOST_AUTO_TEST_CASE(Reorder) { DummyModule& m1 = addModule("module1"); - m1.setResult(0, time::milliseconds(20)); + m1.setResult(0, 20_ms); DummyModule& m2 = addModule("module2"); - m2.setResult(0, time::milliseconds(10)); // module2 completes earlier than module1 + m2.setResult(0, 10_ms); // module2 completes earlier than module1 - this->collect(time::milliseconds(5), 6); + this->collect(5_ms, 6); BOOST_CHECK_EQUAL(res, 0); BOOST_CHECK(statusXml.is_equal(STATUS_XML)); // output is still in order @@ -205,11 +205,11 @@ BOOST_AUTO_TEST_CASE(Reorder) BOOST_AUTO_TEST_CASE(Error) { DummyModule& m1 = addModule("module1"); - m1.setResult(0, time::milliseconds(20)); + m1.setResult(0, 20_ms); DummyModule& m2 = addModule("module2"); - m2.setResult(500, time::milliseconds(10)); + m2.setResult(500, 10_ms); - this->collect(time::milliseconds(5), 6); + this->collect(5_ms, 6); BOOST_CHECK_EQUAL(res, 1000500); } diff --git a/tools/ndn-autoconfig-server/program.cpp b/tools/ndn-autoconfig-server/program.cpp index 8f624b8e..d0be0d11 100644 --- a/tools/ndn-autoconfig-server/program.cpp +++ b/tools/ndn-autoconfig-server/program.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2017, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -35,9 +35,9 @@ namespace ndn { namespace tools { namespace autoconfig_server { -static const Name HUB_DATA_NAME("/localhop/ndn-autoconf/hub"); -static const Name ROUTABLE_PREFIXES_DATA_PREFIX("/localhop/nfd"); -static const PartialName ROUTABLE_PREFIXES_DATA_SUFFIX("rib/routable-prefixes"); +const Name HUB_DATA_NAME("/localhop/ndn-autoconf/hub"); +const Name ROUTABLE_PREFIXES_DATA_PREFIX("/localhop/nfd"); +const PartialName ROUTABLE_PREFIXES_DATA_SUFFIX("rib/routable-prefixes"); Program::Program(const Options& options, Face& face, KeyChain& keyChain) : m_face(face) @@ -56,7 +56,7 @@ Program::enableHubData(const FaceUri& hubFaceUri) std::string uri = hubFaceUri.toString(); auto data = make_shared(Name(HUB_DATA_NAME).appendVersion()); - data->setFreshnessPeriod(time::hours(1)); + data->setFreshnessPeriod(1_h); data->setContent(makeBinaryBlock(tlv::nfd::Uri, reinterpret_cast(uri.data()), uri.size())); m_keyChain.sign(*data); @@ -75,7 +75,7 @@ Program::enableRoutablePrefixesDataset(const std::vector& routablePrefixes { m_dispatcher.addStatusDataset(ROUTABLE_PREFIXES_DATA_SUFFIX, mgmt::makeAcceptAllAuthorization(), - [=] (const Name& prefix, const Interest& interest, mgmt::StatusDatasetContext& context) { + [=] (const Name&, const Interest&, mgmt::StatusDatasetContext& context) { for (const Name& routablePrefix : routablePrefixes) { context.append(routablePrefix.wireEncode()); } @@ -84,8 +84,8 @@ Program::enableRoutablePrefixesDataset(const std::vector& routablePrefixes m_dispatcher.addTopPrefix(ROUTABLE_PREFIXES_DATA_PREFIX, false); m_face.registerPrefix(Name(ROUTABLE_PREFIXES_DATA_PREFIX).append(ROUTABLE_PREFIXES_DATA_SUFFIX), - nullptr, - bind(&Program::handlePrefixRegistrationFailure, this, _1, _2)); + nullptr, + bind(&Program::handlePrefixRegistrationFailure, this, _1, _2)); } void diff --git a/tools/ndn-autoconfig/main.cpp b/tools/ndn-autoconfig/main.cpp index e69ef894..859ed34f 100644 --- a/tools/ndn-autoconfig/main.cpp +++ b/tools/ndn-autoconfig/main.cpp @@ -49,12 +49,12 @@ namespace ndn { namespace tools { namespace autoconfig { -static const time::nanoseconds DAEMON_INITIAL_DELAY = 100_ms; -static const time::nanoseconds DAEMON_UNCONDITIONAL_INTERVAL = 1_h; -static const time::nanoseconds NETMON_DAMPEN_PERIOD = 5_s; - namespace po = boost::program_options; +const time::nanoseconds DAEMON_INITIAL_DELAY = 100_ms; +const time::nanoseconds DAEMON_UNCONDITIONAL_INTERVAL = 1_h; +const time::nanoseconds NETMON_DAMPEN_PERIOD = 5_s; + static void usage(std::ostream& os, const po::options_description& opts, diff --git a/tools/ndn-autoconfig/multicast-discovery.cpp b/tools/ndn-autoconfig/multicast-discovery.cpp index c74d5f36..1baf8312 100644 --- a/tools/ndn-autoconfig/multicast-discovery.cpp +++ b/tools/ndn-autoconfig/multicast-discovery.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2017, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -24,7 +24,9 @@ */ #include "multicast-discovery.hpp" + #include + #include namespace ndn { @@ -34,10 +36,10 @@ namespace autoconfig { using nfd::ControlParameters; using nfd::ControlResponse; -static const Name HUB_DISCOVERY_PREFIX("/localhop/ndn-autoconf/hub"); -static const uint64_t HUB_DISCOVERY_ROUTE_COST(1); -static const time::milliseconds HUB_DISCOVERY_ROUTE_EXPIRATION = time::seconds(30); -static const time::milliseconds HUB_DISCOVERY_INTEREST_LIFETIME = time::seconds(4); +const Name HUB_DISCOVERY_PREFIX("/localhop/ndn-autoconf/hub"); +const uint64_t HUB_DISCOVERY_ROUTE_COST(1); +const time::milliseconds HUB_DISCOVERY_ROUTE_EXPIRATION = 30_s; +const time::milliseconds HUB_DISCOVERY_INTEREST_LIFETIME = 4_s; MulticastDiscovery::MulticastDiscovery(Face& face, nfd::Controller& controller) : m_face(face) diff --git a/tools/ndn-autoconfig/procedure.cpp b/tools/ndn-autoconfig/procedure.cpp index fff88f72..dded94b7 100644 --- a/tools/ndn-autoconfig/procedure.cpp +++ b/tools/ndn-autoconfig/procedure.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2017, Regents of the University of California, + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -36,10 +36,10 @@ namespace autoconfig { using nfd::ControlParameters; using nfd::ControlResponse; -static const time::nanoseconds FACEURI_CANONIZE_TIMEOUT = time::seconds(4); -static const std::vector HUB_PREFIXES{"/", "/localhop/nfd"}; -static const nfd::RouteOrigin HUB_ROUTE_ORIGIN = nfd::ROUTE_ORIGIN_AUTOCONF; -static const uint64_t HUB_ROUTE_COST = 100; +const time::nanoseconds FACEURI_CANONIZE_TIMEOUT = 4_s; +const std::vector HUB_PREFIXES{"/", "/localhop/nfd"}; +const nfd::RouteOrigin HUB_ROUTE_ORIGIN = nfd::ROUTE_ORIGIN_AUTOCONF; +const uint64_t HUB_ROUTE_COST = 100; Procedure::Procedure(Face& face, KeyChain& keyChain) : m_face(face) diff --git a/tools/nfdc/execute-command.cpp b/tools/nfdc/execute-command.cpp index 92f16319..7067ebf5 100644 --- a/tools/nfdc/execute-command.cpp +++ b/tools/nfdc/execute-command.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California, +/* + * Copyright (c) 2014-2019, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -32,7 +32,7 @@ namespace nfdc { time::nanoseconds ExecuteContext::getTimeout() const { - return time::seconds(4); + return 4_s; } ndn::nfd::CommandOptions