Commit 0e818b2e authored by Stepan Palamarchuk's avatar Stepan Palamarchuk Committed by Facebook Github Bot

Add duration_cast when printing expected ms

Summary: As per Yedidya Feldblum comment on my previous diff, we need a duration cast in here.

Reviewed By: yfeldblum

Differential Revision: D13833032

fbshipit-source-id: 8819694875bd3a7e4f54102d8ac77490f8287fbb
parent 4fd1f3ad
...@@ -35,13 +35,15 @@ ...@@ -35,13 +35,15 @@
* @param expectedMS The timeout duration, in milliseconds * @param expectedMS The timeout duration, in milliseconds
* @param tolerance The tolerance, in milliseconds. * @param tolerance The tolerance, in milliseconds.
*/ */
#define T_CHECK_TIMEOUT(start, end, expectedMS, ...) \ #define T_CHECK_TIMEOUT(start, end, expectedMS, ...) \
EXPECT_TRUE(::folly::checkTimeout( \ EXPECT_TRUE(::folly::checkTimeout( \
(start), (end), (expectedMS), false, ##__VA_ARGS__)) \ (start), (end), (expectedMS), false, ##__VA_ARGS__)) \
<< "Timeout violates constraints, expectedMs = " << (expectedMS).count() \ << "Timeout violates constraints, expectedMs = " \
<< ", elapsed wall time ms = " \ << std::chrono::duration_cast<std::chrono::milliseconds>(expectedMS) \
<< std::chrono::duration_cast<std::chrono::milliseconds>( \ .count() \
(end).getTime() - (start).getTime()) \ << ", elapsed wall time ms = " \
<< std::chrono::duration_cast<std::chrono::milliseconds>( \
(end).getTime() - (start).getTime()) \
.count(); .count();
/** /**
...@@ -50,11 +52,13 @@ ...@@ -50,11 +52,13 @@
* This is similar to T_CHECK_TIMEOUT, but does not fail if the event took less * This is similar to T_CHECK_TIMEOUT, but does not fail if the event took less
* than the allowed time. * than the allowed time.
*/ */
#define T_CHECK_TIME_LT(start, end, expectedMS, ...) \ #define T_CHECK_TIME_LT(start, end, expectedMS, ...) \
EXPECT_TRUE(::folly::checkTimeout( \ EXPECT_TRUE(::folly::checkTimeout( \
(start), (end), (expectedMS), true, ##__VA_ARGS__)) \ (start), (end), (expectedMS), true, ##__VA_ARGS__)) \
<< "Interval violates constraints, expectedMs = " \ << "Interval violates constraints, expectedMs = " \
<< (expectedMS).count() << ", elapsed wall time ms = " \ << std::chrono::duration_cast<std::chrono::milliseconds>(expectedMS) \
<< std::chrono::duration_cast<std::chrono::milliseconds>( \ .count() \
(end).getTime() - (start).getTime()) \ << ", elapsed wall time ms = " \
<< std::chrono::duration_cast<std::chrono::milliseconds>( \
(end).getTime() - (start).getTime()) \
.count(); .count();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment