core: move nfd-specific files to daemon/

Refs: #4922
Change-Id: I2243dbb87c63f9cbaf7d7051d7a0d4bca2f9fdb5
diff --git a/tests/daemon/common/config-file.t.cpp b/tests/daemon/common/config-file.t.cpp
new file mode 100644
index 0000000..8eae4fb
--- /dev/null
+++ b/tests/daemon/common/config-file.t.cpp
@@ -0,0 +1,331 @@
+/* -*- 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 "common/config-file.hpp"
+
+#include "tests/test-common.hpp"
+
+#include <boost/property_tree/info_parser.hpp>
+#include <fstream>
+#include <sstream>
+
+namespace nfd {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestConfigFile)
+
+static const std::string CONFIG = R"CONFIG(
+  a
+  {
+    akey avalue
+  }
+  b
+  {
+    bkey bvalue
+  }
+)CONFIG";
+
+// counts of the respective section counts in config_example.info
+const int CONFIG_N_A_SECTIONS = 1;
+const int CONFIG_N_B_SECTIONS = 1;
+
+class DummySubscriber
+{
+public:
+  DummySubscriber(ConfigFile& config, int nASections, int nBSections, bool expectDryRun)
+    : m_nASections(nASections)
+    , m_nBSections(nBSections)
+    , m_nRemainingACallbacks(nASections)
+    , m_nRemainingBCallbacks(nBSections)
+    , m_expectDryRun(expectDryRun)
+  {
+  }
+
+  void
+  onA(const ConfigSection& section, bool isDryRun)
+  {
+    BOOST_CHECK_EQUAL(isDryRun, m_expectDryRun);
+    --m_nRemainingACallbacks;
+  }
+
+  void
+  onB(const ConfigSection& section, bool isDryRun)
+  {
+    BOOST_CHECK_EQUAL(isDryRun, m_expectDryRun);
+    --m_nRemainingBCallbacks;
+  }
+
+  bool
+  allCallbacksFired() const
+  {
+    return m_nRemainingACallbacks == 0 &&
+      m_nRemainingBCallbacks == 0;
+  }
+
+  bool
+  noCallbacksFired() const
+  {
+    return m_nRemainingACallbacks == m_nASections &&
+      m_nRemainingBCallbacks == m_nBSections;
+  }
+
+private:
+  int m_nASections;
+  int m_nBSections;
+  int m_nRemainingACallbacks;
+  int m_nRemainingBCallbacks;
+  bool m_expectDryRun;
+};
+
+class DummyAllSubscriber : public DummySubscriber
+{
+public:
+  explicit
+  DummyAllSubscriber(ConfigFile& config, bool expectDryRun = false)
+    : DummySubscriber(config, CONFIG_N_A_SECTIONS, CONFIG_N_B_SECTIONS, expectDryRun)
+  {
+    config.addSectionHandler("a", bind(&DummySubscriber::onA, this, _1, _2));
+    config.addSectionHandler("b", bind(&DummySubscriber::onB, this, _1, _2));
+  }
+};
+
+class DummyOneSubscriber : public DummySubscriber
+{
+public:
+  DummyOneSubscriber(ConfigFile& config, const std::string& sectionName, bool expectDryRun = false)
+    : DummySubscriber(config,
+                      (sectionName == "a"),
+                      (sectionName == "b"),
+                      expectDryRun)
+  {
+    if (sectionName == "a") {
+      config.addSectionHandler(sectionName, bind(&DummySubscriber::onA, this, _1, _2));
+    }
+    else if (sectionName == "b") {
+      config.addSectionHandler(sectionName, bind(&DummySubscriber::onB, this, _1, _2));
+    }
+    else {
+      BOOST_FAIL("Test setup error: Unexpected section name '" << sectionName << "'");
+    }
+  }
+};
+
+class DummyNoSubscriber : public DummySubscriber
+{
+public:
+  DummyNoSubscriber(ConfigFile& config, bool expectDryRun)
+    : DummySubscriber(config, 0, 0, expectDryRun)
+  {
+  }
+};
+
+BOOST_AUTO_TEST_CASE(ParseFromStream)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  std::ifstream input("tests/daemon/common/config_example.info");
+  BOOST_REQUIRE(input.is_open());
+
+  file.parse(input, false, "config_example.info");
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromEmptyStream)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  std::istringstream input;
+
+  file.parse(input, false, "empty");
+  BOOST_CHECK(sub.noCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromStreamDryRun)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file, true);
+
+  std::ifstream input("tests/daemon/common/config_example.info");
+  BOOST_REQUIRE(input.is_open());
+
+  file.parse(input, true, "tests/daemon/common/config_example.info");
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromConfigSection)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  std::istringstream input(CONFIG);
+  ConfigSection section;
+  boost::property_tree::read_info(input, section);
+
+  file.parse(section, false, "dummy-config");
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromString)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  file.parse(CONFIG, false, "dummy-config");
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromEmptyString)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  file.parse("", false, "empty");
+  BOOST_CHECK(sub.noCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromMalformedString)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  const std::string malformed = R"CONFIG(
+    a
+    {
+      akey avalue
+    }
+    b
+      bkey bvalue
+    }
+  )CONFIG";
+
+  BOOST_CHECK_THROW(file.parse(malformed, false, "dummy-config"), ConfigFile::Error);
+  BOOST_CHECK(sub.noCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromStringDryRun)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file, true);
+
+  file.parse(CONFIG, true, "dummy-config");
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromFilename)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  file.parse("tests/daemon/common/config_example.info", false);
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromFilenameNonExistent)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  BOOST_CHECK_THROW(file.parse("i_made_this_up.info", false), ConfigFile::Error);
+  BOOST_CHECK(sub.noCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromFilenameMalformed)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file);
+
+  BOOST_CHECK_THROW(file.parse("tests/daemon/common/config_malformed.info", false), ConfigFile::Error);
+  BOOST_CHECK(sub.noCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ParseFromFilenameDryRun)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub(file, true);
+
+  file.parse("tests/daemon/common/config_example.info", true);
+  BOOST_CHECK(sub.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_CASE(ReplaceSubscriber)
+{
+  ConfigFile file;
+  DummyAllSubscriber sub1(file);
+  DummyAllSubscriber sub2(file);
+
+  file.parse(CONFIG, false, "dummy-config");
+
+  BOOST_CHECK(sub1.noCallbacksFired());
+  BOOST_CHECK(sub2.allCallbacksFired());
+}
+
+class MissingCallbackFixture
+{
+public:
+  void
+  checkMissingHandler(const std::string& filename,
+                      const std::string& sectionName,
+                      const ConfigSection& section,
+                      bool isDryRun)
+  {
+    m_missingFired = true;
+  }
+
+protected:
+  bool m_missingFired = false;
+};
+
+BOOST_FIXTURE_TEST_CASE(UncoveredSections, MissingCallbackFixture)
+{
+  ConfigFile file;
+  BOOST_REQUIRE_THROW(file.parse(CONFIG, false, "dummy-config"), ConfigFile::Error);
+
+  ConfigFile permissiveFile(bind(&MissingCallbackFixture::checkMissingHandler,
+                                 this, _1, _2, _3, _4));
+  DummyOneSubscriber subA(permissiveFile, "a");
+
+  BOOST_REQUIRE_NO_THROW(permissiveFile.parse(CONFIG, false, "dummy-config"));
+  BOOST_CHECK(subA.allCallbacksFired());
+  BOOST_CHECK(m_missingFired);
+}
+
+BOOST_AUTO_TEST_CASE(CoveredByPartialSubscribers)
+{
+  ConfigFile file;
+  DummyOneSubscriber subA(file, "a");
+  DummyOneSubscriber subB(file, "b");
+
+  file.parse(CONFIG, false, "dummy-config");
+
+  BOOST_CHECK(subA.allCallbacksFired());
+  BOOST_CHECK(subB.allCallbacksFired());
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestConfigFile
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/common/config_example.info b/tests/daemon/common/config_example.info
new file mode 100644
index 0000000..d61691f
--- /dev/null
+++ b/tests/daemon/common/config_example.info
@@ -0,0 +1,9 @@
+a
+{
+        akey "avalue"
+}
+
+b
+{
+        bkey "bvalue"
+}
\ No newline at end of file
diff --git a/tests/daemon/common/config_malformed.info b/tests/daemon/common/config_malformed.info
new file mode 100644
index 0000000..d3a1f9e
--- /dev/null
+++ b/tests/daemon/common/config_malformed.info
@@ -0,0 +1,9 @@
+a
+{
+        akey "avalue"
+}
+
+b
+
+        bkey "bvalue"
+}
\ No newline at end of file
diff --git a/tests/daemon/common/counter.t.cpp b/tests/daemon/common/counter.t.cpp
new file mode 100644
index 0000000..60de483
--- /dev/null
+++ b/tests/daemon/common/counter.t.cpp
@@ -0,0 +1,93 @@
+/* -*- 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 "common/counter.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestCounter)
+
+BOOST_AUTO_TEST_CASE(PacketCnt)
+{
+  PacketCounter counter;
+
+  uint64_t observation = counter; // implicit conversion
+  BOOST_CHECK_EQUAL(observation, 0);
+
+  ++counter;
+  BOOST_CHECK_EQUAL(counter, 1);
+  ++counter;
+  ++counter;
+  BOOST_CHECK_EQUAL(counter, 3);
+
+  counter.set(2);
+  BOOST_CHECK_EQUAL(counter, 2);
+}
+
+BOOST_AUTO_TEST_CASE(ByteCnt)
+{
+  ByteCounter counter;
+
+  uint64_t observation = counter; // implicit conversion
+  BOOST_CHECK_EQUAL(observation, 0);
+
+  counter += 20;
+  BOOST_CHECK_EQUAL(counter, 20);
+  counter += 80;
+  counter += 90;
+  BOOST_CHECK_EQUAL(counter, 190);
+
+  counter.set(21);
+  BOOST_CHECK_EQUAL(counter, 21);
+}
+
+BOOST_AUTO_TEST_CASE(SizeCnt)
+{
+  std::vector<int> v;
+  SizeCounter<std::vector<int>> counter1(&v);
+  SizeCounter<std::vector<int>> counter2;
+  counter2.observe(&v);
+
+  size_t observation1 = counter1; // implicit conversion
+  size_t observation2 = counter2;
+  BOOST_CHECK_EQUAL(observation1, 0);
+  BOOST_CHECK_EQUAL(observation2, 0);
+
+  v.resize(249);
+  BOOST_CHECK_EQUAL(counter1, 249);
+  BOOST_CHECK_EQUAL(counter2, 249);
+
+  v.resize(98);
+  BOOST_CHECK_EQUAL(counter1, 98);
+  BOOST_CHECK_EQUAL(counter2, 98);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestCounter
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/global.t.cpp b/tests/daemon/common/global.t.cpp
similarity index 99%
rename from tests/daemon/global.t.cpp
rename to tests/daemon/common/global.t.cpp
index bb24218..dced382 100644
--- a/tests/daemon/global.t.cpp
+++ b/tests/daemon/common/global.t.cpp
@@ -23,7 +23,7 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"
diff --git a/tests/daemon/common/privilege-helper.t.cpp b/tests/daemon/common/privilege-helper.t.cpp
new file mode 100644
index 0000000..dcea7cb
--- /dev/null
+++ b/tests/daemon/common/privilege-helper.t.cpp
@@ -0,0 +1,73 @@
+/* -*- 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 "common/privilege-helper.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestPrivilegeHelper)
+
+BOOST_AUTO_TEST_CASE(DropRaise)
+{
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+  SKIP_IF_NOT_SUPERUSER();
+
+  // The following assumes that daemon:daemon is present on the test system
+  PrivilegeHelper::initialize("daemon", "daemon");
+  BOOST_CHECK_EQUAL(::geteuid(), 0);
+  BOOST_CHECK_EQUAL(::getegid(), 0);
+
+  PrivilegeHelper::drop();
+  BOOST_CHECK_NE(::geteuid(), 0);
+  BOOST_CHECK_NE(::getegid(), 0);
+
+  PrivilegeHelper::runElevated([] {
+    BOOST_CHECK_EQUAL(::geteuid(), 0);
+    BOOST_CHECK_EQUAL(::getegid(), 0);
+  });
+  BOOST_CHECK_NE(::geteuid(), 0);
+  BOOST_CHECK_NE(::getegid(), 0);
+
+  BOOST_CHECK_THROW(PrivilegeHelper::runElevated(std::function<void()>{}),
+                    std::bad_function_call);
+  BOOST_CHECK_NE(::geteuid(), 0);
+  BOOST_CHECK_NE(::getegid(), 0);
+
+  PrivilegeHelper::raise();
+  BOOST_CHECK_EQUAL(::geteuid(), 0);
+  BOOST_CHECK_EQUAL(::getegid(), 0);
+
+#else
+  BOOST_TEST_MESSAGE("Dropping/raising privileges not supported on this platform, skipping");
+#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestPrivilegeHelper
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/face/multicast-ethernet-transport.t.cpp b/tests/daemon/face/multicast-ethernet-transport.t.cpp
index db248ac..4961a69 100644
--- a/tests/daemon/face/multicast-ethernet-transport.t.cpp
+++ b/tests/daemon/face/multicast-ethernet-transport.t.cpp
@@ -27,7 +27,7 @@
 
 #include "ethernet-fixture.hpp"
 
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/network-predicate.t.cpp b/tests/daemon/face/network-predicate.t.cpp
new file mode 100644
index 0000000..73e29c6
--- /dev/null
+++ b/tests/daemon/face/network-predicate.t.cpp
@@ -0,0 +1,517 @@
+/* -*- 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 "face/network-predicate.hpp"
+#include "common/config-file.hpp"
+
+#include "tests/test-common.hpp"
+
+#include <ndn-cxx/net/ethernet.hpp>
+#include <ndn-cxx/net/network-monitor-stub.hpp>
+
+#include <boost/property_tree/info_parser.hpp>
+#include <sstream>
+
+namespace nfd {
+namespace face {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Face)
+BOOST_AUTO_TEST_SUITE(TestNetworkPredicate)
+
+template<class T>
+class NetworkPredicateBaseFixture
+{
+public:
+  void
+  parseConfig(const std::string& config)
+  {
+    std::istringstream input(config);
+    boost::property_tree::ptree ptree;
+    boost::property_tree::read_info(input, ptree);
+
+    for (const auto& i : ptree) {
+      if (i.first == "whitelist") {
+        predicate.parseWhitelist(i.second);
+      }
+      else if (i.first == "blacklist") {
+        predicate.parseBlacklist(i.second);
+      }
+    }
+  }
+
+protected:
+  T predicate;
+};
+
+class NetworkInterfacePredicateFixture : public NetworkPredicateBaseFixture<NetworkInterfacePredicate>
+{
+protected:
+  NetworkInterfacePredicateFixture()
+  {
+    using namespace boost::asio::ip;
+    using namespace ndn::net;
+    namespace ethernet = ndn::ethernet;
+
+    netifs.push_back(NetworkMonitorStub::makeNetworkInterface());
+    netifs.back()->setIndex(0);
+    netifs.back()->setName("eth0");
+    netifs.back()->setEthernetAddress(ethernet::Address::fromString("3e:15:c2:8b:65:00"));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V4,
+      address_v4::from_string("129.82.100.1"), address_v4::from_string("129.82.255.255"),
+      16, AddressScope::GLOBAL, 0));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V6,
+      address_v6::from_string("2001:db8:1::1"), address_v6::from_string("2001:db8:1::ffff:ffff:ffff:ffff"),
+      64, AddressScope::GLOBAL, 0));
+    netifs.back()->setFlags(IFF_UP);
+
+    netifs.push_back(NetworkMonitorStub::makeNetworkInterface());
+    netifs.back()->setIndex(1);
+    netifs.back()->setName("eth1");
+    netifs.back()->setEthernetAddress(ethernet::Address::fromString("3e:15:c2:8b:65:01"));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V4,
+      address_v4::from_string("192.168.2.1"), address_v4::from_string("192.168.2.255"),
+      24, AddressScope::GLOBAL, 0));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V6,
+      address_v6::from_string("2001:db8:2::1"), address_v6::from_string("2001:db8:2::ffff:ffff:ffff:ffff"),
+      64, AddressScope::GLOBAL, 0));
+    netifs.back()->setFlags(IFF_UP);
+
+    netifs.push_back(NetworkMonitorStub::makeNetworkInterface());
+    netifs.back()->setIndex(2);
+    netifs.back()->setName("eth2");
+    netifs.back()->setEthernetAddress(ethernet::Address::fromString("3e:15:c2:8b:65:02"));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V4,
+      address_v4::from_string("198.51.100.1"), address_v4::from_string("198.51.100.255"),
+      24, AddressScope::GLOBAL, 0));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V6,
+      address_v6::from_string("2001:db8::1"), address_v6::from_string("2001:db8::ffff"),
+      112, AddressScope::GLOBAL, 0));
+    netifs.back()->setFlags(IFF_MULTICAST | IFF_BROADCAST | IFF_UP);
+
+    netifs.push_back(NetworkMonitorStub::makeNetworkInterface());
+    netifs.back()->setIndex(3);
+    netifs.back()->setName("enp68s0f1");
+    netifs.back()->setEthernetAddress(ethernet::Address::fromString("3e:15:c2:8b:65:03"));
+    netifs.back()->addNetworkAddress(NetworkAddress(AddressFamily::V4,
+      address_v4::from_string("192.168.2.3"), address_v4::from_string("192.168.2.255"),
+      24, AddressScope::GLOBAL, 0));
+    netifs.back()->setFlags(IFF_UP);
+  }
+
+protected:
+  std::vector<shared_ptr<ndn::net::NetworkInterface>> netifs;
+};
+
+BOOST_FIXTURE_TEST_SUITE(NetworkInterface, NetworkInterfacePredicateFixture)
+
+BOOST_AUTO_TEST_CASE(Default)
+{
+  parseConfig("");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(EmptyWhitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(WildcardBlacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  *\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameWhitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname eth0\n"
+              "  ifname eth1\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameBlacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  ifname eth0\n"
+              "  ifname eth1\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameWildcardStart)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname enp*\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameWildcardMiddle)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname *th*\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameWildcardDouble)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname eth**\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameWildcardOnly)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname *\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameQuestionMark)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ifname eth?\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(IfnameMalformed)
+{
+  BOOST_CHECK_THROW(
+    parseConfig("whitelist\n"
+                "{\n"
+                "  ifname\n"
+                "}"),
+    ConfigFile::Error);
+}
+
+BOOST_AUTO_TEST_CASE(EtherWhitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  ether 3e:15:c2:8b:65:00\n"
+              "  ether 3e:15:c2:8b:65:01\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(EtherBlacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  ether 3e:15:c2:8b:65:00\n"
+              "  ether 3e:15:c2:8b:65:01\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(EtherMalformed)
+{
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  ether foo\n"
+                "}"),
+    ConfigFile::Error);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet4Whitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  subnet 192.168.0.0/16\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet4Blacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  subnet 192.168.0.0/16\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet6Whitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  subnet 2001:db8:2::1/120\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet6Blacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  subnet 2001:db8:2::1/120\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(*netifs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(SubnetMalformed)
+{
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  subnet 266.0.0.91/\n"
+                "}"),
+    ConfigFile::Error);
+}
+
+BOOST_AUTO_TEST_CASE(UnrecognizedKey)
+{
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  key unrecognized\n"
+                "}"),
+    ConfigFile::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // NetworkInterface
+
+class IpAddressPredicateFixture : public NetworkPredicateBaseFixture<IpAddressPredicate>
+{
+protected:
+  IpAddressPredicateFixture()
+  {
+    using namespace boost::asio::ip;
+
+    addrs.push_back(address_v4::from_string("129.82.100.1"));
+    addrs.push_back(address_v6::from_string("2001:db8:1::1"));
+    addrs.push_back(address_v4::from_string("192.168.2.1"));
+    addrs.push_back(address_v6::from_string("2001:db8:2::1"));
+  }
+
+protected:
+  std::vector<boost::asio::ip::address> addrs;
+};
+
+BOOST_FIXTURE_TEST_SUITE(IpAddress, IpAddressPredicateFixture)
+
+BOOST_AUTO_TEST_CASE(Default)
+{
+  parseConfig("");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(EmptyWhitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(WildcardBlacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  *\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet4Whitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  subnet 192.168.0.0/16\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet4Blacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  subnet 192.168.0.0/16\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet6Whitelist)
+{
+  parseConfig("whitelist\n"
+              "{\n"
+              "  subnet 2001:db8:2::1/120\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), false);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), true);
+}
+
+BOOST_AUTO_TEST_CASE(Subnet6Blacklist)
+{
+  parseConfig("blacklist\n"
+              "{\n"
+              "  subnet 2001:db8:2::1/120\n"
+              "}");
+
+  BOOST_CHECK_EQUAL(predicate(addrs[0]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[1]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[2]), true);
+  BOOST_CHECK_EQUAL(predicate(addrs[3]), false);
+}
+
+BOOST_AUTO_TEST_CASE(UnrecognizedKey)
+{
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  ether 3e:15:c2:8b:65:00\n"
+                "}"),
+    ConfigFile::Error);
+
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  ifname eth**\n"
+                "}"),
+    ConfigFile::Error);
+
+  BOOST_CHECK_THROW(
+    parseConfig("blacklist\n"
+                "{\n"
+                "  key unrecognized\n"
+                "}"),
+    ConfigFile::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // IpAddress
+
+BOOST_AUTO_TEST_SUITE_END() // TestNetworkPredicate
+BOOST_AUTO_TEST_SUITE_END() // Face
+
+} // namespace tests
+} // namespace face
+} // namespace nfd
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index fa90735..b872f94 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-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,
@@ -27,7 +27,7 @@
 #define NFD_TESTS_DAEMON_FACE_TCP_CHANNEL_FIXTURE_HPP
 
 #include "face/tcp-channel.hpp"
-#include "core/network-predicate.hpp"
+#include "face/network-predicate.hpp"
 
 #include "channel-fixture.hpp"
 
diff --git a/tests/daemon/face/test-netif.cpp b/tests/daemon/face/test-netif.cpp
index a19623f..d97ce47 100644
--- a/tests/daemon/face/test-netif.cpp
+++ b/tests/daemon/face/test-netif.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "test-netif.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/fw/asf-measurements.t.cpp b/tests/daemon/fw/asf-measurements.t.cpp
index d08f761..a6d8c02 100644
--- a/tests/daemon/fw/asf-measurements.t.cpp
+++ b/tests/daemon/fw/asf-measurements.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "fw/asf-measurements.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 5776f6c..e63951c 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "fw/best-route-strategy2.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 59b5ef3..598935c 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "fw/forwarder.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index e1c4027..a44ba78 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "fw/multicast-strategy.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 50d3de5..5c63f61 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -25,7 +25,7 @@
 
 #include "topology-tester.hpp"
 
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 #include "face/generic-link-service.hpp"
 
 #include <ndn-cxx/encoding/encoding-buffer-fwd.hpp>
diff --git a/tests/daemon/global-io-fixture.cpp b/tests/daemon/global-io-fixture.cpp
index 4888e80..9d9b184 100644
--- a/tests/daemon/global-io-fixture.cpp
+++ b/tests/daemon/global-io-fixture.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "tests/daemon/global-io-fixture.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 namespace nfd {
 namespace tests {
diff --git a/tests/daemon/limited-io.cpp b/tests/daemon/limited-io.cpp
index c54a290..aeb1ea7 100644
--- a/tests/daemon/limited-io.cpp
+++ b/tests/daemon/limited-io.cpp
@@ -25,7 +25,7 @@
 
 #include "tests/daemon/limited-io.hpp"
 #include "tests/test-common.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include <boost/exception/diagnostic_information.hpp>
 
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.cpp b/tests/daemon/mgmt/face-manager-command-fixture.cpp
index 16e99c6..ed90d0a 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.cpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "face-manager-command-fixture.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include <ndn-cxx/net/network-monitor-stub.hpp>
 
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 5d61168..0918aaf 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -172,7 +172,7 @@
 BOOST_AUTO_TEST_CASE(NameTooLong)
 {
   Name prefix;
-  while (prefix.size() <= FIB_MAX_DEPTH) {
+  while (prefix.size() <= Fib::getMaxDepth()) {
     prefix.append("A");
   }
 
diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp
index 1f7188a..5dbfc41 100644
--- a/tests/daemon/mgmt/general-config-section.t.cpp
+++ b/tests/daemon/mgmt/general-config-section.t.cpp
@@ -24,8 +24,8 @@
  */
 
 #include "mgmt/general-config-section.hpp"
