mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [3/8] mesos git commit: CMake: [3/3] Enabled zlib compression tests.
Date Fri, 11 Mar 2016 17:05:17 GMT
CMake: [3/3] Enabled zlib compression tests.

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


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

Branch: refs/heads/master
Commit: 7b8d98950558ce8f87af55a094d01b0b624e72f5
Parents: fe436bc
Author: Dario Bazan <dariopb@gmail.com>
Authored: Fri Mar 11 11:28:52 2016 -0500
Committer: Joris Van Remoortere <joris.van.remoortere@gmail.com>
Committed: Fri Mar 11 12:03:28 2016 -0500

----------------------------------------------------------------------
 .../3rdparty/stout/cmake/StoutConfigure.cmake   |   4 +
 .../3rdparty/stout/include/Makefile.am          |   2 -
 .../3rdparty/stout/include/stout/gzip.hpp       | 137 ++++++++++++++++-
 .../3rdparty/stout/include/stout/posix/gzip.hpp | 149 -------------------
 .../stout/include/stout/windows/gzip.hpp        |  46 ------
 .../3rdparty/stout/tests/CMakeLists.txt         |   2 +-
 6 files changed, 135 insertions(+), 205 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake b/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
index 40482e6..aa28c1b 100644
--- a/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
+++ b/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
@@ -42,6 +42,7 @@ if (WIN32)
   set(STOUT_DEPENDENCIES
     ${STOUT_DEPENDENCIES}
     ${CURL_TARGET}
+    ${ZLIB_TARGET}
     )
 endif (WIN32)
 
@@ -64,6 +65,7 @@ if (WIN32)
   set(STOUT_INCLUDE_DIRS
     ${STOUT_INCLUDE_DIRS}
     ${CURL_INCLUDE_DIR}
+    ${ZLIB_INCLUDE_DIR}
     )
 endif (WIN32)
 
@@ -83,6 +85,7 @@ if (WIN32)
   set(STOUT_LIB_DIRS
     ${STOUT_LIB_DIRS}
     ${CURL_LIB_DIR}
+    ${ZLIB_LIB_DIR}
     )
 endif (WIN32)
 
