You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/02/01 22:18:41 UTC

mesos git commit: Fixed ShasumTest.SHA512SimpleFile on centos7.

Repository: mesos
Updated Branches:
  refs/heads/master 8b7f0f5c2 -> 8b5523d2c


Fixed ShasumTest.SHA512SimpleFile on centos7.

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


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

Branch: refs/heads/master
Commit: 8b5523d2c512cfab4b69b70960515c4a8d791d2b
Parents: 8b7f0f5
Author: haosdent huang <ha...@gmail.com>
Authored: Mon Feb 1 13:17:00 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Feb 1 13:18:21 2016 -0800

----------------------------------------------------------------------
 src/common/command_utils.cpp             | 28 +++++++++++++++------------
 src/tests/common/command_utils_tests.cpp |  2 +-
 2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8b5523d2/src/common/command_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/command_utils.cpp b/src/common/command_utils.cpp
index 722d0b4..68b7fac 100644
--- a/src/common/command_utils.cpp
+++ b/src/common/command_utils.cpp
@@ -166,19 +166,29 @@ Future<Nothing> untar(
 }
 
 
-static Future<string> shasum(const string& algorithm, const Path& input)
+Future<string> sha512(const Path& input)
 {
+#ifdef __linux__
+  const string cmd = "sha512sum";
   vector<string> argv = {
-    "shasum",
-    "-a", algorithm,  // Shasum type.
+    cmd,
     input             // Input file to compute shasum.
   };
+#else
+  const string cmd = "shasum";
+  vector<string> argv = {
+    cmd,
+    "-a", "512",      // Shasum type.
+    input             // Input file to compute shasum.
+  };
+#endif // __linux__
 
-  return launch("shasum", argv)
-    .then([](const string& output) -> Future<string> {
+  return launch(cmd, argv)
+    .then([cmd](const string& output) -> Future<string> {
       vector<string> tokens = strings::tokenize(output, " ");
       if (tokens.size() < 2) {
-        return Failure("Failed to parse '" + output + "' from shasum command");
+        return Failure(
+            "Failed to parse '" + output + "' from '" + cmd +  "' command");
       }
 
       // TODO(jojy): Check the size of tokens[0].
@@ -187,12 +197,6 @@ static Future<string> shasum(const string& algorithm, const Path& input)
     });
 }
 
-
-Future<string> sha512(const Path& input)
-{
-  return shasum("512", input);
-}
-
 } // namespace command {
 } // namespace internal {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/8b5523d2/src/tests/common/command_utils_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/common/command_utils_tests.cpp b/src/tests/common/command_utils_tests.cpp
index e81c724..9207a1b 100644
--- a/src/tests/common/command_utils_tests.cpp
+++ b/src/tests/common/command_utils_tests.cpp
@@ -226,7 +226,7 @@ TEST_F(TarTest, GZIPChangeDirectory)
 class ShasumTest : public TemporaryDirectoryTest {};
 
 
-TEST_F(ShasumTest, DISABLED_SHA512SimpleFile)
+TEST_F(ShasumTest, SHA512SimpleFile)
 {
   const Path testFile(path::join(os::getcwd(), "test"));