You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/10/14 23:47:15 UTC

[1/5] mesos git commit: Windows: Updated build script to run the stout/libprocess tests.

Repository: mesos
Updated Branches:
  refs/heads/master 2fd78e6a0 -> a926cf3da


Windows: Updated build script to run the stout/libprocess tests.


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

Branch: refs/heads/master
Commit: a926cf3dacaa74f720ef7c4a2f2d2625d138b419
Parents: b0d2c05
Author: Joseph Wu <jo...@apache.org>
Authored: Fri Oct 14 16:15:34 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700

----------------------------------------------------------------------
 support/windows-build.bat | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a926cf3d/support/windows-build.bat
----------------------------------------------------------------------
diff --git a/support/windows-build.bat b/support/windows-build.bat
index 4603a2b..b3b6d0b 100644
--- a/support/windows-build.bat
+++ b/support/windows-build.bat
@@ -67,16 +67,16 @@ msbuild Mesos.sln /p:PreferredToolArchitecture=x64 /m /t:stout_tests
 if %errorlevel% neq 0 exit /b %errorlevel%
 
 REM TODO(josephw): Uncomment this after fixing the tests on Windows.
-REM "3rdparty/stout/tests/Debug/stout_tests.exe"
-REM if %errorlevel% neq 0 exit /b %errorlevel%
+"3rdparty/stout/tests/Debug/stout_tests.exe"
+if %errorlevel% neq 0 exit /b %errorlevel%
 
 REM Build and run the libprocess tests.
 msbuild Mesos.sln /p:PreferredToolArchitecture=x64 /m /t:process_tests
 if %errorlevel% neq 0 exit /b %errorlevel%
 
 REM TODO(josephw): Uncomment this after fixing the tests on Windows.
-REM "3rdparty/libprocess/src/tests/Debug/process_tests.exe"
-REM if %errorlevel% neq 0 exit /b %errorlevel%
+"3rdparty/libprocess/src/tests/Debug/process_tests.exe"
+if %errorlevel% neq 0 exit /b %errorlevel%
 
 REM Build everything else.
 msbuild Mesos.sln /p:PreferredToolArchitecture=x64 /m


[4/5] mesos git commit: Libprocess: Enabled tests that pass on Windows.

Posted by jo...@apache.org.
Libprocess: Enabled tests that pass on Windows.

A large number of libprocess test files are currently not being built on
Windows. Many of these files contain tests for parts of libprocess that
have already been ported, or require only trivial fixes to work (such as
removing `#include`s on Windows). A small minority of the tests contain
bugs that we should fix.

This commit will add these files to the build, fix some of the
trivially-fixable tests, and disable tests that are known to fail
because of bugs, including comments explaining why and links to JIRA
issues where appropriate.

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


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

Branch: refs/heads/master
Commit: b0d2c0529fe2564cfadfc6529490a98658b2d985
Parents: 2e137e8
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Oct 14 15:37:58 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/CMakeLists.txt    |   8 +-
 3rdparty/libprocess/src/tests/future_tests.cpp  |   3 +-
 3rdparty/libprocess/src/tests/http_tests.cpp    |  25 +++-
 3rdparty/libprocess/src/tests/limiter_tests.cpp |  10 +-
 3rdparty/libprocess/src/tests/metrics_tests.cpp |  12 +-
 3rdparty/libprocess/src/tests/process_tests.cpp | 113 ++++++++++++++-----
 3rdparty/libprocess/src/tests/reap_tests.cpp    |   2 +-
 .../libprocess/src/tests/subprocess_tests.cpp   |   4 +-
 3rdparty/libprocess/src/tests/time_tests.cpp    |   3 +-
 9 files changed, 130 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/CMakeLists.txt b/3rdparty/libprocess/src/tests/CMakeLists.txt
index c267117..66597fd 100644
--- a/3rdparty/libprocess/src/tests/CMakeLists.txt
+++ b/3rdparty/libprocess/src/tests/CMakeLists.txt
@@ -23,10 +23,14 @@ set(PROCESS_TESTS_SRC
   decoder_tests.cpp
   encoder_tests.cpp
   future_tests.cpp
+  http_tests.cpp
   limiter_tests.cpp
+  metrics_tests.cpp
   mutex_tests.cpp
   owned_tests.cpp
+  process_tests.cpp
   queue_tests.cpp
+  sequence_tests.cpp
   shared_tests.cpp
   statistics_tests.cpp
   subprocess_tests.cpp
@@ -38,12 +42,8 @@ set(PROCESS_TESTS_SRC
 if (NOT WIN32)
   set(PROCESS_TESTS_SRC
     ${PROCESS_TESTS_SRC}
-    http_tests.cpp
     io_tests.cpp
-    metrics_tests.cpp
-    process_tests.cpp
     reap_tests.cpp
-    sequence_tests.cpp
     )
 endif (NOT WIN32)
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/future_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/future_tests.cpp b/3rdparty/libprocess/src/tests/future_tests.cpp
index 383d260..7c411c7 100644
--- a/3rdparty/libprocess/src/tests/future_tests.cpp
+++ b/3rdparty/libprocess/src/tests/future_tests.cpp
@@ -458,7 +458,8 @@ TEST(FutureTest, Discard3)
 }
 
 
-TEST(FutureTest, Select)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(FutureTest, Select)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 8d6c8c4..533104c 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -10,12 +10,16 @@
 // See the License for the specific language governing permissions and
 // limitations under the License
 
+#ifndef __WINDOWS__
 #include <arpa/inet.h>
+#endif // __WINDOWS__
 
 #include <gmock/gmock.h>
 
+#ifndef __WINDOWS__
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#endif // __WINDOWS__
 
 #include <string>
 #include <vector>
@@ -191,7 +195,10 @@ TEST(HTTPTest, Endpoints)
 }
 
 
-TEST(HTTPTest, EndpointsHelp)
+// TODO(hausdorff): Routing logic is broken on Windows. Fix and enable test. In
+// this case, the '/help/(14)/body' route is missing, but the /help/(14) route
+// exists. See MESOS-5904.
+TEST_TEMP_DISABLED_ON_WINDOWS(HTTPTest, EndpointsHelp)
 {
   Http http;
   PID<HttpProcess> pid = http.process->self();
@@ -260,7 +267,10 @@ TEST(HTTPTest, EndpointsHelp)
 }
 
 
-TEST(HTTPTest, EndpointsHelpRemoval)
+// TODO(hausdorff): Routing logic is broken on Windows. Fix and enable test. In
+// this case, the '/help/(14)/body' route is missing, but the /help/(14) route
+// exists. See MESOS-5904.
+TEST_TEMP_DISABLED_ON_WINDOWS(HTTPTest, EndpointsHelpRemoval)
 {
   // Start up a new HttpProcess;
   Owned<Http> http(new Http());
@@ -541,7 +551,10 @@ TEST(HTTPTest, Get)
 }
 
 
