tests: resetGlobalIoService for every test

All tests must use BaseFixture or a fixture derived from it to get this feature.

This commit also fixes a few warnings in tests/mgmt, and moves test cases into nfd::tests namespace.

refs #1290

Change-Id: I891441a5abce170e35648d463f7157b18429f79f
diff --git a/tests/fw/broadcast-strategy.cpp b/tests/fw/broadcast-strategy.cpp
index 26d0687..b256432 100644
--- a/tests/fw/broadcast-strategy.cpp
+++ b/tests/fw/broadcast-strategy.cpp
@@ -6,17 +6,17 @@
 
 #include "fw/broadcast-strategy.hpp"
 #include "strategy-tester.hpp"
-#include "../face/dummy-face.hpp"
+#include "tests/face/dummy-face.hpp"
 
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
 
 namespace nfd {
+namespace tests {
 
-BOOST_AUTO_TEST_SUITE(FwBroadcastStrategy)
+BOOST_FIXTURE_TEST_SUITE(FwBroadcastStrategy, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(ForwardTwo)
 {
-  resetGlobalIoService();
   Forwarder forwarder;
   typedef StrategyTester<fw::BroadcastStrategy> BroadcastStrategyTester;
   BroadcastStrategyTester strategy(forwarder);
@@ -60,7 +60,6 @@
 
 BOOST_AUTO_TEST_CASE(Reject)
 {
-  resetGlobalIoService();
   Forwarder forwarder;
   typedef StrategyTester<fw::BroadcastStrategy> BroadcastStrategyTester;
   BroadcastStrategyTester strategy(forwarder);
@@ -85,4 +84,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace tests
 } // namespace nfd
diff --git a/tests/fw/forwarder.cpp b/tests/fw/forwarder.cpp
index 6607766..0a30852 100644
--- a/tests/fw/forwarder.cpp
+++ b/tests/fw/forwarder.cpp
@@ -5,17 +5,17 @@
  */
 
 #include "fw/forwarder.hpp"
-#include "../face/dummy-face.hpp"
+#include "tests/face/dummy-face.hpp"
 
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
 
 namespace nfd {
+namespace tests {
 
-BOOST_AUTO_TEST_SUITE(FwForwarder)
+BOOST_FIXTURE_TEST_SUITE(FwForwarder, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(AddRemoveFace)
 {
-  resetGlobalIoService();
   Forwarder forwarder;
 
   shared_ptr<Face> face1 = make_shared<DummyFace>();
@@ -38,18 +38,8 @@
   BOOST_CHECK_EQUAL(face2->getId(), INVALID_FACEID);
 }
 
-class ForwarderTestFace : public DummyFace {
-public:
-  virtual void
-  afterSend()
-  {
-    getGlobalIoService().stop();
-  }
-};
-
 BOOST_AUTO_TEST_CASE(SimpleExchange)
 {
-  resetGlobalIoService();
   Forwarder forwarder;
 
   Name nameA  ("ndn:/A");
@@ -59,8 +49,10 @@
   interestAB.setInterestLifetime(4000);
   Data dataABC(nameABC);
 
-  shared_ptr<ForwarderTestFace> face1 = make_shared<ForwarderTestFace>();
-  shared_ptr<ForwarderTestFace> face2 = make_shared<ForwarderTestFace>();
+  shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+  shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+  face1->afterSend += bind(&boost::asio::io_service::stop, &g_io);
+  face2->afterSend += bind(&boost::asio::io_service::stop, &g_io);
   forwarder.addFace(face1);
   forwarder.addFace(face2);
 
@@ -71,15 +63,15 @@
   fibEntry->addNextHop(face2, 0);
 
   face1->receiveInterest(interestAB);
-  getGlobalIoService().run();
-  getGlobalIoService().reset();
+  g_io.run();
+  g_io.reset();
   BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 1);
   BOOST_CHECK(face2->m_sentInterests[0].getName().equals(nameAB));
   BOOST_CHECK_EQUAL(face2->m_sentInterests[0].getIncomingFaceId(), face1->getId());
 
   face2->receiveData(dataABC);
-  getGlobalIoService().run();
-  getGlobalIoService().reset();
+  g_io.run();
+  g_io.reset();
   BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1);
   BOOST_CHECK(face1->m_sentDatas[0].getName().equals(nameABC));
   BOOST_CHECK_EQUAL(face1->m_sentDatas[0].getIncomingFaceId(), face2->getId());
@@ -115,7 +107,6 @@
 
 BOOST_AUTO_TEST_CASE(ScopeLocalhostIncoming)
 {
-  resetGlobalIoService();
   ScopeLocalhostIncomingTestForwarder forwarder;
   shared_ptr<Face> face1 = make_shared<DummyLocalFace>();
   shared_ptr<Face> face2 = make_shared<DummyFace>();
@@ -165,7 +156,6 @@
 
 BOOST_AUTO_TEST_CASE(ScopeLocalhostOutgoing)
 {
-  resetGlobalIoService();
   Forwarder forwarder;
   shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>();
   shared_ptr<DummyFace>      face2 = make_shared<DummyFace>();
@@ -230,4 +220,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace tests
 } // namespace nfd
diff --git a/tests/fw/ncc-strategy.cpp b/tests/fw/ncc-strategy.cpp
index a258b83..2709913 100644
--- a/tests/fw/ncc-strategy.cpp
+++ b/tests/fw/ncc-strategy.cpp
@@ -6,14 +6,15 @@
 
 #include "fw/ncc-strategy.hpp"
 #include "strategy-tester.hpp"
-#include "../face/dummy-face.hpp"
-#include "../core/limited-io.hpp"
+#include "tests/face/dummy-face.hpp"
+#include "tests/core/limited-io.hpp"
 
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
 
 namespace nfd {
+namespace tests {
 
-BOOST_AUTO_TEST_SUITE(FwNccStrategy)
+BOOST_FIXTURE_TEST_SUITE(FwNccStrategy, BaseFixture)
 
 // NccStrategy is fairly complex.
 // The most important property is:
@@ -84,4 +85,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace tests
 } // namespace nfd
diff --git a/tests/fw/strategy-tester.hpp b/tests/fw/strategy-tester.hpp
index f8e0848..571492c 100644
--- a/tests/fw/strategy-tester.hpp
+++ b/tests/fw/strategy-tester.hpp
@@ -11,6 +11,7 @@
 #include "fw/strategy.hpp"
 
 namespace nfd {
+namespace tests {
 
 /** \class StrategyTester
  *  \brief extends strategy S for unit testing
@@ -64,7 +65,7 @@
   onAction();
 }
 
-
+} // namespace tests
 } // namespace nfd
 
 #endif // TEST_FW_STRATEGY_TESTER_HPP