all: Update code to compile with latest time-related changes in ndn-cpp-dev library
Change-Id: I7e859989c833001f49b286d4a9917f4dc740b4a4
diff --git a/tests/core/limited-io.cpp b/tests/core/limited-io.cpp
index b381696..1eba63d 100644
--- a/tests/core/limited-io.cpp
+++ b/tests/core/limited-io.cpp
@@ -13,7 +13,7 @@
NFD_LOG_INIT("LimitedIo");
const int LimitedIo::UNLIMITED_OPS = std::numeric_limits<int>::max();
-const time::Duration LimitedIo::UNLIMITED_TIME = time::nanoseconds(-1);
+const time::nanoseconds LimitedIo::UNLIMITED_TIME = time::nanoseconds::min();
LimitedIo::LimitedIo()
: m_isRunning(false)
@@ -22,14 +22,14 @@
}
LimitedIo::StopReason
-LimitedIo::run(int nOpsLimit, time::Duration nTimeLimit)
+LimitedIo::run(int nOpsLimit, const time::nanoseconds& nTimeLimit)
{
BOOST_ASSERT(!m_isRunning);
m_isRunning = true;
m_reason = NO_WORK;
m_nOpsRemaining = nOpsLimit;
- if (nTimeLimit != UNLIMITED_TIME) {
+ if (nTimeLimit >= time::nanoseconds::zero()) {
m_timeout = scheduler::schedule(nTimeLimit, bind(&LimitedIo::afterTimeout, this));
}
diff --git a/tests/core/limited-io.hpp b/tests/core/limited-io.hpp
index 0aae290..d3968c2 100644
--- a/tests/core/limited-io.hpp
+++ b/tests/core/limited-io.hpp
@@ -38,7 +38,7 @@
* \param nTimeLimit time limit, pass UNLIMITED_TIME for no limit
*/
StopReason
- run(int nOpsLimit, time::Duration nTimeLimit);
+ run(int nOpsLimit, const time::nanoseconds& nTimeLimit);
/// count an operation
void
@@ -53,7 +53,7 @@
public:
static const int UNLIMITED_OPS;
- static const time::Duration UNLIMITED_TIME;
+ static const time::nanoseconds UNLIMITED_TIME;
private:
bool m_isRunning;
diff --git a/tests/core/scheduler.cpp b/tests/core/scheduler.cpp
index 806c982..87c75cf 100644
--- a/tests/core/scheduler.cpp
+++ b/tests/core/scheduler.cpp
@@ -57,18 +57,20 @@
BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
{
- scheduler::schedule(time::seconds(0.5), bind(&SchedulerFixture::event1, this));
+ scheduler::schedule(time::milliseconds(500), bind(&SchedulerFixture::event1, this));
- EventId i = scheduler::schedule(time::seconds(1.0), bind(&SchedulerFixture::event2, this));
+ EventId i = scheduler::schedule(time::seconds(1), bind(&SchedulerFixture::event2, this));
scheduler::cancel(i);
- scheduler::schedule(time::seconds(0.25), bind(&SchedulerFixture::event3, this));
+ scheduler::schedule(time::milliseconds(250), bind(&SchedulerFixture::event3, this));
- i = scheduler::schedule(time::seconds(0.05), bind(&SchedulerFixture::event2, this));
+ i = scheduler::schedule(time::milliseconds(50), bind(&SchedulerFixture::event2, this));
scheduler::cancel(i);
// TODO deprecate periodic event
- i = scheduler::getGlobalScheduler().schedulePeriodicEvent(time::seconds(0.3), time::seconds(0.1), bind(&SchedulerFixture::event4, this));
+ i = scheduler::getGlobalScheduler().schedulePeriodicEvent(time::milliseconds(300),
+ time::milliseconds(100),
+ bind(&SchedulerFixture::event4, this));
scheduler::schedule(time::seconds(1), bind(&scheduler::cancel, i));
g_io.run();
@@ -98,7 +100,7 @@
BOOST_FIXTURE_TEST_CASE(SelfCancel, SelfCancelFixture)
{
- m_selfEventId = scheduler::schedule(time::seconds(0.1),
+ m_selfEventId = scheduler::schedule(time::milliseconds(100),
bind(&SelfCancelFixture::cancelSelf, this));
BOOST_REQUIRE_NO_THROW(g_io.run());
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index 332e28c..38ee797 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -349,7 +349,7 @@
bind(&EndToEndFixture::channel_onConnectFailed, this, _1)),
time::seconds(4)));
- scheduler::schedule(time::seconds(0.5),
+ scheduler::schedule(time::milliseconds(500),
bind(&EndToEndFixture::checkFaceList, this, 4));
BOOST_CHECK_MESSAGE(m_limitedIo.run(4,// 2 connects and 2 accepts
@@ -385,7 +385,7 @@
BOOST_CHECK(static_cast<bool>(m_face2));
// Face::close must be invoked during io run to be counted as an op
- scheduler::schedule(time::seconds(0.1), bind(&Face::close, m_face1));
+ scheduler::schedule(time::milliseconds(100), bind(&Face::close, m_face1));
BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"FaceClosing error: cannot properly close faces");
diff --git a/tests/face/udp.cpp b/tests/face/udp.cpp
index 5e3a996..d4983bf 100644
--- a/tests/face/udp.cpp
+++ b/tests/face/udp.cpp
@@ -545,7 +545,7 @@
BOOST_CHECK_NE(channel3, channel4);
- scheduler::schedule(time::seconds(0.5),
+ scheduler::schedule(time::milliseconds(500),
bind(&UdpChannel::connect, channel4, "127.0.0.1", "20070",
// does not work without static_cast
static_cast<UdpChannel::FaceCreatedCallback>(
@@ -553,7 +553,7 @@
static_cast<UdpChannel::ConnectFailedCallback>(
bind(&EndToEndFixture::channel_onConnectFailed, this, _1))));
- scheduler::schedule(time::seconds(0.4), bind(&EndToEndFixture::checkFaceList, this, 2));
+ scheduler::schedule(time::milliseconds(400), bind(&EndToEndFixture::checkFaceList, this, 2));
BOOST_CHECK_MESSAGE(m_limitedIo.run(2,// 2 connects
time::seconds(4)) == LimitedIo::EXCEED_OPS,
@@ -727,7 +727,7 @@
// BOOST_CHECK_NE(channel3, channel4);
//
// scheduler
-// .scheduleEvent(time::seconds(0.5),
+// .scheduleEvent(time::milliseconds(500),
// bind(&UdpChannel::connect, channel4,
// "::1", "20070",
// static_cast<UdpChannel::FaceCreatedCallback>(bind(&EndToEndFixture::
@@ -806,7 +806,7 @@
BOOST_CHECK(static_cast<bool>(m_face2));
// Face::close must be invoked during io run to be counted as an op
- scheduler::schedule(time::seconds(0.1), bind(&Face::close, m_face2));
+ scheduler::schedule(time::milliseconds(100), bind(&Face::close, m_face2));
BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"FaceClosing error: cannot properly close faces");
diff --git a/tests/fw/forwarder.cpp b/tests/fw/forwarder.cpp
index 7ec90a5..c96e57a 100644
--- a/tests/fw/forwarder.cpp
+++ b/tests/fw/forwarder.cpp
@@ -24,7 +24,7 @@
Name nameAB ("ndn:/A/B");
Name nameABC("ndn:/A/B/C");
shared_ptr<Interest> interestAB = makeInterest(nameAB);
- interestAB->setInterestLifetime(4000);
+ interestAB->setInterestLifetime(time::seconds(4));
shared_ptr<Data> dataABC = makeData(nameABC);
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
@@ -317,10 +317,10 @@
BOOST_CHECK_EQUAL(strategyQ->m_beforeSatisfyPendingInterest_count, 1);
shared_ptr<Interest> interest3 = makeInterest("ndn:/A/3");
- interest3->setInterestLifetime(30);
+ interest3->setInterestLifetime(time::milliseconds(30));
forwarder.onInterest(*face1, *interest3);
shared_ptr<Interest> interest4 = makeInterest("ndn:/B/4");
- interest4->setInterestLifetime(5000);
+ interest4->setInterestLifetime(time::milliseconds(5000));
forwarder.onInterest(*face1, *interest4);
strategyP->m_beforeExpirePendingInterest_count = 0;
diff --git a/tests/fw/ncc-strategy.cpp b/tests/fw/ncc-strategy.cpp
index d980c49..044b3ec 100644
--- a/tests/fw/ncc-strategy.cpp
+++ b/tests/fw/ncc-strategy.cpp
@@ -49,7 +49,7 @@
// first Interest: strategy knows nothing and follows routing
shared_ptr<Interest> interest1p = makeInterest("ndn:/0Jm1ajrW/%00");
Interest& interest1 = *interest1p;
- interest1.setInterestLifetime(8000);
+ interest1.setInterestLifetime(time::milliseconds(8000));
shared_ptr<pit::Entry> pitEntry1 = pit.insert(interest1).first;
pitEntry1->insertOrUpdateInRecord(face3, interest1);
@@ -74,7 +74,7 @@
// second Interest: strategy knows face2 is best
shared_ptr<Interest> interest2p = makeInterest("ndn:/0Jm1ajrW/%00%01");
Interest& interest2 = *interest2p;
- interest2.setInterestLifetime(8000);
+ interest2.setInterestLifetime(time::milliseconds(8000));
shared_ptr<pit::Entry> pitEntry2 = pit.insert(interest2).first;
pitEntry2->insertOrUpdateInRecord(face3, interest2);
diff --git a/tests/mgmt/command-validator.cpp b/tests/mgmt/command-validator.cpp
index 3dcae24..e2cf51c 100644
--- a/tests/mgmt/command-validator.cpp
+++ b/tests/mgmt/command-validator.cpp
@@ -84,7 +84,7 @@
generateIdentity(const Name& prefix)
{
m_identityName = prefix;
- m_identityName.append(boost::lexical_cast<std::string>(ndn::time::now()));
+ m_identityName.appendVersion();
const Name certName = m_keys.createIdentity(m_identityName);
diff --git a/tests/mgmt/status-server.cpp b/tests/mgmt/status-server.cpp
index 3d8442b..99aa9f8 100644
--- a/tests/mgmt/status-server.cpp
+++ b/tests/mgmt/status-server.cpp
@@ -17,16 +17,6 @@
BOOST_FIXTURE_TEST_SUITE(MgmtStatusServer, BaseFixture)
-static inline ndn::nfd::Status::Timestamp
-now()
-{
- return ndn::nfd::Status::Timestamp(
- boost::chrono::duration_cast<ndn::nfd::Status::Timestamp::duration>(
- boost::chrono::system_clock::now().time_since_epoch()
- )
- );
-}
-
shared_ptr<const Data> g_response;
void
@@ -38,12 +28,12 @@
BOOST_AUTO_TEST_CASE(Status)
{
// initialize
- ndn::nfd::Status::Timestamp t1 = now();
+ time::system_clock::TimePoint t1 = time::system_clock::now();
Forwarder forwarder;
shared_ptr<InternalFace> internalFace = make_shared<InternalFace>();
internalFace->onReceiveData += &interceptResponse;
StatusServer statusServer(internalFace, boost::ref(forwarder));
- ndn::nfd::Status::Timestamp t2 = now();
+ time::system_clock::TimePoint t2 = time::system_clock::now();
// populate tables
forwarder.getFib().insert("ndn:/fib1");
@@ -64,9 +54,9 @@
request->setChildSelector(1);
g_response.reset();
- ndn::nfd::Status::Timestamp t3 = now();
+ time::system_clock::TimePoint t3 = time::system_clock::now();
internalFace->sendInterest(*request);
- ndn::nfd::Status::Timestamp t4 = now();
+ time::system_clock::TimePoint t4 = time::system_clock::now();
BOOST_REQUIRE(static_cast<bool>(g_response));
// verify
@@ -74,10 +64,10 @@
BOOST_REQUIRE_NO_THROW(status.wireDecode(g_response->getContent()));
BOOST_CHECK_EQUAL(status.getNfdVersion(), NFD_VERSION);
- BOOST_CHECK_GE(status.getStartTimestamp(), t1);
- BOOST_CHECK_LE(status.getStartTimestamp(), t2);
- BOOST_CHECK_GE(status.getCurrentTimestamp(), t3);
- BOOST_CHECK_LE(status.getCurrentTimestamp(), t4);
+ BOOST_CHECK_GE(time::toUnixTimestamp(status.getStartTimestamp()), time::toUnixTimestamp(t1));
+ BOOST_CHECK_LE(time::toUnixTimestamp(status.getStartTimestamp()), time::toUnixTimestamp(t2));
+ BOOST_CHECK_GE(time::toUnixTimestamp(status.getCurrentTimestamp()), time::toUnixTimestamp(t3));
+ BOOST_CHECK_LE(time::toUnixTimestamp(status.getCurrentTimestamp()), time::toUnixTimestamp(t4));
// StatusServer under test isn't added to Forwarder,
// so request and response won't affect table size
diff --git a/tests/table/cs.cpp b/tests/table/cs.cpp
index cf0929c..5bb6eb7 100644
--- a/tests/table/cs.cpp
+++ b/tests/table/cs.cpp
@@ -176,13 +176,13 @@
Name name2("/insert/fresh");
shared_ptr<Data> data2 = make_shared<Data>(name2);
- data2->setFreshnessPeriod(5000);
+ data2->setFreshnessPeriod(time::milliseconds(5000));
data2->setSignature(fakeSignature);
cs.insert(*data2);
Name name("/insert/expire");
shared_ptr<Data> data = make_shared<Data>(name);
- data->setFreshnessPeriod(500);
+ data->setFreshnessPeriod(time::milliseconds(500));
data->setSignature(fakeSignature);
cs.insert(*data);
@@ -508,7 +508,7 @@
Name name("/insert/nonfresh");
shared_ptr<Data> data = make_shared<Data>(name);
- data->setFreshnessPeriod(500);
+ data->setFreshnessPeriod(time::milliseconds(500));
data->setSignature(fakeSignature);
cs.insert(*data);
@@ -652,7 +652,7 @@
insert(uint32_t id, const Name& name)
{
shared_ptr<Data> data = make_shared<Data>(name);
- data->setFreshnessPeriod(99999);
+ data->setFreshnessPeriod(time::milliseconds(99999));
data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
ndn::SignatureSha256WithRsa fakeSignature;
diff --git a/tests/table/pit.cpp b/tests/table/pit.cpp
index bf1e073..17df2d7 100644
--- a/tests/table/pit.cpp
+++ b/tests/table/pit.cpp
@@ -21,16 +21,16 @@
Name name("ndn:/KuYfjtRq");
shared_ptr<Interest> interest = makeInterest(name);
shared_ptr<Interest> interest1 = makeInterest(name);
- interest1->setInterestLifetime(static_cast<ndn::Milliseconds>(2528));
+ interest1->setInterestLifetime(time::milliseconds(2528));
interest1->setNonce(25559);
shared_ptr<Interest> interest2 = makeInterest(name);
- interest2->setInterestLifetime(static_cast<ndn::Milliseconds>(6464));
+ interest2->setInterestLifetime(time::milliseconds(6464));
interest2->setNonce(19004);
shared_ptr<Interest> interest3 = makeInterest(name);
- interest3->setInterestLifetime(static_cast<ndn::Milliseconds>(3585));
+ interest3->setInterestLifetime(time::milliseconds(3585));
interest3->setNonce(24216);
shared_ptr<Interest> interest4 = makeInterest(name);
- interest4->setInterestLifetime(static_cast<ndn::Milliseconds>(8795));
+ interest4->setInterestLifetime(time::milliseconds(8795));
interest4->setNonce(17365);
pit::Entry entry(*interest);
@@ -44,10 +44,10 @@
BOOST_CHECK_EQUAL(outRecords1.size(), 0);
// insert InRecord
- time::Point before1 = time::now();
+ time::steady_clock::TimePoint before1 = time::steady_clock::now();
pit::InRecordCollection::iterator in1 =
entry.insertOrUpdateInRecord(face1, *interest1);
- time::Point after1 = time::now();
+ time::steady_clock::TimePoint after1 = time::steady_clock::now();
const pit::InRecordCollection& inRecords2 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords2.size(), 1);
BOOST_CHECK(in1 == inRecords2.begin());
@@ -55,15 +55,15 @@
BOOST_CHECK_EQUAL(in1->getLastNonce(), interest1->getNonce());
BOOST_CHECK_GE(in1->getLastRenewed(), before1);
BOOST_CHECK_LE(in1->getLastRenewed(), after1);
- BOOST_CHECK_LE(std::abs(in1->getExpiry() - in1->getLastRenewed()
- - time::milliseconds(interest1->getInterestLifetime())),
- (after1 - before1));
+ BOOST_CHECK_LE(in1->getExpiry() - in1->getLastRenewed()
+ - interest1->getInterestLifetime(),
+ (after1 - before1));
// insert OutRecord
- time::Point before2 = time::now();
+ time::steady_clock::TimePoint before2 = time::steady_clock::now();
pit::OutRecordCollection::iterator out1 =
entry.insertOrUpdateOutRecord(face1, *interest1);
- time::Point after2 = time::now();
+ time::steady_clock::TimePoint after2 = time::steady_clock::now();
const pit::OutRecordCollection& outRecords2 = entry.getOutRecords();
BOOST_CHECK_EQUAL(outRecords2.size(), 1);
BOOST_CHECK(out1 == outRecords2.begin());
@@ -71,23 +71,23 @@
BOOST_CHECK_EQUAL(out1->getLastNonce(), interest1->getNonce());
BOOST_CHECK_GE(out1->getLastRenewed(), before2);
BOOST_CHECK_LE(out1->getLastRenewed(), after2);
- BOOST_CHECK_LE(std::abs(out1->getExpiry() - out1->getLastRenewed()
- - time::milliseconds(interest1->getInterestLifetime())),
- (after2 - before2));
+ BOOST_CHECK_LE(out1->getExpiry() - out1->getLastRenewed()
+ - interest1->getInterestLifetime(),
+ (after2 - before2));
// update InRecord
- time::Point before3 = time::now();
+ time::steady_clock::TimePoint before3 = time::steady_clock::now();
pit::InRecordCollection::iterator in2 =
entry.insertOrUpdateInRecord(face1, *interest2);
- time::Point after3 = time::now();
+ time::steady_clock::TimePoint after3 = time::steady_clock::now();
const pit::InRecordCollection& inRecords3 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords3.size(), 1);
BOOST_CHECK(in2 == inRecords3.begin());
BOOST_CHECK_EQUAL(in2->getFace(), face1);
BOOST_CHECK_EQUAL(in2->getLastNonce(), interest2->getNonce());
- BOOST_CHECK_LE(std::abs(in2->getExpiry() - in2->getLastRenewed()
- - time::milliseconds(interest2->getInterestLifetime())),
- (after3 - before3));
+ BOOST_CHECK_LE(in2->getExpiry() - in2->getLastRenewed()
+ - interest2->getInterestLifetime(),
+ (after3 - before3));
// insert another InRecord
pit::InRecordCollection::iterator in3 =
@@ -130,16 +130,16 @@
BOOST_AUTO_TEST_CASE(EntryLifetime)
{
shared_ptr<Interest> interest = makeInterest("ndn:/7oIEurbgy6");
- BOOST_ASSERT(interest->getInterestLifetime() < 0); // library uses -1 to indicate unset lifetime
+ BOOST_ASSERT(interest->getInterestLifetime() < time::milliseconds::zero()); // library uses -1 to indicate unset lifetime
shared_ptr<Face> face = make_shared<DummyFace>();
pit::Entry entry(*interest);
pit::InRecordCollection::iterator inIt = entry.insertOrUpdateInRecord(face, *interest);
- BOOST_CHECK_GT(inIt->getExpiry(), time::now());
+ BOOST_CHECK_GT(inIt->getExpiry(), time::steady_clock::now());
pit::OutRecordCollection::iterator outIt = entry.insertOrUpdateOutRecord(face, *interest);
- BOOST_CHECK_GT(outIt->getExpiry(), time::now());
+ BOOST_CHECK_GT(outIt->getExpiry(), time::steady_clock::now());
}
BOOST_AUTO_TEST_CASE(EntryCanForwardTo)
@@ -174,27 +174,27 @@
exclude2.excludeOne(Name::Component("FG1Ni6nYcf"));
// base
- Interest interestA(name1, -1, -1, exclude0, -1, false, -1, -1.0, 0);
+ Interest interestA(name1, -1, -1, exclude0, -1, false, -1, time::milliseconds::min(), 0);
// A+exclude1
- Interest interestB(name1, -1, -1, exclude1, -1, false, -1, -1.0, 0);
+ Interest interestB(name1, -1, -1, exclude1, -1, false, -1, time::milliseconds::min(), 0);
// A+exclude2
- Interest interestC(name1, -1, -1, exclude2, -1, false, -1, -1.0, 0);
+ Interest interestC(name1, -1, -1, exclude2, -1, false, -1, time::milliseconds::min(), 0);
// A+MinSuffixComponents
- Interest interestD(name1, 2, -1, exclude0, -1, false, -1, -1.0, 0);
+ Interest interestD(name1, 2, -1, exclude0, -1, false, -1, time::milliseconds::min(), 0);
// A+MaxSuffixComponents
- Interest interestE(name1, -1, 4, exclude0, -1, false, -1, -1.0, 0);
+ Interest interestE(name1, -1, 4, exclude0, -1, false, -1, time::milliseconds::min(), 0);
// A+ChildSelector
- Interest interestF(name1, -1, -1, exclude0, 1, false, -1, -1.0, 0);
+ Interest interestF(name1, -1, -1, exclude0, 1, false, -1, time::milliseconds::min(), 0);
// A+MustBeFresh
- Interest interestG(name1, -1, -1, exclude0, -1, true, -1, -1.0, 0);
+ Interest interestG(name1, -1, -1, exclude0, -1, true, -1, time::milliseconds::min(), 0);
// A+Scope
- Interest interestH(name1, -1, -1, exclude0, -1, false, 2, -1.0, 0);
+ Interest interestH(name1, -1, -1, exclude0, -1, false, 2, time::milliseconds::min(), 0);
// A+InterestLifetime
- Interest interestI(name1, -1, -1, exclude0, -1, false, -1, 2000, 0);
+ Interest interestI(name1, -1, -1, exclude0, -1, false, -1, time::milliseconds(2000), 0);
// A+Nonce
- Interest interestJ(name1, -1, -1, exclude0, -1, false, -1, -1.0, 2192);
+ Interest interestJ(name1, -1, -1, exclude0, -1, false, -1, time::milliseconds::min(), 2192);
// different Name+exclude1
- Interest interestK(name2, -1, -1, exclude1, -1, false, -1, -1.0, 0);
+ Interest interestK(name2, -1, -1, exclude1, -1, false, -1, time::milliseconds::min(), 0);
NameTree nameTree(16);
Pit pit(nameTree);