@@ -101,6 +104,7 @@ set(STOUT_LIBS
 if (WIN32)
   set(STOUT_LIBS
     ${STOUT_LIBS}
+    ${ZLIB_LFLAG}
     ws2_32
     Mswsock
     )

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index c10c6d9..d713f18 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -138,7 +138,6 @@ nobase_include_HEADERS =		\
   stout/protobuf.hpp			\
   stout/posix/dynamiclibrary.hpp	\
   stout/posix/fs.hpp			\
-  stout/posix/gzip.hpp			\
   stout/posix/os.hpp			\
   stout/recordio.hpp			\
   stout/representation.hpp			\
@@ -165,5 +164,4 @@ nobase_include_HEADERS =		\
   stout/windows/error.hpp		\
   stout/windows/format.hpp		\
   stout/windows/fs.hpp			\
-  stout/windows/gzip.hpp		\
   stout/windows/os.hpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
index 3d074a5..b78a8a3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
@@ -13,14 +13,137 @@
 #ifndef __STOUT_GZIP_HPP__
 #define __STOUT_GZIP_HPP__
 
+#include <zlib.h>
 
-// For readability, we minimize the number of #ifdef blocks in the code by
-// splitting platform specifc system calls into separate directories.
-#ifdef __WINDOWS__
-#include <stout/windows/gzip.hpp>
-#else
-#include <stout/posix/gzip.hpp>
-#endif // __WINDOWS__
+#include <string>
 
+#include <stout/error.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
+
+
+// Compression utilities.
+// TODO(bmahler): Provide streaming compression / decompression as well.
+namespace gzip {
+
+// We use a 16KB buffer with zlib compression / decompression.
+#define GZIP_BUFFER_SIZE 16384
+
+// Returns a gzip compressed version of the provided string.
+// The compression level should be within the range [-1, 9].
+// See zlib.h:
+//   #define Z_NO_COMPRESSION         0
+//   #define Z_BEST_SPEED             1
+//   #define Z_BEST_COMPRESSION       9
+//   #define Z_DEFAULT_COMPRESSION  (-1)
+inline Try<std::string> compress(
+    const std::string& decompressed,
+    int level = Z_DEFAULT_COMPRESSION)
+{
+  // Verify the level is within range.
+  if (!(level == Z_DEFAULT_COMPRESSION ||
+      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
+    return Error("Invalid compression level: " + stringify(level));
+  }
+
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
+  stream.avail_in = decompressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = deflateInit2(
+      &stream,
+      level,          // Compression level.
+      Z_DEFLATED,     // Compression method.
+      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
+      8,              // Default memLevel value.
+      Z_DEFAULT_STRATEGY);
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the compressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      deflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = deflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+
+// Returns a gzip decompressed version of the provided string.
+inline Try<std::string> decompress(const std::string& compressed)
+{
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
+  stream.avail_in = compressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = inflateInit2(
+      &stream,
+      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the decompressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      inflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = inflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+} // namespace gzip {
 
 #endif // __STOUT_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
deleted file mode 100644
index eb52beb..0000000
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
+++ /dev/null
@@ -1,149 +0,0 @@
-// 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.
-
-#ifndef __STOUT_POSIX_GZIP_HPP__
-#define __STOUT_POSIX_GZIP_HPP__
-
-#include <zlib.h>
-
-#include <string>
-
-#include <stout/error.hpp>
-#include <stout/stringify.hpp>
-#include <stout/try.hpp>
-
-
-// Compression utilities.
-// TODO(bmahler): Provide streaming compression / decompression as well.
-namespace gzip {
-
-// We use a 16KB buffer with zlib compression / decompression.
-#define GZIP_BUFFER_SIZE 16384
-
-// Returns a gzip compressed version of the provided string.
-// The compression level should be within the range [-1, 9].
-// See zlib.h:
-//   #define Z_NO_COMPRESSION         0
-//   #define Z_BEST_SPEED             1
-//   #define Z_BEST_COMPRESSION       9
-//   #define Z_DEFAULT_COMPRESSION  (-1)
-inline Try<std::string> compress(
-    const std::string& decompressed,
-    int level = Z_DEFAULT_COMPRESSION)
-{
-  // Verify the level is within range.
-  if (!(level == Z_DEFAULT_COMPRESSION ||
-      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
-    return Error("Invalid compression level: " + stringify(level));
-  }
-
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
-  stream.avail_in = decompressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = deflateInit2(
-      &stream,
-      level,          // Compression level.
-      Z_DEFLATED,     // Compression method.
-      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
-      8,              // Default memLevel value.
-      Z_DEFAULT_STRATEGY);
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the compressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      deflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = deflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-
-// Returns a gzip decompressed version of the provided string.
-inline Try<std::string> decompress(const std::string& compressed)
-{
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
-  stream.avail_in = compressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = inflateInit2(
-      &stream,
-      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the decompressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      inflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = inflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-} // namespace gzip {
-
-#endif // __STOUT_POSIX_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
deleted file mode 100644
index 8698e99..0000000
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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.
-
-#ifndef __STOUT_WINDOWS_GZIP_HPP__
-#define __STOUT_WINDOWS_GZIP_HPP__
-
-#include <string>
-
-#include <stout/try.hpp>
-
-
-namespace gzip {
-
-// Returns a gzip compressed version of the provided string.
-// The compression level should be within the range [-1, 9].
-// See zlib.h:
-//   #define Z_NO_COMPRESSION         0
-//   #define Z_BEST_SPEED             1
-//   #define Z_BEST_COMPRESSION       9
-//   #define Z_DEFAULT_COMPRESSION  (-1)
-inline Try<std::string> compress(
-    const std::string& decompressed,
-    int level = Z_DEFAULT_COMPRESSION)
-{
-  UNIMPLEMENTED;
-}
-
-
-// Returns a gzip decompressed version of the provided string.
-inline Try<std::string> decompress(const std::string& compressed)
-{
-  UNIMPLEMENTED;
-}
-
-} // namespace gzip {
-
-#endif // __STOUT_WINDOWS_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/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 03e09fb..c9d331d 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
+++ b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
@@ -25,6 +25,7 @@ set(STOUT_TESTS_SRC
   duration_tests.cpp
   dynamiclibrary_tests.cpp
   error_tests.cpp
+  gzip_tests.cpp
   hashmap_tests.cpp
   hashset_tests.cpp
   interval_tests.cpp
@@ -53,7 +54,6 @@ if (NOT WIN32)
   set(STOUT_TESTS_SRC
     ${STOUT_TESTS_SRC}
     flags_tests.cpp
-    gzip_tests.cpp
     mac_tests.cpp
     os_tests.cpp
     path_tests.cpp


Mime
View raw message