Make Core.size test portable
authorAlexander Shaposhnikov <alexshap@fb.com>
Thu, 6 Aug 2015 02:25:51 +0000 (19:25 -0700)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Thu, 6 Aug 2015 03:22:16 +0000 (20:22 -0700)
Summary: Add a golden struct for checking the size of Core.
It makes this test pass on OSX
(now failing because of the different size of std::function).

Reviewed By: @​hannesr

Differential Revision: D2315429

folly/futures/test/CoreTest.cpp

index dedfeec365fd6621e8db2e5ade0298301cbbd214..4d824d59688940b56abbccd4c85b169938df5197 100644 (file)
 using namespace folly;
 
 TEST(Core, size) {
+  struct Gold {
+    char lambdaBuf_[8 * sizeof(void*)];
+    folly::Optional<Try<Unit>> result_;
+    std::function<void(Try<Unit>&&)> callback_;
+    detail::FSM<detail::State> fsm_;
+    std::atomic<unsigned char> attached_;
+    std::atomic<bool> active_;
+    std::atomic<bool> interruptHandlerSet_;
+    folly::MicroSpinLock interruptLock_;
+    folly::MicroSpinLock executorLock_;
+    int8_t priority_;
+    Executor* executor_;
+    std::shared_ptr<RequestContext> context_;
+    std::unique_ptr<exception_wrapper> interrupt_;
+    std::function<void(exception_wrapper const&)> interruptHandler_;
+  };
   // If this number goes down, it's fine!
   // If it goes up, please seek professional advice ;-)
-  EXPECT_EQ(192, sizeof(detail::Core<Unit>));
+  EXPECT_GE(sizeof(Gold), sizeof(detail::Core<Unit>));
 }