You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/04/09 02:26:49 UTC

svn commit: r1465843 - /incubator/mesos/trunk/src/tests/utils.hpp

Author: vinodkone
Date: Tue Apr  9 00:26:48 2013
New Revision: 1465843

URL: http://svn.apache.org/r1465843
Log:
Added DROP_PROTOBUF(s), AWAIT_READY and AWAIT_FOR_READY to test utils.

Review: https://reviews.apache.org/r/10313

Modified:
    incubator/mesos/trunk/src/tests/utils.hpp

Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1465843&r1=1465842&r2=1465843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Tue Apr  9 00:26:48 2013
@@ -801,22 +801,44 @@ ACTION_P(SendStatusUpdateFromTaskID, sta
   AWAIT_FOR(future, Seconds(2))
 
 
+// TODO(vinod): Combine this with ASSERT_FUTURE_WILL_SUCCEED
+// inside libprocess gtest.hpp.
+#define AWAIT_FOR_READY(future, duration)         \
+  ASSERT_TRUE(future.await(duration));            \
+  ASSERT_TRUE(future.isReady())                   \
+
+
+// TODO(vinod): Combine this with ASSERT_FUTURE_WILL_SUCCEED
+// inside libprocess gtest.hpp.
+#define AWAIT_READY(future)                     \
+  ASSERT_TRUE(future.await(Seconds(2)));        \
+  ASSERT_TRUE(future.isReady())                 \
+
+
 #define FUTURE_PROTOBUF(message, from, to)              \
   FutureProtobuf(message, from, to)
 
 
+#define DROP_PROTOBUF(message, from, to)              \
+  FutureProtobuf(message, from, to, true)
+
+
+#define DROP_PROTOBUFS(message, from, to)              \
+  DropProtobufs(message, from, to)
+
+
 // Forward declaration.
 template <typename T>
 process::Future<T> _FutureProtobuf(const process::Message& message);
 
 
 template <typename T, typename From, typename To>
-process::Future<T> FutureProtobuf(T t, From from, To to)
+process::Future<T> FutureProtobuf(T t, From from, To to, bool drop = false)
 {
   // Help debugging by adding some "type constraints".
   { google::protobuf::Message* m = &t; (void) m; }
 
-  return process::FutureMessage(testing::Eq(t.GetTypeName()), from, to)
+  return process::FutureMessage(testing::Eq(t.GetTypeName()), from, to, drop)
     .then(lambda::bind(&_FutureProtobuf<T>, lambda::_1));
 }
 
@@ -829,6 +851,16 @@ process::Future<T> _FutureProtobuf(const
   return t;
 }
 
+
+template <typename T, typename From, typename To>
+void DropProtobufs(T t, From from, To to)
+{
+  // Help debugging by adding some "type constraints".
+  { google::protobuf::Message* m = &t; (void) m; }
+
+  process::DropMessages(testing::Eq(t.GetTypeName()), from, to, true);
+}
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {