From 7bbdffca8c07075f3bdb7f56c62484c3f081a551 Mon Sep 17 00:00:00 2001 From: Subodh Iyengar Date: Mon, 2 Mar 2015 14:46:46 -0800 Subject: [PATCH] Add test for running after terminate Summary: Add a test to check what will happen if someone tries to run a job on evb after termination. Test Plan: Unit tests Reviewed By: seanc@fb.com Subscribers: seanc, folly-diffs@, yfeldblum FB internal diff: D1882308 Signature: t1:1882308:1425333248:7ab6692eb0b866fcc9685048eb385bacd90023d1 --- folly/io/async/test/EventBaseTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/folly/io/async/test/EventBaseTest.cpp b/folly/io/async/test/EventBaseTest.cpp index baad1343..a5fbcad5 100644 --- a/folly/io/async/test/EventBaseTest.cpp +++ b/folly/io/async/test/EventBaseTest.cpp @@ -1309,6 +1309,20 @@ TEST(EventBaseTest, RunInLoopStopLoop) { ASSERT_LE(c1.getCount(), 11); } +TEST(EventBaseTest, TryRunningAfterTerminate) { + EventBase eventBase; + CountedLoopCallback c1(&eventBase, 1, + std::bind(&EventBase::terminateLoopSoon, &eventBase)); + eventBase.runInLoop(&c1); + eventBase.loopForever(); + bool ran = false; + eventBase.runInEventBaseThread([&]() { + ran = true; + }); + + ASSERT_FALSE(ran); +} + // Test cancelling runInLoop() callbacks TEST(EventBaseTest, CancelRunInLoop) { EventBase eventBase; -- 2.34.1