Repository: mesos
Updated Branches:
  refs/heads/master f9960dbc1 -> 46671dd4b


Windows: Added workaround for lack of sleep utility.

This modifies the `SLEEP_COMMAND` on Windows to deal with how we
use `sleep` in tests.  The `sleep` must last for zero or more seconds
and should always succeed (exit code 0).


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/46671dd4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/46671dd4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/46671dd4

Branch: refs/heads/master
Commit: 46671dd4bab68f64e62e5d109f818a492361c33f
Parents: f9960db
Author: Joseph Wu <josep...@apache.org>
Authored: Fri Oct 14 17:48:15 2016 -0700
Committer: Joseph Wu <josep...@apache.org>
Committed: Fri Oct 14 17:51:04 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/gtest.hpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/46671dd4/3rdparty/stout/include/stout/gtest.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/gtest.hpp 
b/3rdparty/stout/include/stout/gtest.hpp
index 4d8106d..b2f75b6 100644
--- a/3rdparty/stout/include/stout/gtest.hpp
+++ b/3rdparty/stout/include/stout/gtest.hpp
@@ -200,10 +200,16 @@ template <typename T1, typename T2>
 #endif // __WINDOWS__
 
 
+// NOTE: On Windows, the closest equivalent to `sleep` is `timeout`.
+// Unfortunately, `timeout` requires an interactive terminal, otherwise
+// it errors out immediately. Instead, we use `ping` against localhost
+// with a count.  On Windows, `ping` waits one second between pings.
+// Additionally, because `ping` requires a count greater than 0,
+// we simply `exit 0` if the sleep is too short.
 #ifndef __WINDOWS__
 #define SLEEP_COMMAND(x) "sleep " #x
 #else
-#define SLEEP_COMMAND(x) "timeout " #x
+#define SLEEP_COMMAND(x) (x > 0 ? "ping 127.0.0.1 -n " #x : "cmd /C exit 0")
 #endif // __WINDOWS__
 
 

Reply via email to