-#include "core/config-file.hpp"
-#include "core/privilege-helper.hpp"
+#include "common/config-file.hpp"
+#include "common/privilege-helper.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index 04d9dca..dd34b5e 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -24,7 +24,6 @@
  */
 
 #include "mgmt/rib-manager.hpp"
-#include "core/fib-max-depth.hpp"
 #include "rib/fib-updater.hpp"
 
 #include "manager-common-fixture.hpp"
@@ -405,7 +404,7 @@
 BOOST_AUTO_TEST_CASE(NameTooLong)
 {
   Name prefix;
-  while (prefix.size() <= FIB_MAX_DEPTH) {
+  while (prefix.size() <= Fib::getMaxDepth()) {
     prefix.append("A");
   }
   auto params = makeRegisterParameters(prefix, 2899);
@@ -413,9 +412,9 @@
   receiveInterest(command);
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
-  BOOST_CHECK_EQUAL(checkResponse(0, command.getName(), ControlResponse(414,
-                      "Route prefix cannot exceed " + ndn::to_string(FIB_MAX_DEPTH) +
-                      " components")),
+  BOOST_CHECK_EQUAL(checkResponse(0, command.getName(),
+                                  ControlResponse(414, "Route prefix cannot exceed " +
+                                                  to_string(Fib::getMaxDepth()) + " components")),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(m_commands.size(), 0);
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index 6b7e390..ae96352 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -124,7 +124,7 @@
 BOOST_AUTO_TEST_CASE(SetNameTooLong)
 {
   Name prefix;
-  while (prefix.size() <= FIB_MAX_DEPTH) {
+  while (prefix.size() <= NameTree::getMaxDepth()) {
     prefix.append("A");
   }
   ControlParameters reqParams;
diff --git a/tests/daemon/rib-io-fixture.cpp b/tests/daemon/rib-io-fixture.cpp
index 768c5cc..a0c8048 100644
--- a/tests/daemon/rib-io-fixture.cpp
+++ b/tests/daemon/rib-io-fixture.cpp
@@ -25,7 +25,7 @@
 
 #include "tests/daemon/rib-io-fixture.hpp"
 #include "tests/test-common.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include <boost/exception/diagnostic_information.hpp>
 
diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp
index e732e07..80b0c38 100644
--- a/tests/daemon/rib/service.t.cpp
+++ b/tests/daemon/rib/service.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "rib/service.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/rib-io-fixture.hpp"
diff --git a/tests/daemon/table/dead-nonce-list.t.cpp b/tests/daemon/table/dead-nonce-list.t.cpp
index 1cd32eb..b98cd00 100644
--- a/tests/daemon/table/dead-nonce-list.t.cpp
+++ b/tests/daemon/table/dead-nonce-list.t.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "table/dead-nonce-list.hpp"
-#include "daemon/global.hpp"
+#include "common/global.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"