core+daemon: eliminate scheduler::{schedule,cancel} wrappers

Also move core/global-io.hpp to daemon/global.hpp

Refs: #4528, #4883
Change-Id: I0b99029f1a19d7451aab57099cd3303b7eb42ff3
diff --git a/tests/core/scheduler.t.cpp b/tests/core/scheduler.t.cpp
deleted file mode 100644
index 8e319e0..0000000
--- a/tests/core/scheduler.t.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2019,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "core/scheduler.hpp"
-
-#include "tests/test-common.hpp"
-
-#include <thread>
-
-namespace nfd {
-namespace scheduler {
-// defined in scheduler.cpp
-Scheduler&
-getGlobalScheduler();
-} // namespace scheduler
-
-namespace tests {
-
-BOOST_FIXTURE_TEST_SUITE(TestScheduler, BaseFixture)
-
-BOOST_AUTO_TEST_CASE(ScheduleCancel)
-{
-  int count1 = 0, count2 = 0, count3 = 0;
-
-  scheduler::schedule(500_ms, [&] {
-    BOOST_CHECK_EQUAL(count3, 1);
-    ++count1;
-  });
-
-  scheduler::EventId eid = scheduler::schedule(1_s, [&] { ++count2; });
-  scheduler::cancel(eid);
-
-  scheduler::schedule(250_ms, [&] {
-    BOOST_CHECK_EQUAL(count1, 0);
-    ++count3;
-  });
-
-  {
-    scheduler::ScopedEventId se = scheduler::schedule(50_ms, [&] { ++count2; });
-  } // se goes out of scope, canceling the event
-
-  g_io.run();
-
-  BOOST_CHECK_EQUAL(count1, 1);
-  BOOST_CHECK_EQUAL(count2, 0);
-  BOOST_CHECK_EQUAL(count3, 1);
-}
-
-BOOST_AUTO_TEST_CASE(ThreadLocalScheduler)
-{
-  scheduler::Scheduler* s1 = &scheduler::getGlobalScheduler();
-  scheduler::Scheduler* s2 = nullptr;
-  std::thread t([&s2] { s2 = &scheduler::getGlobalScheduler(); });
-  t.join();
-
-  BOOST_CHECK(s1 != nullptr);
-  BOOST_CHECK(s2 != nullptr);
-  BOOST_CHECK(s1 != s2);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // TestScheduler
-
-} // namespace tests
-} // namespace nfd
diff --git a/tests/daemon/face/channel-fixture.hpp b/tests/daemon/face/channel-fixture.hpp
index 7efedfd..8f94a09 100644
--- a/tests/daemon/face/channel-fixture.hpp
+++ b/tests/daemon/face/channel-fixture.hpp
@@ -27,7 +27,8 @@
 #define NFD_TESTS_DAEMON_FACE_CHANNEL_FIXTURE_HPP
 
 #include "face/channel.hpp"
-#include "tests/limited-io.hpp"
+
+#include "tests/daemon/limited-io.hpp"
 
 #include <type_traits>
 
diff --git a/tests/daemon/face/ethernet-fixture.hpp b/tests/daemon/face/ethernet-fixture.hpp
index 993352d..0a75fcc 100644
--- a/tests/daemon/face/ethernet-fixture.hpp
+++ b/tests/daemon/face/ethernet-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,
@@ -29,7 +29,7 @@
 #include "face/multicast-ethernet-transport.hpp"
 #include "face/unicast-ethernet-transport.hpp"
 
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 #include "test-netif.hpp"
 
 namespace nfd {
diff --git a/tests/daemon/face/multicast-ethernet-transport.t.cpp b/tests/daemon/face/multicast-ethernet-transport.t.cpp
index d4e1fce..220274c 100644
--- a/tests/daemon/face/multicast-ethernet-transport.t.cpp
+++ b/tests/daemon/face/multicast-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,
@@ -27,6 +27,8 @@
 
 #include "ethernet-fixture.hpp"
 
+#include "daemon/global.hpp"
+
 namespace nfd {
 namespace face {
 namespace tests {
@@ -66,7 +68,7 @@
   BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP);
 
   // simulate 'ip link set IFNAME down'
-  scheduler::schedule(10_ms, [=] { netif->setState(ndn::net::InterfaceState::DOWN); });
+  getScheduler().schedule(10_ms, [=] { netif->setState(ndn::net::InterfaceState::DOWN); });
   transport->afterStateChange.connectSingleShot([&] (TransportState oldState, TransportState newState) {
     BOOST_CHECK_EQUAL(oldState, TransportState::UP);
     BOOST_CHECK_EQUAL(newState, TransportState::DOWN);
@@ -76,8 +78,8 @@
   BOOST_CHECK_EQUAL(transport->getState(), TransportState::DOWN);
 
   // simulate 'ip link set IFNAME up'
-  scheduler::schedule(10_ms, [=] { netif->setState(ndn::net::InterfaceState::NO_CARRIER); });
-  scheduler::schedule(80_ms, [=] { netif->setState(ndn::net::InterfaceState::RUNNING); });
+  getScheduler().schedule(10_ms, [=] { netif->setState(ndn::net::InterfaceState::NO_CARRIER); });
+  getScheduler().schedule(80_ms, [=] { netif->setState(ndn::net::InterfaceState::RUNNING); });
   transport->afterStateChange.connectSingleShot([&] (TransportState oldState, TransportState newState) {
     BOOST_CHECK_EQUAL(oldState, TransportState::DOWN);
     BOOST_CHECK_EQUAL(newState, TransportState::UP);
diff --git a/tests/daemon/face/multicast-udp-transport-fixture.hpp b/tests/daemon/face/multicast-udp-transport-fixture.hpp
index 5959821..06455c7 100644
--- a/tests/daemon/face/multicast-udp-transport-fixture.hpp
+++ b/tests/daemon/face/multicast-udp-transport-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,
@@ -30,7 +30,7 @@
 #include "face/face.hpp"
 
 #include "dummy-receive-link-service.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index d349cf9..3c00134 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-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,
@@ -27,7 +27,7 @@
 
 #include "face-system-fixture.hpp"
 #include "factory-test-common.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/tcp-transport-fixture.hpp b/tests/daemon/face/tcp-transport-fixture.hpp
index 0cfae44..65a4d24 100644
--- a/tests/daemon/face/tcp-transport-fixture.hpp
+++ b/tests/daemon/face/tcp-transport-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,
@@ -30,7 +30,7 @@
 #include "face/face.hpp"
 
 #include "dummy-receive-link-service.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/test-netif.cpp b/tests/daemon/face/test-netif.cpp
index c1a734d..a19623f 100644
--- a/tests/daemon/face/test-netif.cpp
+++ b/tests/daemon/face/test-netif.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "test-netif.hpp"
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/unicast-udp-transport-fixture.hpp b/tests/daemon/face/unicast-udp-transport-fixture.hpp
index e30a6a2..b269a71 100644
--- a/tests/daemon/face/unicast-udp-transport-fixture.hpp
+++ b/tests/daemon/face/unicast-udp-transport-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,
@@ -30,7 +30,7 @@
 #include "face/face.hpp"
 
 #include "dummy-receive-link-service.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/unix-stream-transport-fixture.hpp b/tests/daemon/face/unix-stream-transport-fixture.hpp
index 634bb9a..d131a00 100644
--- a/tests/daemon/face/unix-stream-transport-fixture.hpp
+++ b/tests/daemon/face/unix-stream-transport-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,
@@ -30,7 +30,7 @@
 #include "face/face.hpp"
 
 #include "dummy-receive-link-service.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 #include <boost/filesystem.hpp>
 
diff --git a/tests/daemon/face/websocket-transport-fixture.hpp b/tests/daemon/face/websocket-transport-fixture.hpp
index 374f922..38ab81c 100644
--- a/tests/daemon/face/websocket-transport-fixture.hpp
+++ b/tests/daemon/face/websocket-transport-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,
@@ -30,7 +30,7 @@
 #include "face/face.hpp"
 
 #include "dummy-receive-link-service.hpp"
-#include "tests/limited-io.hpp"
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/fw/asf-measurements.t.cpp b/tests/daemon/fw/asf-measurements.t.cpp
index cc4c9e4..71491b7 100644
--- a/tests/daemon/fw/asf-measurements.t.cpp
+++ b/tests/daemon/fw/asf-measurements.t.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "fw/asf-measurements.hpp"
+#include "daemon/global.hpp"
 
 #include "tests/daemon/face/dummy-face.hpp"
 #include "tests/test-common.hpp"
@@ -85,7 +86,7 @@
 {
   FaceInfo info;
 
-  scheduler::EventId id = scheduler::schedule(time::seconds(1), []{});
+  auto id = getScheduler().schedule(1_s, []{});
   ndn::Name interestName("/ndn/interest");
 
   // Receive Interest and forward to next hop; should update RTO information
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 80e2603..83f9903 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "fw/best-route-strategy2.hpp"
+#include "daemon/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
@@ -108,17 +109,17 @@
     size_t nSent = strategy.sendInterestHistory.size();
     if (nSent > nSentLast) {
       BOOST_CHECK_EQUAL(nSent - nSentLast, 1);
-      time::steady_clock::TimePoint timeSent = time::steady_clock::now();
+      auto timeSent = time::steady_clock::now();
       BOOST_CHECK_GE(timeSent - timeSentLast, TICK * 8);
       nSentLast = nSent;
       timeSentLast = timeSent;
     }
 
-    retxFrom4Evt = scheduler::schedule(TICK * 5, periodicalRetxFrom4);
+    retxFrom4Evt = getScheduler().schedule(TICK * 5, periodicalRetxFrom4);
   };
   periodicalRetxFrom4();
   this->advanceClocks(TICK, BestRouteStrategy2::RETX_SUPPRESSION_MAX * 16);
-  scheduler::cancel(retxFrom4Evt);
+  retxFrom4Evt.cancel();
 
   // nexthops for accepted retransmissions: follow FIB cost,
   // later forward to an eligible upstream with earliest out-record
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 2c7c1d2..60c8ea4 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "fw/forwarder.hpp"
+#include "daemon/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
@@ -545,7 +546,7 @@
   face2->afterSend.connect([face1, face2] (uint32_t pktType) {
     if (pktType == tlv::Interest) {
       auto interest = make_shared<Interest>(face2->sentInterests.back());
-      scheduler::schedule(time::milliseconds(170), [face1, interest] { face1->receiveInterest(*interest); });
+      getScheduler().schedule(170_ms, [face1, interest] { face1->receiveInterest(*interest); });
     }
   });
 
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index 1ee1ae9..e3ed88b 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -24,10 +24,11 @@
  */
 
 #include "fw/multicast-strategy.hpp"
-#include "strategy-tester.hpp"
-#include "tests/daemon/face/dummy-face.hpp"
+#include "daemon/global.hpp"
 
+#include "tests/daemon/face/dummy-face.hpp"
 #include "tests/test-common.hpp"
+#include "strategy-tester.hpp"
 
 namespace nfd {
 namespace fw {
@@ -108,17 +109,17 @@
     if (nSent > nSentLast) {
       // Multicast strategy should multicast the interest to other two faces
       BOOST_CHECK_EQUAL(nSent - nSentLast, 2);
-      time::steady_clock::TimePoint timeSent = time::steady_clock::now();
+      auto timeSent = time::steady_clock::now();
       BOOST_CHECK_GE(timeSent - timeSentLast, TICK * 8);
       nSentLast = nSent;
       timeSentLast = timeSent;
     }
 
-    retxFrom4Evt = scheduler::schedule(TICK * 5, periodicalRetxFrom4);
+    retxFrom4Evt = getScheduler().schedule(TICK * 5, periodicalRetxFrom4);
   };
   periodicalRetxFrom4();
   this->advanceClocks(TICK, MulticastStrategy::RETX_SUPPRESSION_MAX * 16);
-  scheduler::cancel(retxFrom4Evt);
+  retxFrom4Evt.cancel();
 }
 
 BOOST_AUTO_TEST_CASE(RejectLoopback)
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index 1b71aa2..4044251 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -24,12 +24,10 @@
  */
 
 #include "fw/ncc-strategy.hpp"
+
+#include "tests/daemon/face/dummy-face.hpp"
 #include "strategy-tester.hpp"
 #include "topology-tester.hpp"
-#include "tests/daemon/face/dummy-face.hpp"
-#include "tests/limited-io.hpp"
-
-#include "tests/test-common.hpp"
 
 namespace nfd {
 namespace fw {
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index 86c47f6..3d61452 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -31,12 +31,11 @@
 #include "fw/best-route-strategy2.hpp"
 #include "fw/multicast-strategy.hpp"
 
-#include "tests/test-common.hpp"
-#include "tests/limited-io.hpp"
 #include "choose-strategy.hpp"
 #include "strategy-tester.hpp"
 #include "topology-tester.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
+
 #include <boost/mpl/vector.hpp>
 
 namespace nfd {
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
index 3c5be6b..6e8aa8a 100644
--- a/tests/daemon/fw/strategy-no-route.t.cpp
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -34,11 +34,10 @@
 #include "fw/best-route-strategy2.hpp"
 #include "fw/multicast-strategy.hpp"
 
-#include "tests/test-common.hpp"
-#include "tests/limited-io.hpp"
 #include "choose-strategy.hpp"
 #include "strategy-tester.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
+
 #include <boost/mpl/copy_if.hpp>
 #include <boost/mpl/vector.hpp>
 
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 984c792..c97e8ab 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -35,11 +35,10 @@
 #include "fw/multicast-strategy.hpp"
 #include "fw/ncc-strategy.hpp"
 
-#include "tests/test-common.hpp"
-#include "tests/limited-io.hpp"
 #include "choose-strategy.hpp"
 #include "strategy-tester.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
+
 #include <boost/mpl/copy_if.hpp>
 #include <boost/mpl/vector.hpp>
 
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index 5b5c98d..f2ac93d 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -27,7 +27,8 @@
 #define NFD_TESTS_DAEMON_FW_STRATEGY_TESTER_HPP
 
 #include "fw/strategy.hpp"
-#include "tests/limited-io.hpp"
+
+#include "tests/daemon/limited-io.hpp"
 
 namespace nfd {
 namespace fw {
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 15bbc3c..c401aef 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "topology-tester.hpp"
+#include "daemon/global.hpp"
 #include "face/generic-link-service.hpp"
 
 #include <ndn-cxx/encoding/encoding-buffer-fwd.hpp>
@@ -98,7 +99,7 @@
 void
 TopologyLink::scheduleReceive(InternalTransportBase* recipient, const Block& packet)
 {
-  scheduler::schedule(m_delay, [packet, recipient] {
+  getScheduler().schedule(m_delay, [packet, recipient] {
     recipient->receiveFromLink(packet);
   });
 }
@@ -271,8 +272,9 @@
   face.expressInterest(*interest, nullptr, nullptr, nullptr);
 
   if (n > 1) {
-    scheduler::schedule(interval,
-                        [=, &face] { addIntervalConsumer(face, prefix, interval, n - 1, seq); });
+    getScheduler().schedule(interval, [=, &face] {
+      addIntervalConsumer(face, prefix, interval, n - 1, seq);
+    });
   }
 }
 
diff --git a/tests/core/global-io.t.cpp b/tests/daemon/global.t.cpp
similarity index 85%
rename from tests/core/global-io.t.cpp
rename to tests/daemon/global.t.cpp
index 02f5c4c..bdde1ba 100644
--- a/tests/core/global-io.t.cpp
+++ b/tests/daemon/global.t.cpp
@@ -23,27 +23,37 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "core/global-io.hpp"
-#include "core/scheduler.hpp"
+#include "daemon/global.hpp"
 
-#include "tests/rib-io-fixture.hpp"
 #include "tests/test-common.hpp"
+#include "tests/daemon/rib-io-fixture.hpp"
 
 #include <thread>
 
 namespace nfd {
 namespace tests {
 
-BOOST_FIXTURE_TEST_SUITE(TestGlobalIo, BaseFixture)
+BOOST_FIXTURE_TEST_SUITE(TestGlobal, BaseFixture)
 
-BOOST_AUTO_TEST_CASE(ThreadLocalGlobalIoService)
+BOOST_AUTO_TEST_CASE(ThreadLocalIoService)
 {
   boost::asio::io_service* s1 = &getGlobalIoService();
   boost::asio::io_service* s2 = nullptr;
-  std::thread t([&s2] {
-    s2 = &getGlobalIoService();
-  });
 
+  std::thread t([&s2] { s2 = &getGlobalIoService(); });
+  t.join();
+
+  BOOST_CHECK(s1 != nullptr);
+  BOOST_CHECK(s2 != nullptr);
+  BOOST_CHECK(s1 != s2);
+}
+
+BOOST_AUTO_TEST_CASE(ThreadLocalScheduler)
+{
+  scheduler::Scheduler* s1 = &getScheduler();
+  scheduler::Scheduler* s2 = nullptr;
+
+  std::thread t([&s2] { s2 = &getScheduler(); });
   t.join();
 
   BOOST_CHECK(s1 != nullptr);
@@ -115,7 +125,7 @@
 
   hasRibRun = false;
   bool hasMainRun = false;
-  scheduler::schedule(250_ms, [&] {
+  getScheduler().schedule(250_ms, [&] {
     hasMainRun = true;
     runOnRibIoService([&] { hasRibRun = true; });
   });
@@ -127,7 +137,7 @@
   BOOST_CHECK_EQUAL(hasRibRun, true);
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestGlobal
 
 } // namespace tests
 } // namespace nfd
diff --git a/tests/limited-io.cpp b/tests/daemon/limited-io.cpp
similarity index 93%
rename from tests/limited-io.cpp
rename to tests/daemon/limited-io.cpp
index a9da60e..2779b24 100644
--- a/tests/limited-io.cpp
+++ b/tests/daemon/limited-io.cpp
@@ -24,8 +24,8 @@
  */
 
 #include "limited-io.hpp"
-#include "core/global-io.hpp"
 #include "core/logger.hpp"
+#include "daemon/global.hpp"
 
 #include <boost/exception/diagnostic_information.hpp>
 
@@ -39,8 +39,6 @@
 
 LimitedIo::LimitedIo(UnitTestTimeFixture* uttf)
   : m_uttf(uttf)
-  , m_nOpsRemaining(0)
-  , m_isRunning(false)
 {
 }
 
@@ -58,7 +56,7 @@
   m_reason = NO_WORK;
   m_nOpsRemaining = nOpsLimit;
   if (timeLimit >= 0_ns) {
-    m_timeout = scheduler::schedule(timeLimit, [this] { afterTimeout(); });
+    m_timeout = getScheduler().schedule(timeLimit, [this] { afterTimeout(); });
   }
 
   try {
@@ -79,7 +77,7 @@
   }
 
   getGlobalIoService().reset();
-  scheduler::cancel(m_timeout);
+  m_timeout.cancel();
   m_isRunning = false;
 
   return m_reason;
diff --git a/tests/limited-io.hpp b/tests/daemon/limited-io.hpp
similarity index 89%
rename from tests/limited-io.hpp
rename to tests/daemon/limited-io.hpp
index a42a797..7e7ecc4 100644
--- a/tests/limited-io.hpp
+++ b/tests/daemon/limited-io.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,
@@ -23,11 +23,10 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef NFD_TESTS_LIMITED_IO_HPP
-#define NFD_TESTS_LIMITED_IO_HPP
+#ifndef NFD_TESTS_DAEMON_LIMITED_IO_HPP
+#define NFD_TESTS_DAEMON_LIMITED_IO_HPP
 
-#include "test-common.hpp"
-#include "core/scheduler.hpp"
+#include "tests/test-common.hpp"
 
 #include <exception>
 
@@ -41,12 +40,10 @@
 class LimitedIo : noncopyable
 {
 public:
-  /** \brief construct with UnitTestTimeFixture
-   */
   explicit
   LimitedIo(UnitTestTimeFixture* uttf = nullptr);
 
-  /// indicates why .run returns
+  /// indicates why run() returns
   enum StopReason {
     /// g_io.run() returns normally because there's no work to do
     NO_WORK,
@@ -105,13 +102,13 @@
 private:
   UnitTestTimeFixture* m_uttf;
   StopReason m_reason;
-  int m_nOpsRemaining;
+  int m_nOpsRemaining = 0;
   scheduler::EventId m_timeout;
   std::exception_ptr m_lastException;
-  bool m_isRunning;
+  bool m_isRunning = false;
 };
 
 } // namespace tests
 } // namespace nfd
 
-#endif // NFD_TESTS_LIMITED_IO_HPP
+#endif // NFD_TESTS_DAEMON_LIMITED_IO_HPP
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.cpp b/tests/daemon/mgmt/face-manager-command-fixture.cpp
index 8fcb965..16e99c6 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.cpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.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,
@@ -24,6 +24,7 @@
  */
 
 #include "face-manager-command-fixture.hpp"
+#include "daemon/global.hpp"
 
 #include <ndn-cxx/net/network-monitor-stub.hpp>
 
diff --git a/tests/daemon/mgmt/manager-common-fixture.cpp b/tests/daemon/mgmt/manager-common-fixture.cpp
index ee8d543..ed4344e 100644
--- a/tests/daemon/mgmt/manager-common-fixture.cpp
+++ b/tests/daemon/mgmt/manager-common-fixture.cpp
@@ -54,7 +54,7 @@
 }
 
 ManagerCommonFixture::ManagerCommonFixture()
-  : m_face(getGlobalIoService(), m_keyChain, {true, true})
+  : m_face(g_io, m_keyChain, {true, true})
   , m_dispatcher(m_face, m_keyChain, ndn::security::SigningInfo())
   , m_responses(m_face.sentData)
 {
diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 452d758..5576878 100644
--- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -163,7 +163,7 @@
 
 private:
   ndn::util::DummyClientFace m_face;
-  ndn::util::Scheduler m_scheduler;
+  Scheduler m_scheduler;
   ndn::nfd::Controller m_nfdController;
   Dispatcher m_dispatcher;
   rib::FibUpdater m_fibUpdater;
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index c3c5dd6..9756a36 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -205,7 +205,7 @@
   std::vector<Interest>& m_commands;
   ConfigurationStatus m_status;
 
-  ndn::util::Scheduler m_scheduler;
+  Scheduler m_scheduler;
   ndn::nfd::Controller m_nfdController;
   rib::Rib m_rib;
   rib::FibUpdater m_fibUpdater;
diff --git a/tests/rib-io-fixture.cpp b/tests/daemon/rib-io-fixture.cpp
similarity index 98%
rename from tests/rib-io-fixture.cpp
rename to tests/daemon/rib-io-fixture.cpp
index 8702994..251d6e9 100644
--- a/tests/rib-io-fixture.cpp
+++ b/tests/daemon/rib-io-fixture.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "rib-io-fixture.hpp"
+#include "daemon/global.hpp"
 
 #include <boost/exception/diagnostic_information.hpp>
 
diff --git a/tests/rib-io-fixture.hpp b/tests/daemon/rib-io-fixture.hpp
similarity index 95%
rename from tests/rib-io-fixture.hpp
rename to tests/daemon/rib-io-fixture.hpp
index f2bb892..99d4387 100644
--- a/tests/rib-io-fixture.hpp
+++ b/tests/daemon/rib-io-fixture.hpp
@@ -23,8 +23,8 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef NFD_TESTS_RIB_IO_FIXTURE_HPP
-#define NFD_TESTS_RIB_IO_FIXTURE_HPP
+#ifndef NFD_TESTS_DAEMON_RIB_IO_FIXTURE_HPP
+#define NFD_TESTS_DAEMON_RIB_IO_FIXTURE_HPP
 
 #include "tests/test-common.hpp"
 
@@ -102,4 +102,4 @@
 } // namespace tests
 } // namespace nfd
 
-#endif // NFD_TESTS_RIB_IO_FIXTURE_HPP
+#endif // NFD_TESTS_DAEMON_RIB_IO_FIXTURE_HPP
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 4967788..d3ec057 100644
--- a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
+++ b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
@@ -58,7 +58,7 @@
 
 protected:
   ndn::util::DummyClientFace face;
-  ndn::util::Scheduler scheduler;
+  Scheduler scheduler;
   ndn::nfd::Controller controller;
   Rib rib;
   NfdRibReadvertiseDestination dest;
diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp
index 1ff0f85..f73efbd 100644
--- a/tests/daemon/rib/readvertise/readvertise.t.cpp
+++ b/tests/daemon/rib/readvertise/readvertise.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,
@@ -159,7 +159,7 @@
 
 private:
   ndn::util::DummyClientFace m_face;
-  ndn::util::Scheduler m_scheduler;
+  Scheduler m_scheduler;
   Rib m_rib;
 };
 
diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp
index 14ee649..156257b 100644
--- a/tests/daemon/rib/service.t.cpp
+++ b/tests/daemon/rib/service.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,
@@ -24,8 +24,10 @@
  */
 
 #include "rib/service.hpp"
-#include "tests/rib-io-fixture.hpp"
+#include "daemon/global.hpp"
+
 #include "tests/test-common.hpp"
+#include "tests/daemon/rib-io-fixture.hpp"
 
 namespace nfd {
 namespace rib {
diff --git a/tests/daemon/table/dead-nonce-list.t.cpp b/tests/daemon/table/dead-nonce-list.t.cpp
index 599a7e2..1df1070 100644
--- a/tests/daemon/table/dead-nonce-list.t.cpp
+++ b/tests/daemon/table/dead-nonce-list.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,
@@ -24,6 +24,7 @@
  */
 
 #include "table/dead-nonce-list.hpp"
+#include "daemon/global.hpp"
 
 #include "tests/test-common.hpp"
 
@@ -85,8 +86,7 @@
     }
 
     if (addNonceInterval > time::nanoseconds::zero()) {
-      addNonceEvent = scheduler::schedule(addNonceInterval,
-                                          bind(&PeriodicalInsertionFixture::addNonce, this));
+      addNonceEvent = getScheduler().schedule(addNonceInterval, [this] { addNonce(); });
     }
   }
 
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index 19aac7c..3ab1dda 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -23,7 +23,7 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "core/global-io.hpp"
+#include "daemon/global.hpp"
 #include "face/face.hpp"
 #include "face/tcp-channel.hpp"
 #include "face/udp-channel.hpp"
diff --git a/tests/test-common.cpp b/tests/test-common.cpp
index 62e728a..59060d6 100644
--- a/tests/test-common.cpp
+++ b/tests/test-common.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,
@@ -24,6 +24,8 @@
  */
 
 #include "test-common.hpp"
+#include "daemon/global.hpp"
+
 #include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
 
 namespace nfd {
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index c01484c..178502a 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.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,
@@ -28,7 +28,7 @@
 
 #include "boost-test.hpp"
 
-#include "core/global-io.hpp"
+#include "core/common.hpp"
 
 #include <ndn-cxx/prefix-announcement.hpp>
 #include <ndn-cxx/util/time-unit-test-clock.hpp>
@@ -157,22 +157,22 @@
  *  \param index name component index
  *  \param a arguments to name::Component constructor
  */
-template<typename...A>
+template<typename... A>
 void
-setNameComponent(Name& name, ssize_t index, const A& ...a)
+setNameComponent(Name& name, ssize_t index, A&&... a)
 {
   Name name2 = name.getPrefix(index);
-  name2.append(name::Component(a...));
+  name2.append(name::Component(std::forward<A>(a)...));
   name2.append(name.getSubName(name2.size()));
-  name = name2;
+  name = std::move(name2);
 }
 
-template<typename Packet, typename...A>
+template<typename Packet, typename... A>
 void
-setNameComponent(Packet& packet, ssize_t index, const A& ...a)
+setNameComponent(Packet& packet, ssize_t index, A&&... a)
 {
   Name name = packet.getName();
-  setNameComponent(name, index, a...);
+  setNameComponent(name, index, std::forward<A>(a)...);
   packet.setName(name);
 }
 
diff --git a/tests/tools/nfdc/status-report.t.cpp b/tests/tools/nfdc/status-report.t.cpp
index 5cd25f9..d15b901 100644
--- a/tests/tools/nfdc/status-report.t.cpp
+++ b/tests/tools/nfdc/status-report.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,
@@ -24,7 +24,6 @@
  */
 
 #include "nfdc/status-report.hpp"
-#include "core/scheduler.hpp"
 
 #include "status-fixture.hpp"
 
@@ -49,9 +48,9 @@
 class DummyModule : public Module
 {
 public:
-  explicit
-  DummyModule(const std::string& moduleName)
+  DummyModule(const std::string& moduleName, boost::asio::io_service& io)
     : m_moduleName(moduleName)
+    , m_scheduler(io)
     , m_res(0)
     , m_delay(time::milliseconds(1))
   {
@@ -70,13 +69,13 @@
   }
 
   void
-  fetchStatus(Controller& controller,
+  fetchStatus(Controller&,
               const std::function<void()>& onSuccess,
               const Controller::DatasetFailCallback& onFailure,
-              const CommandOptions& options) final
+              const CommandOptions&) final
   {
     ++nFetchStatusCalls;
-    scheduler::schedule(m_delay, [=] {
+    m_scheduler.schedule(m_delay, [=] {
       if (m_res == 0) {
         onSuccess();
       }
@@ -103,6 +102,7 @@
 
 private:
   std::string m_moduleName;
+  Scheduler m_scheduler;
   uint32_t m_res;
   time::nanoseconds m_delay;
 };
@@ -133,7 +133,7 @@
   DummyModule&
   addModule(const std::string& moduleName)
   {
-    report.sections.push_back(make_unique<DummyModule>(moduleName));
+    report.sections.push_back(make_unique<DummyModule>(moduleName, g_io));
     return static_cast<DummyModule&>(*report.sections.back());
   }
 
diff --git a/tests/wscript b/tests/wscript
index 7f5b321..9c17ad3 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -62,6 +62,10 @@
                 src += node.ant_glob('face/unix*.cpp')
             if bld.env.HAVE_WEBSOCKET:
                 src += node.ant_glob('face/websocket*.cpp')
+            if module == 'core' or module == 'tools':
+                src += ['../daemon/global.cpp']
+            if module == 'rib':
+                src += ['daemon/limited-io.cpp', 'daemon/rib-io-fixture.cpp']
 
             objmod = 'daemon' if module == 'rib' else module
             # unit-tests binary for the module