-TEST(HTTPTest, NestedGet)
+// TODO(hausdorff): Routing logic is broken on Windows. Fix and enable test. In
+// this case, the route '/a/b/c' exists and returns 200 ok, but '/a/b' does
+// not. See MESOS-5904.
+TEST_TEMP_DISABLED_ON_WINDOWS(HTTPTest, NestedGet)
 {
   Http http;
 
@@ -1122,7 +1135,11 @@ TEST(HTTPConnectionTest, Equality)
 }
 
 
-TEST(HTTPTest, QueryEncodeDecode)
+// TODO(hausdorff): This test seems to create inconsistent (though not
+// incorrect) results across platforms. Fix and enable the test on Windows. In
+// particular, the encoding in the 3rd example puts the first variable into the
+// query string before the second, but we expect the reverse. See MESOS-5814.
+TEST_TEMP_DISABLED_ON_WINDOWS(HTTPTest, QueryEncodeDecode)
 {
   // If we use Type<a, b> directly inside a macro without surrounding
   // parenthesis the comma will be eaten by the macro rather than the

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/limiter_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/limiter_tests.cpp b/3rdparty/libprocess/src/tests/limiter_tests.cpp
index 71a3d25..b80b1da 100644
--- a/3rdparty/libprocess/src/tests/limiter_tests.cpp
+++ b/3rdparty/libprocess/src/tests/limiter_tests.cpp
@@ -26,7 +26,9 @@ using process::Clock;
 using process::Future;
 using process::RateLimiter;
 
-TEST(LimiterTest, Acquire)
+
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(LimiterTest, Acquire)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -56,7 +58,8 @@ TEST(LimiterTest, Acquire)
 // In this test 4 permits are given, but the 2nd permit's acquire
 // is immediately discarded. So, 1st, 3rd and 4th permits should
 // be acquired according to the rate limit.
-TEST(LimiterTest, DiscardMiddle)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(LimiterTest, DiscardMiddle)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -94,7 +97,8 @@ TEST(LimiterTest, DiscardMiddle)
 // In this test 2 permits are initially given, but the 2nd permit's
 // future is immediately discarded. Then the 3rd permit is given. So,
 // 1st and 3rd permits should be acquired according to the rate limit.
-TEST(LimiterTest, DiscardLast)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(LimiterTest, DiscardLast)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index 88526e6..d7fdb06 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -136,7 +136,8 @@ TEST_F(MetricsTest, Counter)
 }
 
 
-TEST_F(MetricsTest, Gauge)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(MetricsTest, Gauge)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -201,7 +202,8 @@ TEST_F(MetricsTest, Statistics)
 }
 
 
-TEST_F(MetricsTest, Snapshot)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(MetricsTest, Snapshot)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -273,7 +275,8 @@ TEST_F(MetricsTest, Snapshot)
 }
 
 
-TEST_F(MetricsTest, SnapshotTimeout)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(MetricsTest, SnapshotTimeout)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -507,7 +510,8 @@ TEST_F(MetricsTest, AsyncTimer)
 
 // Tests that the `/metrics/snapshot` endpoint rejects unauthenticated requests
 // when HTTP authentication is enabled.
-TEST_F(MetricsTest, SnapshotAuthenticationEnabled)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(MetricsTest, SnapshotAuthenticationEnabled)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index 3936f47..a4af54a 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -13,12 +13,16 @@
 #include <errno.h>
 #include <time.h>
 
+#ifndef __WINDOWS__
 #include <arpa/inet.h>
+#endif // __WINDOWS__
 
 #include <gmock/gmock.h>
 
+#ifndef __WINDOWS__
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#endif // __WINDOWS__
 
 #include <atomic>
 #include <sstream>
@@ -58,6 +62,7 @@
 #include <stout/try.hpp>
 
 #include <stout/os/killtree.hpp>
+#include <stout/os/write.hpp>
 
 #include "encoder.hpp"
 
@@ -120,7 +125,8 @@ public:
 };
 
 
-TEST(ProcessTest, Spawn)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Spawn)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -154,7 +160,8 @@ public:
 };
 
 
-TEST(ProcessTest, Dispatch)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Dispatch)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -190,7 +197,8 @@ TEST(ProcessTest, Dispatch)
 }
 
 
-TEST(ProcessTest, Defer1)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Defer1)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -288,7 +296,8 @@ private:
 };
 
 
-TEST(ProcessTest, Defer2)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Defer2)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -322,7 +331,8 @@ void set(T* t1, const T& t2)
 }
 
 
-TEST(ProcessTest, Defer3)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Defer3)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -356,7 +366,8 @@ public:
 };
 
 
-TEST(ProcessTest, Handlers)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Handlers)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -381,7 +392,8 @@ TEST(ProcessTest, Handlers)
 
 // Tests DROP_MESSAGE and DROP_DISPATCH and in particular that an
 // event can get dropped before being processed.
-TEST(ProcessTest, Expect)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Expect)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -412,7 +424,8 @@ TEST(ProcessTest, Expect)
 
 
 // Tests the FutureArg<N> action.
-TEST(ProcessTest, Action)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Action)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -459,7 +472,8 @@ public:
 };
 
 
-TEST(ProcessTest, Inheritance)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Inheritance)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -490,7 +504,8 @@ TEST(ProcessTest, Inheritance)
 }
 
 
-TEST(ProcessTest, Thunk)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Thunk)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -535,7 +550,8 @@ public:
 };
 
 
-TEST(ProcessTest, Delegate)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Delegate)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -568,7 +584,8 @@ public:
 };
 
 
-TEST(ProcessTest, Delay)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Delay)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -607,7 +624,8 @@ public:
 };
 
 
-TEST(ProcessTest, Order)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Order)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -662,7 +680,8 @@ public:
 };
 
 
-TEST(ProcessTest, Donate)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Donate)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -813,7 +832,9 @@ public:
 
 // Verifies that linking to a remote process will correctly detect
 // the associated `ExitedEvent`.
