face: don't crash if Face is destroyed with outstanding io.post
refs #3248
Change-Id: Ifd46e46fb1df849cbb3651204cd5a72f476cb81e
diff --git a/tests/unit-tests/face.t.cpp b/tests/unit-tests/face.t.cpp
index bf87de6..42def58 100644
--- a/tests/unit-tests/face.t.cpp
+++ b/tests/unit-tests/face.t.cpp
@@ -577,6 +577,8 @@
BOOST_AUTO_TEST_SUITE_END() // Producer
+BOOST_AUTO_TEST_SUITE(IoRoutines)
+
BOOST_AUTO_TEST_CASE(ProcessEvents)
{
face.processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside
@@ -594,6 +596,20 @@
BOOST_CHECK_EQUAL(nRegSuccesses, 1);
}
+BOOST_AUTO_TEST_CASE(DestroyWithoutProcessEvents) // Bug 3248
+{
+ auto face2 = make_unique<Face>(io);
+ face2.reset();
+
+ io.poll(); // should not crash
+}
+
+BOOST_AUTO_TEST_SUITE_END() // IoRoutines
+
+BOOST_AUTO_TEST_SUITE(Transport)
+
+using ndn::Transport;
+
struct PibDirWithDefaultTpm
{
const std::string PATH = "build/keys-with-default-tpm";
@@ -616,8 +632,6 @@
BOOST_CHECK(Face(transport, io, keyChain).getTransport() == transport);
}
-BOOST_AUTO_TEST_SUITE(CustomizeTransport)
-
class WithEnv : private IdentityManagementTimeFixture
{
public:
@@ -725,7 +739,8 @@
BOOST_CHECK(dynamic_pointer_cast<UnixTransport>(face->getTransport()) != nullptr);
}
-BOOST_AUTO_TEST_SUITE_END() // CustomizeTransport
+BOOST_AUTO_TEST_SUITE_END() // Transport
+
BOOST_AUTO_TEST_SUITE_END() // TestFace
} // namespace tests