util: make SegmentFetcher test suite run faster
UnitTestTimeFixture::advanceClocks is invoked with less ticks of
larger duration when feasible, so that test cases run faster.
UnitTestTimeFixture is synchronized from NFD codebase.
refs #2734
Change-Id: Ifd338f1008af8662bb9ea8f798f6cc2a922fb865
diff --git a/tests/unit-tests/security/certificate-cache-ttl.t.cpp b/tests/unit-tests/security/certificate-cache-ttl.t.cpp
index 4d3430d..6d35811 100644
--- a/tests/unit-tests/security/certificate-cache-ttl.t.cpp
+++ b/tests/unit-tests/security/certificate-cache-ttl.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -29,7 +29,8 @@
namespace ndn {
namespace tests {
-BOOST_AUTO_TEST_SUITE(SecurityCertificateCacheTtl)
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestCertificateCacheTtl)
class CertificateCacheFixture : public UnitTestTimeFixture
{
@@ -69,7 +70,7 @@
cache->insertCertificate(cert1);
cache->insertCertificate(cert2);
- advanceClocks(time::nanoseconds(0));
+ advanceClocks(time::nanoseconds(1));
BOOST_CHECK_EQUAL(cache->getSize(), 2);
scheduler.scheduleEvent(time::milliseconds(200), [&] {
@@ -97,7 +98,7 @@
{
cache->insertCertificate(cert1); // 500ms
- advanceClocks(time::nanoseconds(0));
+ advanceClocks(time::nanoseconds(1));
BOOST_CHECK_EQUAL(cache->getSize(), 1);
advanceClocks(time::milliseconds(400));
@@ -106,7 +107,7 @@
// Refresh certificate in cache
cache->insertCertificate(cert1); // +500ms
- advanceClocks(time::nanoseconds(0));
+ advanceClocks(time::nanoseconds(1));
BOOST_CHECK_EQUAL(cache->getSize(), 1);
advanceClocks(time::milliseconds(400));
@@ -121,16 +122,17 @@
cache->insertCertificate(cert1);
cache->insertCertificate(cert2);
- advanceClocks(time::nanoseconds(0));
+ advanceClocks(time::nanoseconds(1));
BOOST_CHECK_EQUAL(cache->getSize(), 2);
cache->reset();
- advanceClocks(time::nanoseconds(0));
+ advanceClocks(time::nanoseconds(1));
BOOST_CHECK_EQUAL(cache->getSize(), 0);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestCertificateCacheTtl
+BOOST_AUTO_TEST_SUITE_END() // Security
} // namespace tests
} // namespace ndn
diff --git a/tests/unit-tests/security/validator-config.t.cpp b/tests/unit-tests/security/validator-config.t.cpp
index 1c72e69..005ca9b 100644
--- a/tests/unit-tests/security/validator-config.t.cpp
+++ b/tests/unit-tests/security/validator-config.t.cpp
@@ -38,7 +38,8 @@
using namespace ndn::tests;
-BOOST_FIXTURE_TEST_SUITE(SecurityValidatorConfig, IdentityManagementFixture)
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_FIXTURE_TEST_SUITE(TestValidatorConfig, IdentityManagementFixture)
BOOST_AUTO_TEST_CASE(NameFilter)
{
@@ -1287,7 +1288,7 @@
BOOST_FIXTURE_TEST_CASE(Nrd, FacesFixture)
{
- advanceClocks(time::milliseconds(0));
+ advanceClocks(time::nanoseconds(1));
std::vector<CertificateSubjectDescription> subjectDescription;
@@ -1577,7 +1578,8 @@
advanceClocks(time::milliseconds(10), 20);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestValidatorConfig
+BOOST_AUTO_TEST_SUITE_END() // Security
} // namespace tests
} // namespace security