-TEST_F(ProcessRemoteLinkTest, RemoteLink)
+// TODO(hausdorff): Test fails on Windows. Fix and enable. Linkee never sends a
+// message because "no such program exists". See MESOS-5941.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(ProcessRemoteLinkTest, RemoteLink)
 {
   // Link to the remote subprocess.
   ExitedProcess process(pid);
@@ -866,7 +887,9 @@ private:
 // Verifies that calling `link` with "relink" semantics will have the
 // same behavior as `link` with "normal" semantics, when there is no
 // existing persistent connection.
-TEST_F(ProcessRemoteLinkTest, RemoteRelink)
+// TODO(hausdorff): Test fails on Windows. Fix and enable. Linkee never sends a
+// message because "no such program exists". See MESOS-5941.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(ProcessRemoteLinkTest, RemoteRelink)
 {
   RemoteLinkTestProcess process(pid);
 
@@ -891,7 +914,9 @@ TEST_F(ProcessRemoteLinkTest, RemoteRelink)
 
 // Verifies that linking and relinking a process will retain monitoring
 // on the linkee.
-TEST_F(ProcessRemoteLinkTest, RemoteLinkRelink)
+// TODO(hausdorff): Test fails on Windows. Fix and enable. Linkee never sends a
+// message because "no such program exists". See MESOS-5941.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(ProcessRemoteLinkTest, RemoteLinkRelink)
 {
   RemoteLinkTestProcess process(pid);
 
@@ -917,7 +942,9 @@ TEST_F(ProcessRemoteLinkTest, RemoteLinkRelink)
 
 // Verifies that relinking a remote process will not affect the
 // monitoring of the process by other linkers.
-TEST_F(ProcessRemoteLinkTest, RemoteDoubleLinkRelink)
+// TODO(hausdorff): Test fails on Windows. Fix and enable. Linkee never sends a
+// message because "no such program exists". See MESOS-5941.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(ProcessRemoteLinkTest, RemoteDoubleLinkRelink)
 {
   ExitedProcess linker(pid);
   RemoteLinkTestProcess relinker(pid);
@@ -954,7 +981,7 @@ TEST_F(ProcessRemoteLinkTest, RemoteDoubleLinkRelink)
 // Verifies that remote links will trigger an `ExitedEvent` if the link
 // fails during socket creation. The test instigates a socket creation
 // failure by hogging all available file descriptors.
-TEST_F(ProcessRemoteLinkTest, RemoteLinkLeak)
+TEST_F_TEMP_DISABLED_ON_WINDOWS(ProcessRemoteLinkTest, RemoteLinkLeak)
 {
   RemoteLinkTestProcess relinker(pid);
   Future<UPID> relinkerExitedPid;
@@ -994,6 +1021,9 @@ Option<int> get_persistent_socket(const UPID& to);
 } // namespace process {
 
 
+// TODO(hausdorff): Test disabled temporarily because `SHUT_WR` does not exist
+// on Windows. See MESOS-5817.
+#ifndef __WINDOWS__
 // Verifies that sending a message over a socket will fail if the
 // link to the target is broken (i.e. closed) outside of the
 // `SocketManager`s knowledge.
@@ -1047,8 +1077,12 @@ TEST_F(ProcessRemoteLinkTest, RemoteUseStaleLink)
   terminate(process);
   wait(process);
 }
+#endif // __WINDOWS__
 
 
+// TODO(hausdorff): Test disabled temporarily because `SHUT_WR` does not exist
+// on Windows. See MESOS-5817.
+#ifndef __WINDOWS__
 // Verifies that, in a situation where an existing remote link has become
 // "stale", "relinking" prior to sending a message will lead to successful
 // message passing. The existing remote link is broken in the same way as
@@ -1109,6 +1143,7 @@ TEST_F(ProcessRemoteLinkTest, RemoteStaleLinkRelink)
   terminate(process);
   wait(process);
 }
+#endif // __WINDOWS__
 
 
 class SettleProcess : public Process<SettleProcess>
@@ -1142,7 +1177,8 @@ public:
 };
 
 
-TEST(ProcessTest, Settle)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Settle)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1157,7 +1193,8 @@ TEST(ProcessTest, Settle)
 }
 
 
-TEST(ProcessTest, Pid)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Pid)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1192,7 +1229,8 @@ public:
 };
 
 
-TEST(ProcessTest, Listener)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Listener)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1222,7 +1260,8 @@ public:
 };
 
 
-TEST(ProcessTest, Executor)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Executor)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1270,7 +1309,8 @@ public:
 };
 
 
-TEST(ProcessTest, Remote)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Remote)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1305,7 +1345,8 @@ TEST(ProcessTest, Remote)
 
 
 // Like the 'remote' test but uses http::connect.
-TEST(ProcessTest, Http1)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Http1)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1357,7 +1398,8 @@ TEST(ProcessTest, Http1)
 
 // Like 'http1' but uses the 'Libprocess-From' header. We can
 // also use http::post here since we expect a 202 response.
-TEST(ProcessTest, Http2)
+// NOTE: GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Http2)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1475,7 +1517,8 @@ static string itoa2(int* const& i)
 }
 
 
-TEST(ProcessTest, Async)
+// GTEST_IS_THREADSAFE is not defined on Windows. See MESOS-5903.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Async)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
@@ -1510,7 +1553,10 @@ public:
 };
 
 
