fix flaky ConnectTFOTimeout and ConnectTFOFallbackTimeout tests
[folly.git] / folly / io / async / test / Util.h
index e0b7360e64681a0da1d15bc613e0275af98d0d88..8f54274de4e4007ae7e9602211bf4f227b661519 100644 (file)
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <folly/io/async/test/TimeUtil.h>
+#include <folly/test/TestUtils.h>
 #include <gtest/gtest.h>
 
 /**
  * @param expectedMS            The timeout duration, in milliseconds
  * @param tolerance             The tolerance, in milliseconds.
  */
-#define T_CHECK_TIMEOUT(start, end, expectedMS, ...) \
-  EXPECT_TRUE(::folly::checkTimeout((start), (end),  \
-                                    (expectedMS), false,  \
-                                    ##__VA_ARGS__))
+#define T_CHECK_TIMEOUT(start, end, expectedMS, ...)     \
+  if (!::folly::checkTimeout((start), (end),             \
+                             (expectedMS), false,        \
+                             ##__VA_ARGS__)) {           \
+    SKIP() << "T_CHECK_TIMEOUT lapsed";                  \
+  }
 
 /**
  * Verify that an event took less than a specified amount of time.
@@ -47,7 +50,9 @@
  * This is similar to T_CHECK_TIMEOUT, but does not fail if the event took less
  * than the allowed time.
  */
-#define T_CHECK_TIME_LT(start, end, expectedMS, ...) \
-  EXPECT_TRUE(::folly::checkTimeout((start), (end),  \
-                                    (expectedMS), true, \
-                                    ##__VA_ARGS__))
+#define T_CHECK_TIME_LT(start, end, expectedMS, ...)     \
+  if (!::folly::checkTimeout((start), (end),             \
+                             (expectedMS), true,         \
+                             ##__VA_ARGS__)) {           \
+    SKIP() << "T_CHECK_TIMEOUT_LT lapsed";               \
+  }