Add test for running after terminate
authorSubodh Iyengar <subodh@fb.com>
Mon, 2 Mar 2015 22:46:46 +0000 (14:46 -0800)
committerAlecs King <int@fb.com>
Tue, 3 Mar 2015 03:31:14 +0000 (19:31 -0800)
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

index baad13437ada623f964c92dbc230198f85abbe03..a5fbcad53c7a27c494619a2d7f2f8e7053fe5c97 100644 (file)
@@ -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;