-TEST(ProcessTest, Provide)
+// TODO(hausdorff): Enable test when `os::rmdir` is semantically equivalent to
+// the POSIX version. In this case, it behaves poorly when we try to use it to
+// delete a file instead of a directory. See MESOS-5942.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, Provide)
 {
   const Try<string> mkdtemp = os::mkdtemp();
   ASSERT_SOME(mkdtemp);
@@ -1549,6 +1595,8 @@ static int baz(string s) { return 42; }
 static Future<int> bam(string s) { return 42; }
 
 
+// MSVC can't compile the call to std::invoke.
+#ifndef __WINDOWS__
 TEST(ProcessTest, Defers)
 {
   {
@@ -1686,6 +1734,7 @@ TEST(ProcessTest, Defers)
   Future<int> future13 = Future<string>().then(
       defer(functor));
 }
+#endif // __WINDOWS__
 
 
 class PercentEncodedIDProcess : public Process<PercentEncodedIDProcess>
@@ -1790,7 +1839,9 @@ public:
 
 // Sets firewall rules which disable endpoints on a process and then
 // attempts to connect to those endpoints.
-TEST(ProcessTest, FirewallDisablePaths)
+// TODO(hausdorff): Routing logic is broken on Windows. Fix and enable test. In
+// this case, we fail to set up the firewall routes. See MESOS-5904.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, FirewallDisablePaths)
 {
   const string id = "testprocess";
 
@@ -1875,7 +1926,9 @@ TEST(ProcessTest, FirewallDisablePaths)
 
 // Test that firewall rules can be changed by changing the vector.
 // An empty vector should allow all paths.
-TEST(ProcessTest, FirewallUninstall)
+// TODO(hausdorff): Routing logic is broken on Windows. Fix and enable test. In
+// this case, we fail to set up the firewall routes. See MESOS-5904.
+TEST_TEMP_DISABLED_ON_WINDOWS(ProcessTest, FirewallUninstall)
 {
   const string id = "testprocess";
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/reap_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/reap_tests.cpp b/3rdparty/libprocess/src/tests/reap_tests.cpp
index 586d528..30518de 100644
--- a/3rdparty/libprocess/src/tests/reap_tests.cpp
+++ b/3rdparty/libprocess/src/tests/reap_tests.cpp
@@ -55,7 +55,7 @@ TEST(ReapTest, NonChildProcess)
   //  -+- child (exit 0)
   //  -+- grandchild sleep 10
   Try<ProcessTree> tree = Fork(None(),
-                               Fork(Exec("sleep 10")),
+                               Fork(Exec(SLEEP_COMMAND(10))),
                                Exec("exit 0"))();
   ASSERT_SOME(tree);
   ASSERT_EQ(1u, tree.get().children.size());

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/subprocess_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/subprocess_tests.cpp b/3rdparty/libprocess/src/tests/subprocess_tests.cpp
index c8350cf..483ac1c 100644
--- a/3rdparty/libprocess/src/tests/subprocess_tests.cpp
+++ b/3rdparty/libprocess/src/tests/subprocess_tests.cpp
@@ -264,7 +264,7 @@ TEST_F(SubprocessTest, Status)
   AWAIT_EXPECT_WEXITSTATUS_EQ(1, s.get().status());
 
   // SIGTERM.
-  s = subprocess("sleep 60");
+  s = subprocess(SLEEP_COMMAND(60));
 
   ASSERT_SOME(s);
 
@@ -281,7 +281,7 @@ TEST_F(SubprocessTest, Status)
   AWAIT_EXPECT_WTERMSIG_EQ(SIGTERM, s.get().status());
 
   // SIGKILL.
-  s = subprocess("sleep 60");
+  s = subprocess(SLEEP_COMMAND(60));
 
   ASSERT_SOME(s);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0d2c052/3rdparty/libprocess/src/tests/time_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/time_tests.cpp b/3rdparty/libprocess/src/tests/time_tests.cpp
index 9d40eae..08ddb56 100644
--- a/3rdparty/libprocess/src/tests/time_tests.cpp
+++ b/3rdparty/libprocess/src/tests/time_tests.cpp
@@ -43,7 +43,8 @@ TEST(TimeTest, Arithmetic)
 }
 
 
-TEST(TimeTest, Now)
+// Windows OS timers aren't high enough resolution to support this.
+TEST_TEMP_DISABLED_ON_WINDOWS(TimeTest, Now)
 {
   Time t1 = Clock::now();
   os::sleep(Microseconds(10));


[3/5] mesos git commit: Made semantics of `os::rmdir` consistent between POSIX and Windows.

Posted by jo...@apache.org.
Made semantics of `os::rmdir` consistent between POSIX and Windows.

This commit will fix 2 known bugs in the Windows implementation of
`os::rmdir`, as chronicled in MESOS-5942, namely:

1. Calling `os::rmdir` with a file argument (rather than a directory)
   and the `recursive` parameter set to `true` will fail on Windows,
   but succeed on POSIX.

The POSIX semantics of `os::rmdir` are a union of `rm -r` and `::rmdir`,
the behavior of which depends on the arguments the caller passes in. If
the formal parameter `recursive` is set to `true`, then the semantics
are meant to be`rm -r`; if `false`, the semantics are meant to be
`::rmdir`.

The implications of this are somewhat subtle: `::rmdir` will error out
if you try to delete (e.g.) regular files, while `rm -r` will happily
delete them.

On Windows, we currently always have `::rmdir`-style semantics, in that
we if you pass a path that points at a file to `os::rmdir`, it will not
delete that file.

This commit will reverse this, and move make the Windows implementation
semantically identical to the POSIX implementation (at least in this
regard).

2. Recursively deleting nested directories fails on windows when
   `removeRoot` is set to `false`.

Currently if you set the `removeRoot` parameter to `false`, the Windows
implementation of `os::rmdir` will fail to delete a directory inside a
directory. The reason is that we are propagating the `removeRoot` flag
to the recursive calls to `os::rmdir`. The implication of this is that
the recursive call will *not* delete the nested directory (since
`removeRoot` is `false`).

This commit will fix this by setting `removeRoot` to `true` in recursive
calls to `os::rmdir`.

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


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

Branch: refs/heads/master
Commit: 719f7c0f335834322088e7921255a1352f4f2b41
Parents: 2fd78e6
Author: Alex Clemmer <cl...@gmail.com>
Authored: Thu Oct 13 16:25:58 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700

----------------------------------------------------------------------
 .../stout/include/stout/os/windows/rmdir.hpp    | 21 ++++++-
 3rdparty/stout/tests/os/rmdir_tests.cpp         | 59 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/719f7c0f/3rdparty/stout/include/stout/os/windows/rmdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/rmdir.hpp b/3rdparty/stout/include/stout/os/windows/rmdir.hpp
index b74bf71..4437484 100644
--- a/3rdparty/stout/include/stout/os/windows/rmdir.hpp
+++ b/3rdparty/stout/include/stout/os/windows/rmdir.hpp
@@ -21,6 +21,7 @@
 #include <stout/windows.hpp>
 
 #include <stout/os/realpath.hpp>
+#include <stout/os/rm.hpp>
 #include <stout/os/stat.hpp>
 
 #include <stout/windows/error.hpp>
@@ -29,11 +30,25 @@
 namespace os {
 namespace internal {
 
-// Recursive version of `RemoveDirectory`. NOTE: unlike `rmdir`, this requires
-// Windows-formatted paths, and therefore should be in the `internal` namespace.
+// Recursive version of `RemoveDirectory`. Two things are notable about this
+// implementation:
+//
+// 1. Unlike `rmdir`, this requires Windows-formatted paths, and therefore
+//    should be in the `internal` namespace.
+// 2. To match the semantics of the POSIX implementation, this function
+//    implements the semantics of `rm -r`, rather than `rmdir`. In particular,
+//    if `path` points at a file, this function will delete it, while a call to
+//    `rmdir` will not.
 inline Try<Nothing> recursive_remove_directory(
     const std::string& path, bool removeRoot, bool continueOnError)
 {
+  // NOTE: Special case required to match the semantics of POSIX. See comment
+  // above. As below, this also handles symlinks correctly, i.e., given a path
+  // to a symlink, we delete the symlink rather than the target.
+  if (os::stat::isfile(path)) {
+    return os::rm(path);
+  }
+
   // Appending a slash here if the path doesn't already have one simplifies
   // path join logic later, because (unlike Unix) Windows doesn't like double
   // slashes in paths.
@@ -79,7 +94,7 @@ inline Try<Nothing> recursive_remove_directory(
     // Delete current path, whether it's a directory, file, or symlink.
     if (is_directory) {
       Try<Nothing> removed = recursive_remove_directory(
-          current_absolute_path, removeRoot, continueOnError);
+          current_absolute_path, true, continueOnError);
 
       if (removed.isError()) {
         if (continueOnError) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/719f7c0f/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/stout/tests/os/rmdir_tests.cpp
index ffe234b..e19a508 100644
--- a/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -94,6 +94,65 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
 }
 
 
+// Tests behavior of `rmdir` when path points at a file instead of a directory.
+TEST_F(RmdirTest, RemoveFile)
+{
+  const string tmpdir = os::getcwd();
+  hashset<string> expectedRootListing = hashset<string>::EMPTY;
+  hashset<string> expectedSubListing = hashset<string>::EMPTY;
+
+  // Directory is initially empty.
+  EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+
+  // Successfully make directory using absolute path, and then `touch` a file
+  // in that folder.
+  const string newDirectoryName = "newDirectory";
+  const string newDirectoryAbsolutePath = path::join(tmpdir, newDirectoryName);
+  const string newFileName = "newFile";
+  const string newFileAbsolutePath = path::join(
+      newDirectoryAbsolutePath,
+      newFileName);
+
+  expectedRootListing.insert(newDirectoryName);
+  expectedSubListing.insert(newFileName);
+
+  EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
+  EXPECT_SOME(os::touch(newFileAbsolutePath));
+  EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+  EXPECT_EQ(expectedSubListing, listfiles(newDirectoryAbsolutePath));
+
+  // Successful recursive remove with `removeRoot` set to `true` (using the
+  // semantics of `rm -r`).
+  EXPECT_SOME(os::rmdir(newFileAbsolutePath));
+  EXPECT_TRUE(os::exists(newDirectoryAbsolutePath));
+  ASSERT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
+
+  // Add file to directory again.
+  EXPECT_SOME(os::touch(newFileAbsolutePath));
+
+  // Successful recursive remove with `removeRoot` set to `false` (using the
+  // semantics of `rm -r`).
+  EXPECT_SOME(os::rmdir(newFileAbsolutePath, true, false));
+  EXPECT_TRUE(os::exists(newDirectoryAbsolutePath));
+  ASSERT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
+
+  // Add file to directory again.
+  EXPECT_SOME(os::touch(newFileAbsolutePath));
+
+  // Error on non-recursive remove with `removeRoot` set to `true` (using the
+  // semantics of `rmdir`).
+  EXPECT_ERROR(os::rmdir(newFileAbsolutePath, false, true));
+  EXPECT_TRUE(os::exists(newDirectoryAbsolutePath));
+  EXPECT_TRUE(os::exists(newFileAbsolutePath));
+
+  // Error on non-recursive remove with `removeRoot` set to `false` (using the
+  // semantics of `rmdir`).
+  EXPECT_ERROR(os::rmdir(newFileAbsolutePath, false, false));
+  EXPECT_TRUE(os::exists(newDirectoryAbsolutePath));
+  EXPECT_TRUE(os::exists(newFileAbsolutePath));
+}
+
+
 TEST_F(RmdirTest, RemoveRecursiveByDefault)
 {
   const string tmpdir = os::getcwd();


[2/5] mesos git commit: Stout: Enabled tests that pass on Windows.

Posted by jo...@apache.org.
Stout: Enabled tests that pass on Windows.

A large number of Stout test files are currently not being built on
Windows.  Many of these files contain tests for parts of Stout that have
already been ported, or require only trivial fixes to work (such as
removing `#include`s on Windows). A small minority of the tests contain
bugs that we should fix.

This commit will add these files to the build, fix some of the
trivially-fixable tests, and disable tests that are known to fail
because of bugs, including comments explaining why and links to JIRA
issues where appropriate.

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


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

Branch: refs/heads/master
Commit: 2e137e8a23bb0544449c0596d63fa32221868d61
Parents: 99dfdf4
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Oct 14 13:34:10 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/gtest.hpp    | 31 ++++++++++++
 3rdparty/stout/include/stout/mac.hpp      |  6 +++
 3rdparty/stout/tests/CMakeLists.txt       | 12 ++---
 3rdparty/stout/tests/flags_tests.cpp      | 19 ++++++--
 3rdparty/stout/tests/ip_tests.cpp         |  4 +-
 3rdparty/stout/tests/mac_tests.cpp        |  4 +-
 3rdparty/stout/tests/os/process_tests.cpp |  4 +-
 3rdparty/stout/tests/os/rmdir_tests.cpp   |  8 ++-
 3rdparty/stout/tests/os_tests.cpp         | 67 ++++++++++++++++++++------
 9 files changed, 122 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/include/stout/gtest.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/gtest.hpp b/3rdparty/stout/include/stout/gtest.hpp
index fca304a..4d8106d 100644
--- a/3rdparty/stout/include/stout/gtest.hpp
+++ b/3rdparty/stout/include/stout/gtest.hpp
@@ -176,6 +176,37 @@ template <typename T1, typename T2>
   EXPECT_TRUE(actual.isNone())
 
 
+// Creates a gtest `TEST` that is disabled on Windows.
+// TODO(hausdorff): Remove after temporarily-disabled tests are fixed on
+// Windows. See MESOS-6392.
+#ifndef __WINDOWS__
+#define TEST_TEMP_DISABLED_ON_WINDOWS(test_case_name, test_name) \
+  TEST(test_case_name, test_name)
+#else
+#define TEST_TEMP_DISABLED_ON_WINDOWS(test_case_name, test_name) \
+  TEST(test_case_name, DISABLED_##test_name)
+#endif // __WINDOWS__
+
+
+// Creates a gtest `TEST_F` that is disabled on Windows.
+// TODO(hausdorff): Remove after temporarily-disabled tests are fixed on
+// Windows. See MESOS-6392.
+#ifndef __WINDOWS__
+#define TEST_F_TEMP_DISABLED_ON_WINDOWS(test_case_name, test_name) \
+  TEST_F(test_case_name, test_name)
+#else
+#define TEST_F_TEMP_DISABLED_ON_WINDOWS(test_case_name, test_name) \
+  TEST_F(test_case_name, DISABLED_##test_name)
+#endif // __WINDOWS__
+
+
+#ifndef __WINDOWS__
+#define SLEEP_COMMAND(x) "sleep " #x
+#else
+#define SLEEP_COMMAND(x) "timeout " #x
+#endif // __WINDOWS__
+
+
 inline ::testing::AssertionResult AssertExited(
     const char* actualExpr,
     const int actual)

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/include/stout/mac.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/mac.hpp b/3rdparty/stout/include/stout/mac.hpp
index 91c4fda..7ed5f38 100644
--- a/3rdparty/stout/include/stout/mac.hpp
+++ b/3rdparty/stout/include/stout/mac.hpp
@@ -20,14 +20,18 @@
 #include <stdio.h>
 #include <string.h>
 
+#ifndef __WINDOWS__
 #include <arpa/inet.h>
+#endif // __WINDOWS__
 
 #ifdef __linux__
 #include <linux/if.h>
 #include <linux/if_packet.h>
 #endif
 
+#ifndef __WINDOWS__
 #include <net/ethernet.h>
+#endif // __WINDOWS__
 
 #ifdef __APPLE__
 #include <net/if.h>
@@ -35,7 +39,9 @@
 #include <net/if_types.h>
 #endif
 
+#ifndef __WINDOWS__
 #include <sys/socket.h>
+#endif // __WINDOWS__
 #include <sys/types.h>
 
 #include <iostream>

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/CMakeLists.txt b/3rdparty/stout/tests/CMakeLists.txt
index 49971c7..e52aa62 100644
--- a/3rdparty/stout/tests/CMakeLists.txt
+++ b/3rdparty/stout/tests/CMakeLists.txt
@@ -25,6 +25,7 @@ set(STOUT_TESTS_SRC
   duration_tests.cpp
   dynamiclibrary_tests.cpp
   error_tests.cpp
+  flags_tests.cpp
   gzip_tests.cpp
   hashmap_tests.cpp
   hashset_tests.cpp
@@ -33,11 +34,13 @@ set(STOUT_TESTS_SRC
   json_tests.cpp
   jsonify_tests.cpp
   linkedhashmap_tests.cpp
+  mac_tests.cpp
   main.cpp
   multimap_tests.cpp
   none_tests.cpp
   numify_tests.cpp
   option_tests.cpp
+  os_tests.cpp
   os/env_tests.cpp
   os/filesystem_tests.cpp
   os/process_tests.cpp
@@ -47,9 +50,12 @@ set(STOUT_TESTS_SRC
   os/systems_tests.cpp
   protobuf_tests.pb.h
   protobuf_tests.proto
+  recordio_tests.cpp
   result_tests.cpp
   some_tests.cpp
   strings_tests.cpp
+  subcommand_tests.cpp
+  try_tests.cpp
   uuid_tests.cpp
   version_tests.cpp
   )
@@ -57,16 +63,10 @@ set(STOUT_TESTS_SRC
 if (NOT WIN32)
   set(STOUT_TESTS_SRC
     ${STOUT_TESTS_SRC}
-    flags_tests.cpp
-    mac_tests.cpp
-    os_tests.cpp
     path_tests.cpp
     protobuf_tests.cpp
     protobuf_tests.pb.cc
-    recordio_tests.cpp
-    subcommand_tests.cpp
     svn_tests.cpp
-    try_tests.cpp
     os/sendfile_tests.cpp
     os/signals_tests.cpp
     )

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/flags_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/flags_tests.cpp b/3rdparty/stout/tests/flags_tests.cpp
index 94ba915..201b16a 100644
--- a/3rdparty/stout/tests/flags_tests.cpp
+++ b/3rdparty/stout/tests/flags_tests.cpp
@@ -28,6 +28,8 @@
 #include <stout/some.hpp>
 #include <stout/utils.hpp>
 
+#include <stout/os/write.hpp>
+
 #include <stout/tests/utils.hpp>
 
 using flags::Flag;
@@ -226,7 +228,10 @@ TEST(FlagsTest, Flags)
 }
 
 
-TEST(FlagsTest, LoadFromEnvironment)
+// TODO(hausdorff): Enable this test on Windows. Currently setting an
+// environment variable to the blank string will cause the environment variable
+// to be deleted on Windows. See MESOS-5880.
+TEST_TEMP_DISABLED_ON_WINDOWS(FlagsTest, LoadFromEnvironment)
 {
   TestFlags flags;
 
@@ -509,7 +514,9 @@ TEST(FlagsTest, DeprecationWarning)
 }
 
 
-TEST(FlagsTest, DuplicatesFromEnvironment)
+// TODO(hausdorff): Enable this test on Windows. Currently `flags::parse`
+// assumes filesystems are rooted at '/'. See MESOS-5937.
+TEST_TEMP_DISABLED_ON_WINDOWS(FlagsTest, DuplicatesFromEnvironment)
 {
   TestFlags flags;
 
@@ -609,7 +616,7 @@ TEST(FlagsTest, Errors)
 {
   TestFlags flags;
 
-  int argc = 2;
+  const int argc = 2;
   char* argv[argc];
 
   argv[0] = (char*) "/path/to/program";
@@ -701,7 +708,7 @@ TEST(FlagsTest, MissingRequiredFlag)
       "required_flag",
       "This flag is required and has no default value.");
 
-  int argc = 2;
+  const int argc = 2;
   char* argv[argc];
 
   argv[0] = (char*) "/path/to/program";
@@ -933,7 +940,9 @@ TEST(FlagsTest, JSON)
 class FlagsFileTest : public TemporaryDirectoryTest {};
 
 
-TEST_F(FlagsFileTest, JSONFile)
+// TODO(hausdorff): Enable this test on Windows. Currently `flags::parse`
+// assumes filesystems are rooted at '/'. See MESOS-5937.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(FlagsFileTest, JSONFile)
 {
   Flags<TestFlags> flags;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/ip_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/ip_tests.cpp b/3rdparty/stout/tests/ip_tests.cpp
index 59e69a5..b5a206f 100644
--- a/3rdparty/stout/tests/ip_tests.cpp
+++ b/3rdparty/stout/tests/ip_tests.cpp
@@ -31,7 +31,9 @@ using std::string;
 using std::vector;
 
 
-TEST(NetTest, LinkDevice)
+// TODO(hausdorff): Look into enabling this test on Windows. Currently `links`
+// is not implemented on Windows. See MESOS-5938.
+TEST_TEMP_DISABLED_ON_WINDOWS(NetTest, LinkDevice)
 {
   Try<set<string>> links = net::links();
   ASSERT_SOME(links);

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/mac_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/mac_tests.cpp b/3rdparty/stout/tests/mac_tests.cpp
index ebd50a0..d4560e7 100644
--- a/3rdparty/stout/tests/mac_tests.cpp
+++ b/3rdparty/stout/tests/mac_tests.cpp
@@ -30,7 +30,9 @@ using std::string;
 using std::vector;
 
 
-TEST(NetTest, Mac)
+// TODO(hausdorff): Look into enabling this test on Windows. Currently `links`
+// is not implemented on Windows. See MESOS-5938.
+TEST_TEMP_DISABLED_ON_WINDOWS(NetTest, Mac)
 {
   Try<set<string>> links = net::links();
   ASSERT_SOME(links);

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/os/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/process_tests.cpp b/3rdparty/stout/tests/os/process_tests.cpp
index 4977d02..4cb3b5f 100644
--- a/3rdparty/stout/tests/os/process_tests.cpp
+++ b/3rdparty/stout/tests/os/process_tests.cpp
@@ -253,8 +253,8 @@ TEST_F(ProcessTest, Pstree)
 
   tree =
     Fork(None(),                   // Child.
-      Fork(Exec("sleep 10")),   // Grandchild.
-      Exec("sleep 10"))();
+      Fork(Exec(SLEEP_COMMAND(10))),   // Grandchild.
+      Exec(SLEEP_COMMAND(10)))();
 
   ASSERT_SOME(tree);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/stout/tests/os/rmdir_tests.cpp
index cd46336..9aa4059 100644
--- a/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -234,7 +234,8 @@ TEST_F(RmdirTest, FailToRemoveNestedInvalidPath)
 // `mknod` will implement the functionality expressed in this test, and as the
 // need for these capabilities arise elsewhere in the codebase, we should
 // rethink abstractions we need here, and subsequently, what this test should
-// look like.
+// look like. This is `#ifdef`'d rather than `DISABLED_` because `rdev` doesn't
+// exist on Windows.
 TEST_F(RmdirTest, RemoveDirectoryWithDeviceFile)
 {
   // mknod requires root permission.
@@ -272,9 +273,12 @@ TEST_F(RmdirTest, RemoveDirectoryWithDeviceFile)
 #endif // __WINDOWS__
 
 
+// TODO(hausdorff): Look into enabling this test on Windows. Currently it is
+// not possible to create a symlink on Windows unless the target exists. See
+// MESOS-5881.
 // This test verifies that `rmdir` can remove a directory with a
 // symlink that has no target.
-TEST_F(RmdirTest, RemoveDirectoryWithNoTargetSymbolicLink)
+TEST_F_TEMP_DISABLED_ON_WINDOWS(RmdirTest, RemoveDirectoryNoTargetSymbolicLink)
 {
   const string newDirectory = path::join(os::getcwd(), "newDirectory");
   ASSERT_SOME(os::mkdir(newDirectory));

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e137e8a/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os_tests.cpp b/3rdparty/stout/tests/os_tests.cpp
index 6a7b836..0b7ee07 100644
--- a/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/stout/tests/os_tests.cpp
@@ -12,7 +12,7 @@
 
 #include <stdint.h>
 
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__WINDOWS__)
 #include <sys/time.h> // For gettimeofday.
 #endif
 #ifdef __FreeBSD__
@@ -39,6 +39,10 @@
 #include <stout/hashset.hpp>
 #include <stout/numify.hpp>
 #include <stout/os.hpp>
+#include <stout/os/environment.hpp>
+#include <stout/os/kill.hpp>
+#include <stout/os/killtree.hpp>
+#include <stout/os/write.hpp>
 #include <stout/stopwatch.hpp>
 #include <stout/strings.hpp>
 #include <stout/try.hpp>
@@ -50,7 +54,9 @@
 
 #include <stout/tests/utils.hpp>
 
+#ifndef __WINDOWS__
 using os::Exec;
+#endif // __WINDOWS__
 using os::Fork;
 using os::Process;
 using os::ProcessTree;
@@ -79,7 +85,10 @@ static bool isJailed() {
 class OsTest : public TemporaryDirectoryTest {};
 
 
-TEST_F(OsTest, Environment)
+// TODO(hausdorff): Enable this test on Windows. Currently setting an
+// environment variable to the blank string will cause the environment variable
+// to be deleted on Windows. See MESOS-5880.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Environment)
 {
   // Make sure the environment has some entries with '=' in the value.
   os::setenv("SOME_SPECIAL_FLAG", "--flag=foobar");
@@ -117,7 +126,7 @@ TEST_F(OsTest, Argv)
 TEST_F(OsTest, System)
 {
   EXPECT_EQ(0, os::system("exit 0"));
-  EXPECT_EQ(0, os::system("sleep 0"));
+  EXPECT_EQ(0, os::system(SLEEP_COMMAND(0)));
   EXPECT_NE(0, os::system("exit 1"));
   EXPECT_NE(0, os::system("invalid.command"));
 
@@ -127,7 +136,8 @@ TEST_F(OsTest, System)
 }
 
 
-TEST_F(OsTest, Cloexec)
+// NOTE: Disabled because `os::cloexec` is not implemented on Windows.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Cloexec)
 {
   Try<int> fd = os::open(
       "cloexec",
@@ -151,6 +161,8 @@ TEST_F(OsTest, Cloexec)
 }
 
 
+// NOTE: Disabled because `os::nonblock` doesn't exist on Windows.
+#ifndef __WINDOWS__
 TEST_F(OsTest, Nonblock)
 {
   int pipes[2];
@@ -170,13 +182,17 @@ TEST_F(OsTest, Nonblock)
   EXPECT_ERROR(os::nonblock(pipes[0]));
   EXPECT_ERROR(os::nonblock(pipes[1]));
 }
+#endif // __WINDOWS__
 
 
+// TODO(hausdorff): Fix this issue and enable the test on Windows. It fails
+// because `os::size` is not following symlinks correctly on Windows. See
+// MESOS-5939.
 // Tests whether a file's size is reported by os::stat::size as expected.
 // Tests all four combinations of following a link or not and of a file
 // or a link as argument. Also tests that an error is returned for a
 // non-existing file.
-TEST_F(OsTest, Size)
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Size)
 {
   const string file = path::join(os::getcwd(), UUID::random().toString());
 
@@ -228,7 +244,9 @@ TEST_F(OsTest, BootId)
 }
 
 
-TEST_F(OsTest, Sleep)
+// TODO(hausdorff): Enable test on Windows after we fix. The test hangs. See
+// MESOS-3441.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Sleep)
 {
   Duration duration = Milliseconds(10);
   Stopwatch stopwatch;
@@ -292,6 +310,8 @@ TEST_F(OsTest, Sysctl)
 #endif // __APPLE__ || __FreeBSD__
 
 
+// TODO(hausdorff): Enable when we implement `Fork` and `Exec`. See MESOS-3638.
+#ifndef __WINDOWS__
 TEST_F(OsTest, Children)
 {
   Try<set<pid_t>> children = os::children(getpid());
@@ -301,8 +321,8 @@ TEST_F(OsTest, Children)
 
   Try<ProcessTree> tree =
     Fork(None(),                   // Child.
-         Fork(Exec("sleep 10")),   // Grandchild.
-         Exec("sleep 10"))();
+         Fork(Exec(SLEEP_COMMAND(10))),   // Grandchild.
+         Exec(SLEEP_COMMAND(10)))();
 
   ASSERT_SOME(tree);
   ASSERT_EQ(1u, tree.get().children.size());
@@ -357,10 +377,10 @@ TEST_F(OsTest, Killtree)
          Fork(None(),                      // Grandchild.
               Fork(None(),                 // Great-grandchild.
                    Fork(&dosetsid,         // Great-great-granchild.
-                        Exec("sleep 10")),
-                   Exec("sleep 10")),
+                        Exec(SLEEP_COMMAND(10))),
+                   Exec(SLEEP_COMMAND(10))),
               Exec("exit 0")),
-         Exec("sleep 10"))();
+         Exec(SLEEP_COMMAND(10)))();
 
   ASSERT_SOME(tree);
 
@@ -479,8 +499,8 @@ TEST_F(OsTest, KilltreeNoRoot)
     Fork(&dosetsid,       // Child.
          Fork(None(),     // Grandchild.
               Fork(None(),
-                   Exec("sleep 100")),
-              Exec("sleep 100")),
+                   Exec(SLEEP_COMMAND(100))),
+              Exec(SLEEP_COMMAND(100))),
          Exec("exit 0"))();
   ASSERT_SOME(tree);
 
@@ -705,11 +725,15 @@ TEST_F(OsTest, User)
   EXPECT_SOME(os::setgroups(gids.get(), uid.get()));
   EXPECT_SOME(os::setuid(uid.get()));
 }
+#endif // __WINDOWS__
 
 
+// TODO(hausdorff): Look into enabling this on Windows. Right now,
+// `LD_LIBRARY_PATH` doesn't exist on Windows, so `setPaths` doesn't work. See
+// MESOS-5940.
 // Test setting/resetting/appending to LD_LIBRARY_PATH environment
 // variable (DYLD_LIBRARY_PATH on OS X).
-TEST_F(OsTest, Libraries)
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Libraries)
 {
   const string path1 = "/tmp/path1";
   const string path2 = "/tmp/path1";
@@ -747,7 +771,9 @@ TEST_F(OsTest, Libraries)
 }
 
 
-TEST_F(OsTest, Shell)
+// TODO(hausdorff): Port this test to Windows; these shell commands as they
+// exist now don't make much sense to the Windows cmd prompt. See MESOS-3441.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Shell)
 {
   Try<string> result = os::shell("echo %s", "hello world");
   EXPECT_SOME_EQ("hello world\n", result);
@@ -774,6 +800,8 @@ TEST_F(OsTest, Shell)
 }
 
 
+// NOTE: Disabled on Windows because `mknod` does not exist.
+#ifndef __WINDOWS__
 TEST_F(OsTest, Mknod)
 {
   // mknod requires root permission.
@@ -802,9 +830,13 @@ TEST_F(OsTest, Mknod)
 
   EXPECT_SOME(os::rm(another));
 }
+#endif // __WINDOWS__
 
 
-TEST_F(OsTest, Realpath)
+// TODO(hausdorff): Look into enabling this test on Windows. Currently it is
+// not possible to create a symlink on Windows unless the target exists. See
+// MESOS-5881.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Realpath)
 {
   // Create a file.
   const Try<string> _testFile = os::mktemp();
@@ -839,6 +871,8 @@ TEST_F(OsTest, Realpath)
 }
 
 
+// NOTE: Disabled on Windows because `which` doesn't exist.
+#ifndef __WINDOWS__
 TEST_F(OsTest, Which)
 {
   // TODO(jieyu): Test PATH search ordering and file execution bit.
@@ -848,3 +882,4 @@ TEST_F(OsTest, Which)
   which = os::which("bar");
   EXPECT_NONE(which);
 }
+#endif // __WINDOWS__


[5/5] mesos git commit: Cleaned up style in stout rmdir_tests.cpp.

Posted by jo...@apache.org.
Cleaned up style in stout rmdir_tests.cpp.

Change a few test variables to `const` and made use of initializer lists
as these variables are only modified once at the beginning of the tests.

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


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

Branch: refs/heads/master
Commit: 99dfdf48c1aebb5ccc310edebcf59b4c84e6e810
Parents: 719f7c0
Author: Joseph Wu <jo...@apache.org>
Authored: Thu Oct 13 16:36:28 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/tests/os/rmdir_tests.cpp | 33 ++++++++++++----------------
 1 file changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/99dfdf48/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/stout/tests/os/rmdir_tests.cpp
index e19a508..cd46336 100644
--- a/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -54,15 +54,15 @@ class RmdirTest : public TemporaryDirectoryTest {};
 TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
 {
   const string tmpdir = os::getcwd();
-  hashset<string> expectedListing = hashset<string>::EMPTY;
 
   // Directory is initially empty.
-  EXPECT_EQ(expectedListing, listfiles(tmpdir));
+  EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
 
   // Successfully make directory using absolute path.
   const string newDirectoryName = "newDirectory";
   const string newDirectoryAbsolutePath = path::join(tmpdir, newDirectoryName);
-  expectedListing.insert(newDirectoryName);
+  const hashset<string> expectedListing = { newDirectoryName };
+
   EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
   EXPECT_EQ(expectedListing, listfiles(tmpdir));
   EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
@@ -76,14 +76,14 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
 TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
 {
   const string tmpdir = os::getcwd();
-  hashset<string> expectedListing = hashset<string>::EMPTY;
 
   // Directory is initially empty.
-  EXPECT_EQ(expectedListing, listfiles(tmpdir));
+  EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
 
   // Successfully make directory using relative path.
   const string newDirectoryName = "newDirectory";
-  expectedListing.insert(newDirectoryName);
+  const hashset<string> expectedListing = { newDirectoryName };
+
   EXPECT_SOME(os::mkdir(newDirectoryName));
   EXPECT_EQ(expectedListing, listfiles(tmpdir));
   EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryName));
@@ -98,11 +98,9 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
 TEST_F(RmdirTest, RemoveFile)
 {
   const string tmpdir = os::getcwd();
-  hashset<string> expectedRootListing = hashset<string>::EMPTY;
-  hashset<string> expectedSubListing = hashset<string>::EMPTY;
 
   // Directory is initially empty.
-  EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+  EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
 
   // Successfully make directory using absolute path, and then `touch` a file
   // in that folder.
@@ -113,8 +111,8 @@ TEST_F(RmdirTest, RemoveFile)
       newDirectoryAbsolutePath,
       newFileName);
 
-  expectedRootListing.insert(newDirectoryName);
-  expectedSubListing.insert(newFileName);
+  const hashset<string> expectedRootListing = { newDirectoryName };
+  const hashset<string> expectedSubListing = { newFileName };
 
   EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
   EXPECT_SOME(os::touch(newFileAbsolutePath));
@@ -156,11 +154,9 @@ TEST_F(RmdirTest, RemoveFile)
 TEST_F(RmdirTest, RemoveRecursiveByDefault)
 {
   const string tmpdir = os::getcwd();
-  hashset<string> expectedRootListing = hashset<string>::EMPTY;
-  hashset<string> expectedSubListing = hashset<string>::EMPTY;
 
   // Directory is initially empty.
-  EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+  EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
 
   // Successfully make directory using absolute path, and then `touch` a file
   // in that folder.
@@ -171,8 +167,8 @@ TEST_F(RmdirTest, RemoveRecursiveByDefault)
       newDirectoryAbsolutePath,
       newFileName);
 
-  expectedRootListing.insert(newDirectoryName);
-  expectedSubListing.insert(newFileName);
+  const hashset<string> expectedRootListing = { newDirectoryName };
+  const hashset<string> expectedSubListing = { newFileName };
 
   EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
   EXPECT_SOME(os::touch(newFileAbsolutePath));
@@ -203,16 +199,15 @@ TEST_F(RmdirTest, TrivialFailToRemoveInvalidPath)
 TEST_F(RmdirTest, FailToRemoveNestedInvalidPath)
 {
   const string tmpdir = os::getcwd();
-  hashset<string> expectedRootListing = hashset<string>::EMPTY;
 
   // Directory is initially empty.
-  EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+  EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
 
   // Successfully make directory using absolute path.
   const string newDirectoryName = "newDirectory";
   const string newDirectoryAbsolutePath = path::join(tmpdir, newDirectoryName);
 
-  expectedRootListing.insert(newDirectoryName);
+  const hashset<string> expectedRootListing = { newDirectoryName };
 
   EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
   EXPECT_EQ(expectedRootListing, listfiles(tmpdir));