Skip to content

Commit

Permalink
tests+tools: minor code cleanup
Browse files Browse the repository at this point in the history
Change-Id: Ic3356d4a18a8e5eeb45fc076fc0563c3d1549c8a
  • Loading branch information
Pesa committed Mar 28, 2019
1 parent c6a65ad commit 14e71f0
Show file tree
Hide file tree
Showing 76 changed files with 406 additions and 446 deletions.
4 changes: 2 additions & 2 deletions daemon/fw/asf-measurements.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -316,7 +316,7 @@ class AsfMeasurements : noncopyable
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;
Expand Down
2 changes: 1 addition & 1 deletion daemon/fw/self-learning-strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion daemon/rib/readvertise/readvertise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/config-file.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/core/ndebug.t.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/core/rtt-estimator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/core/version.t.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/daemon/face/datagram-transport.t.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/daemon/face/ethernet-channel.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class EthernetChannelFixture : public EthernetFixture
makeChannel()
{
BOOST_ASSERT(netifs.size() > 0);
return make_unique<EthernetChannel>(netifs.front(), time::seconds(2));
return make_unique<EthernetChannel>(netifs.front(), 2_s);
}
};

Expand Down
12 changes: 6 additions & 6 deletions tests/daemon/face/ethernet-factory.t.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -436,22 +436,22 @@ 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()});
}

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);
}

Expand All @@ -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]"),
Expand Down
2 changes: 1 addition & 1 deletion tests/daemon/face/ethernet-fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class EthernetFixture : public virtual GlobalIoFixture
BOOST_ASSERT(netif != nullptr);
localEp = netif->getName();
remoteEp = remoteAddr;
transport = make_unique<UnicastEthernetTransport>(*netif, remoteEp, persistency, time::seconds(2));
transport = make_unique<UnicastEthernetTransport>(*netif, remoteEp, persistency, 2_s);
}

/** \brief create a MulticastEthernetTransport
Expand Down
34 changes: 17 additions & 17 deletions tests/daemon/face/generic-link-service.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand All @@ -541,15 +541,15 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel)
BOOST_REQUIRE_NO_THROW(pkt1.wireDecode(transport->sentPackets.back().packet));
BOOST_REQUIRE_EQUAL(pkt1.count<lp::CongestionMarkField>(), 1);
BOOST_CHECK_EQUAL(pkt1.get<lp::CongestionMarkField>(), 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);
BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 1);
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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -690,15 +690,15 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel)
BOOST_REQUIRE_NO_THROW(pkt10.wireDecode(transport->sentPackets.back().packet));
BOOST_REQUIRE_EQUAL(pkt10.count<lp::CongestionMarkField>(), 1);
BOOST_CHECK_EQUAL(pkt10.get<lp::CongestionMarkField>(), 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);
BOOST_CHECK_EQUAL(service->m_nMarkedSinceInMarkingState, 1);
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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(CongestionCoDel)
BOOST_REQUIRE_NO_THROW(pkt14.wireDecode(transport->sentPackets.back().packet));
BOOST_REQUIRE_EQUAL(pkt14.count<lp::CongestionMarkField>(), 1);
BOOST_CHECK_EQUAL(pkt14.get<lp::CongestionMarkField>(), 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);
Expand All @@ -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);
Expand Down Expand Up @@ -821,7 +821,7 @@ BOOST_AUTO_TEST_CASE(DefaultThreshold)
BOOST_REQUIRE_NO_THROW(pkt3.wireDecode(transport->sentPackets.back().packet));
BOOST_REQUIRE_EQUAL(pkt3.count<lp::CongestionMarkField>(), 1);
BOOST_CHECK_EQUAL(pkt3.get<lp::CongestionMarkField>(), 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);
Expand Down
Loading

0 comments on commit 14e71f0

Please sign in to comment.