From: Subodh Iyengar Date: Mon, 2 Mar 2015 22:46:46 +0000 (-0800) Subject: Add test for running after terminate X-Git-Tag: v0.27.0~1 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=7bbdffca8c07075f3bdb7f56c62484c3f081a551 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 --- 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;