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/mgmt/config-file.cpp b/tests/mgmt/config-file.cpp
index bf275e4..ca89aec 100644
--- a/tests/mgmt/config-file.cpp
+++ b/tests/mgmt/config-file.cpp
@@ -7,13 +7,14 @@
#include "mgmt/config-file.hpp"
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
namespace nfd {
+namespace tests {
NFD_LOG_INIT("ConfigFileTest");
-BOOST_AUTO_TEST_SUITE(MgmtConfigFile)
+BOOST_FIXTURE_TEST_SUITE(MgmtConfigFile, BaseFixture)
// a
// {
@@ -342,6 +343,7 @@
BOOST_CHECK(subB.allCallbacksFired());
}
-} // namespace nfd
-
BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/mgmt/fib-manager.cpp b/tests/mgmt/fib-manager.cpp
index 2352f53..00043d2 100644
--- a/tests/mgmt/fib-manager.cpp
+++ b/tests/mgmt/fib-manager.cpp
@@ -9,17 +9,16 @@
#include "table/fib-nexthop.hpp"
#include "face/face.hpp"
#include "mgmt/internal-face.hpp"
-#include "../face/dummy-face.hpp"
+#include "tests/face/dummy-face.hpp"
-#include <algorithm>
-
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
namespace nfd {
+namespace tests {
NFD_LOG_INIT("FibManagerTest");
-class FibManagerFixture
+class FibManagerFixture : protected BaseFixture
{
public:
@@ -32,9 +31,9 @@
shared_ptr<Face>
getFace(FaceId id)
{
- if (id > 0 && id <= m_faces.size())
+ if (id > 0 && static_cast<size_t>(id) <= m_faces.size())
{
- return m_faces[id-1];
+ return m_faces[id - 1];
}
NFD_LOG_DEBUG("No face found returning NULL");
return shared_ptr<DummyFace>();
@@ -120,10 +119,7 @@
bool m_callbackFired;
};
-
-BOOST_AUTO_TEST_SUITE(MgmtFibManager)
-
-
+BOOST_FIXTURE_TEST_SUITE(MgmtFibManager, FibManagerFixture)
bool
foundNextHop(FaceId id, uint32_t cost, const fib::NextHop& next)
@@ -167,7 +163,7 @@
return false;
}
-BOOST_FIXTURE_TEST_CASE(TestFireInterestFilter, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(TestFireInterestFilter)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -186,7 +182,7 @@
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_FIXTURE_TEST_CASE(MalformedCommmand, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(MalformedCommmand)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -207,7 +203,7 @@
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_FIXTURE_TEST_CASE(UnsupportedVerb, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(UnsupportedVerb)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -236,7 +232,7 @@
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_FIXTURE_TEST_CASE(UnsignedCommand, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(UnsignedCommand)
{
addFace(make_shared<DummyFace>());
@@ -270,7 +266,7 @@
BOOST_REQUIRE(!addedNextHopWithCost(fib, "/hello", 0, 101));
}
-BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(UnauthorizedCommand)
{
addFace(make_shared<DummyFace>());
@@ -304,7 +300,7 @@
BOOST_REQUIRE(!addedNextHopWithCost(fib, "/hello", 0, 101));
}
-BOOST_FIXTURE_TEST_CASE(BadOptionParse, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(BadOptionParse)
{
addFace(make_shared<DummyFace>());
@@ -328,7 +324,7 @@
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_FIXTURE_TEST_CASE(UnknownFaceId, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(UnknownFaceId)
{
addFace(make_shared<DummyFace>());
@@ -360,7 +356,7 @@
BOOST_REQUIRE(addedNextHopWithCost(fib, "/hello", 0, 101) == false);
}
-BOOST_FIXTURE_TEST_CASE(TestImplicitFaceId, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(TestImplicitFaceId)
{
addFace(make_shared<DummyFace>());
@@ -402,7 +398,7 @@
BOOST_REQUIRE(addedNextHopWithFace(fib, "/hello", 0, 101, getFace(1)));
}
-BOOST_FIXTURE_TEST_CASE(AddNextHopVerbInitialAdd, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(AddNextHopVerbInitialAdd)
{
addFace(make_shared<DummyFace>());
@@ -436,7 +432,7 @@
BOOST_REQUIRE(addedNextHopWithCost(fib, "/hello", 0, 101));
}
-BOOST_FIXTURE_TEST_CASE(AddNextHopVerbAddToExisting, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(AddNextHopVerbAddToExisting)
{
addFace(make_shared<DummyFace>());
@@ -490,9 +486,8 @@
}
}
-BOOST_FIXTURE_TEST_CASE(AddNextHopVerbUpdateFaceCost, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(AddNextHopVerbUpdateFaceCost)
{
- FibManagerFixture fixture;
addFace(make_shared<DummyFace>());
shared_ptr<InternalFace> face(make_shared<InternalFace>());
@@ -568,7 +563,7 @@
}
}
-BOOST_FIXTURE_TEST_CASE(Insert, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(Insert)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -666,7 +661,7 @@
face->onReceiveData.clear();
}
-BOOST_FIXTURE_TEST_CASE(Delete, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(Delete)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -752,7 +747,7 @@
face->onReceiveData.clear();
}
-BOOST_FIXTURE_TEST_CASE(RemoveNextHop, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(RemoveNextHop)
{
shared_ptr<Face> face1 = make_shared<DummyFace>();
shared_ptr<Face> face2 = make_shared<DummyFace>();
@@ -790,7 +785,7 @@
}
-BOOST_FIXTURE_TEST_CASE(RemoveNoFace, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(RemoveNoFace)
{
shared_ptr<InternalFace> face(make_shared<InternalFace>());
Fib fib;
@@ -818,7 +813,7 @@
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_FIXTURE_TEST_CASE(RemoveNoPrefix, FibManagerFixture)
+BOOST_AUTO_TEST_CASE(RemoveNoPrefix)
{
addFace(make_shared<DummyFace>());
@@ -850,4 +845,5 @@
BOOST_AUTO_TEST_SUITE_END()
+} // namespace tests
} // namespace nfd
diff --git a/tests/mgmt/internal-face.cpp b/tests/mgmt/internal-face.cpp
index 52eaa23..f4d51ca 100644
--- a/tests/mgmt/internal-face.cpp
+++ b/tests/mgmt/internal-face.cpp
@@ -5,15 +5,16 @@
*/
#include "mgmt/internal-face.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 {
NFD_LOG_INIT("InternalFaceTest");
-class InternalFaceFixture
+class InternalFaceFixture : protected BaseFixture
{
public:
@@ -72,7 +73,7 @@
bool m_noOnInterestFired;
};
-BOOST_AUTO_TEST_SUITE(MgmtInternalFace)
+BOOST_FIXTURE_TEST_SUITE(MgmtInternalFace, InternalFaceFixture)
void
validatePutData(bool& called, const Name& expectedName, const Data& data)
@@ -81,7 +82,7 @@
BOOST_CHECK_EQUAL(expectedName, data.getName());
}
-BOOST_FIXTURE_TEST_CASE(PutData, InternalFaceFixture)
+BOOST_AUTO_TEST_CASE(PutData)
{
addFace(make_shared<DummyFace>());
@@ -100,7 +101,7 @@
BOOST_CHECK_THROW(face->close(), InternalFace::Error);
}
-BOOST_FIXTURE_TEST_CASE(SendInterestHitEnd, InternalFaceFixture)
+BOOST_AUTO_TEST_CASE(SendInterestHitEnd)
{
addFace(make_shared<DummyFace>());
@@ -122,9 +123,7 @@
BOOST_REQUIRE(didNoOnInterestFire() == false);
}
-
-
-BOOST_FIXTURE_TEST_CASE(SendInterestHitBegin, InternalFaceFixture)
+BOOST_AUTO_TEST_CASE(SendInterestHitBegin)
{
addFace(make_shared<DummyFace>());
@@ -145,9 +144,7 @@
BOOST_REQUIRE(didNoOnInterestFire() == false);
}
-
-
-BOOST_FIXTURE_TEST_CASE(SendInterestHitExact, InternalFaceFixture)
+BOOST_AUTO_TEST_CASE(SendInterestHitExact)
{
addFace(make_shared<DummyFace>());
@@ -176,9 +173,7 @@
BOOST_REQUIRE(didNoOnInterestFire() == false);
}
-
-
-BOOST_FIXTURE_TEST_CASE(SendInterestHitPrevious, InternalFaceFixture)
+BOOST_AUTO_TEST_CASE(SendInterestHitPrevious)
{
addFace(make_shared<DummyFace>());
@@ -205,4 +200,5 @@
BOOST_AUTO_TEST_SUITE_END()
+} // namespace tests
} // namespace nfd
diff --git a/tests/mgmt/local-control-header-manager.cpp b/tests/mgmt/local-control-header-manager.cpp
index b7fdf58..43a649d 100644
--- a/tests/mgmt/local-control-header-manager.cpp
+++ b/tests/mgmt/local-control-header-manager.cpp
@@ -5,20 +5,17 @@
*/
#include "mgmt/local-control-header-manager.hpp"
-#include "face/face.hpp"
-#include "face/local-face.hpp"
#include "mgmt/internal-face.hpp"
-#include "../face/dummy-face.hpp"
+#include "tests/face/dummy-face.hpp"
-#include <algorithm>
-
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
namespace nfd {
+namespace tests {
NFD_LOG_INIT("LocalControlHeaderManagerTest");
-class LocalControlHeaderManagerFixture
+class LocalControlHeaderManagerFixture : protected BaseFixture
{
public:
@@ -31,9 +28,9 @@
shared_ptr<Face>
getFace(FaceId id)
{
- if (id > 0 && id <= m_faces.size())
+ if (id > 0 && static_cast<size_t>(id) <= m_faces.size())
{
- return m_faces[id-1];
+ return m_faces[id - 1];
}
NFD_LOG_DEBUG("No face found returning NULL");
return shared_ptr<DummyFace>();
@@ -90,10 +87,9 @@
bool m_callbackFired;
};
+BOOST_FIXTURE_TEST_SUITE(MgmtLocalControlHeaderManager, LocalControlHeaderManagerFixture)
-BOOST_AUTO_TEST_SUITE(MgmtLocalControlHeaderManager)
-
-BOOST_FIXTURE_TEST_CASE(InFaceId, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(InFaceId)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -135,7 +131,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(NextHopFaceId, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(NextHopFaceId)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -178,7 +174,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(ShortCommand, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(ShortCommand)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -203,7 +199,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(ShortCommandModule, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(ShortCommandModule)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -228,7 +224,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(UnsupportedModule, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(UnsupportedModule)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -253,7 +249,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(InFaceIdUnsupportedVerb, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(InFaceIdUnsupportedVerb)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -278,7 +274,7 @@
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
}
-BOOST_FIXTURE_TEST_CASE(NextHopFaceIdUnsupportedVerb, LocalControlHeaderManagerFixture)
+BOOST_AUTO_TEST_CASE(NextHopFaceIdUnsupportedVerb)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
addFace(dummy);
@@ -305,4 +301,5 @@
BOOST_AUTO_TEST_SUITE_END()
+} // namespace tests
} // namespace nfd
diff --git a/tests/mgmt/manager-base.cpp b/tests/mgmt/manager-base.cpp
index feca0da..f6ddcb7 100644
--- a/tests/mgmt/manager-base.cpp
+++ b/tests/mgmt/manager-base.cpp
@@ -7,15 +7,14 @@
#include "mgmt/manager-base.hpp"
#include "mgmt/internal-face.hpp"
-#include <boost/test/unit_test.hpp>
+#include "tests/test-common.hpp"
namespace nfd {
+namespace tests {
NFD_LOG_INIT("ManagerBaseTest");
-BOOST_AUTO_TEST_SUITE(MgmtManagerBase)
-
-class ManagerBaseTest : public ManagerBase
+class ManagerBaseTest : public ManagerBase, protected BaseFixture
{
public:
@@ -90,7 +89,9 @@
};
-BOOST_FIXTURE_TEST_CASE(SetResponse, ManagerBaseTest)
+BOOST_FIXTURE_TEST_SUITE(MgmtManagerBase, ManagerBaseTest)
+
+BOOST_AUTO_TEST_CASE(SetResponse)
{
ControlResponse response(200, "OK");
@@ -104,7 +105,7 @@
}
-BOOST_FIXTURE_TEST_CASE(SendResponse3Arg, ManagerBaseTest)
+BOOST_AUTO_TEST_CASE(SendResponse3Arg)
{
getInternalFace()->onReceiveData +=
bind(&ManagerBaseTest::validateControlResponse, this, _1,
@@ -115,7 +116,7 @@
}
-BOOST_FIXTURE_TEST_CASE(SendResponse2Arg, ManagerBaseTest)
+BOOST_AUTO_TEST_CASE(SendResponse2Arg)
{
getInternalFace()->onReceiveData +=
bind(&ManagerBaseTest::validateControlResponse, this, _1,
@@ -129,11 +130,5 @@
BOOST_AUTO_TEST_SUITE_END()
+} // namespace tests
} // namespace nfd
-
-
-
-
-
-
-