You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/04/22 07:30:35 UTC

[5/6] mesos git commit: Added `systems_tests.cpp` to stout.

Added `systems_tests.cpp` to stout.

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


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

Branch: refs/heads/master
Commit: 3c5712e856ef2d910f5e9b3e595ea5a4201dce1a
Parents: 3287552
Author: Alex Clemmer <cl...@gmail.com>
Authored: Thu Apr 21 11:51:41 2016 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Thu Apr 21 22:26:42 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/Makefile.am  |  1 +
 .../3rdparty/stout/tests/CMakeLists.txt         |  1 +
 .../3rdparty/stout/tests/os/systems_tests.cpp   | 78 ++++++++++++++++++++
 .../3rdparty/stout/tests/os_tests.cpp           | 36 ---------
 4 files changed, 80 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3c5712e8/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index ad8731d..08ede41 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -52,6 +52,7 @@ EXTRA_DIST =					\
   tests/os/sendfile_tests.cpp			\
   tests/os/signals_tests.cpp			\
   tests/os/strerror_tests.cpp			\
+  tests/os/systems_tests.cpp			\
   tests/path_tests.cpp				\
   tests/proc_tests.cpp				\
   tests/protobuf_tests.cpp			\

http://git-wip-us.apache.org/repos/asf/mesos/blob/3c5712e8/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
index b6de810..7b3b2a5 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
+++ b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
@@ -43,6 +43,7 @@ set(STOUT_TESTS_SRC
   os/process_tests.cpp
   os/rmdir_tests.cpp
   os/strerror_tests.cpp
+  os/systems_tests.cpp
   protobuf_tests.pb.h
   protobuf_tests.proto
   result_tests.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/3c5712e8/3rdparty/libprocess/3rdparty/stout/tests/os/systems_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os/systems_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os/systems_tests.cpp
new file mode 100644
index 0000000..110ba5b
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os/systems_tests.cpp
@@ -0,0 +1,78 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+#include <stout/os.hpp>
+
+#include <stout/tests/utils.hpp>
+
+using std::string;
+
+
+class SystemsTests : public TemporaryDirectoryTest {};
+
+
+TEST_F(SystemsTests, Uname)
+{
+  const Try<os::UTSInfo> info = os::uname();
+
+  ASSERT_SOME(info);
+#ifdef __linux__
+  EXPECT_EQ(info.get().sysname, "Linux");
+
+  // Machine arch must be non-empty.
+  EXPECT_FALSE(info.get().machine.empty());
+#elif defined(__APPLE__)
+  EXPECT_EQ(info.get().sysname, "Darwin");
+
+  // Machine arch must be non-empty.
+  EXPECT_FALSE(info.get().machine.empty());
+#elif defined(__WINDOWS__)
+  // On Windows, `sysname` is one of 2 options.
+  hashset<string> server_types{"Windows", "Windows Server"};
+  EXPECT_TRUE(server_types.contains(info.get().sysname));
+
+  // On Windows, we `machine` takes one of 5 values.
+  hashset<string> arch_types{"AMD64", "ARM", "IA64", "x86", "Unknown"};
+  EXPECT_TRUE(arch_types.contains(info.get().machine));
+#endif // __linux__
+
+  // The `release`, `version`, and `nodename` properties should all be
+  // populated with a string of at least 1 character.
+  EXPECT_GT(info.get().release.size(), 0);
+  EXPECT_GT(info.get().version.size(), 0);
+  EXPECT_GT(info.get().nodename.size(), 0);
+}
+
+
+TEST_F(SystemsTests, Sysname)
+{
+  const Try<string> name = os::sysname();
+
+  ASSERT_SOME(name);
+#ifdef __linux__
+  EXPECT_EQ(name.get(), "Linux");
+#elif defined(__APPLE__)
+  EXPECT_EQ(name.get(), "Darwin");
+#elif defined(__WINDOWS__)
+  // On Windows, `sysname` is one of 2 options.
+  hashset<string> server_types{ "Windows", "Windows Server" };
+  EXPECT_TRUE(server_types.contains(name.get()));
+#endif // __linux__
+}
+
+
+TEST_F(SystemsTests, Release)
+{
+  const Try<Version> info = os::release();
+
+  ASSERT_SOME(info);
+}

http://git-wip-us.apache.org/repos/asf/mesos/blob/3c5712e8/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
index 6c65ac1..5f00f56 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
@@ -216,42 +216,6 @@ TEST_F(OsTest, BootId)
 }
 
 
-TEST_F(OsTest, Uname)
-{
-  const Try<os::UTSInfo> info = os::uname();
-
-  ASSERT_SOME(info);
-#ifdef __linux__
-  EXPECT_EQ(info.get().sysname, "Linux");
-#endif
-#ifdef __APPLE__
-  EXPECT_EQ(info.get().sysname, "Darwin");
-#endif
-}
-
-
-TEST_F(OsTest, Sysname)
-{
-  const Try<string> name = os::sysname();
-
-  ASSERT_SOME(name);
-#ifdef __linux__
-  EXPECT_EQ(name.get(), "Linux");
-#endif
-#ifdef __APPLE__
-  EXPECT_EQ(name.get(), "Darwin");
-#endif
-}
-
-
-TEST_F(OsTest, Release)
-{
-  const Try<Version> info = os::release();
-
-  ASSERT_SOME(info);
-}
-
-
 TEST_F(OsTest, Sleep)
 {
   Duration duration = Milliseconds(10);