Skip to content

Commit

Permalink
deps: update zlib to 1.2.13.1-motley-3f0af7f
Browse files Browse the repository at this point in the history
  • Loading branch information
nodejs-github-bot committed Oct 1, 2023
1 parent e4239f6 commit ef2de63
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 33 deletions.
53 changes: 53 additions & 0 deletions deps/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ check_include_file(stddef.h HAVE_STDDEF_H)
option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF)
option(ENABLE_SIMD_AVX512 "Enable SIMD AXV512 optimizations" OFF)
option(USE_ZLIB_RABIN_KARP_HASH "Enable bitstream compatibility with canonical zlib" OFF)
option(BUILD_UNITTESTS "Enable standalone unit tests build" OFF)

if (USE_ZLIB_RABIN_KARP_HASH)
add_definitions(-DUSE_ZLIB_RABIN_KARP_ROLLING_HASH)
Expand Down Expand Up @@ -244,6 +245,58 @@ set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4).
add_executable(zlib_bench contrib/bench/zlib_bench.cc)
target_link_libraries(zlib_bench zlib)

#============================================================================
# Unit Tests
#============================================================================
if (BUILD_UNITTESTS)
include (ExternalProject)
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
ExternalProject_add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG d1467f5813f4d363cfd11aba99c4e9fe47a85e99
UPDATE_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)

# gtest includedir
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIRS
${source_dir}/googletest/include
${source_dir}/googletest/include/gtest
)

# gtest library
ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_LIBRARY gtest)
add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED)
set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH})
add_dependencies(${GTEST_LIBRARY} googletest)

set(UTEST_SRC
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/infcover.cc
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/infcover.h
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/utils_unittest.cc
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/standalone_test_runner.cc
${CMAKE_CURRENT_SOURCE_DIR}/google/compression_utils_portable.cc
)

add_compile_definitions(CMAKE_STANDALONE_UNITTESTS)

add_executable(zlib_unittests ${UTEST_SRC})
target_include_directories(zlib_unittests PUBLIC ${GTEST_INCLUDE_DIRS})
target_include_directories(zlib_unittests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/google)

target_link_libraries(zlib_unittests ${GTEST_LIBRARY})
target_link_libraries(zlib_unittests zlib)
# Needed by gtest
target_link_libraries(zlib_unittests pthread)
endif()

#============================================================================
# Minigzip tool
#============================================================================
Expand Down
2 changes: 1 addition & 1 deletion deps/zlib/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 1.2.13
CPEPrefix: cpe:/a:zlib:zlib:1.2.13
Security Critical: yes
Shipped: yes
License: Custom license
License: Zlib
License File: LICENSE
License Android Compatible: yes

Expand Down
5 changes: 3 additions & 2 deletions deps/zlib/contrib/optimizations/inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,8 +1488,9 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
if (copy == Z_NULL) return Z_MEM_ERROR;
window = Z_NULL;
if (state->window != Z_NULL) {
window = (unsigned char FAR *)
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
window = (unsigned char FAR *)ZALLOC(
source, (1U << state->wbits) + CHUNKCOPY_CHUNK_SIZE,
sizeof(unsigned char));
if (window == Z_NULL) {
ZFREE(source, copy);
return Z_MEM_ERROR;
Expand Down
9 changes: 9 additions & 0 deletions deps/zlib/contrib/tests/standalone_test_runner.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the Chromium source repository LICENSE file.
#include <gtest/gtest.h>

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
14 changes: 12 additions & 2 deletions deps/zlib/contrib/tests/utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
#include <cstddef>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "compression_utils_portable.h"
#include "gtest.h"

#if !defined(CMAKE_STANDALONE_UNITTESTS)
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"

#include "third_party/zlib/contrib/minizip/unzip.h"
#include "third_party/zlib/contrib/minizip/zip.h"
#endif

#include "zlib.h"

void TestPayloads(size_t input_size, zlib_internal::WrapperType type) {
Expand Down Expand Up @@ -1020,6 +1025,9 @@ TEST(ZlibTest, DeflateZFixedCorruption) {
0);
}

// TODO(gustavoa): make these tests run standalone.
#ifndef CMAKE_STANDALONE_UNITTESTS

TEST(ZlibTest, ZipFilenameCommentSize) {
// Check that minizip rejects zip member filenames or comments longer than
// the zip format can represent.
Expand Down Expand Up @@ -1138,3 +1146,5 @@ TEST(ZlibTest, ZipExtraFieldSize) {
EXPECT_EQ(unzGoToNextFile(uzf), UNZ_END_OF_LIST_OF_FILE);
EXPECT_EQ(unzClose(uzf), UNZ_OK);
}

#endif
3 changes: 2 additions & 1 deletion deps/zlib/google/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ include_rules = [
'+base',
'+build',
'+testing',
"+third_party/zlib/zlib.h",
'+third_party/icu/source/i18n/unicode',
'+third_party/zlib/zlib.h',
]
34 changes: 10 additions & 24 deletions deps/zlib/google/zip_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/hash/md5.h"
#include "base/i18n/time_formatting.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_piece.h"
Expand All @@ -31,6 +32,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/zlib/google/zip_internal.h"

using ::testing::_;
Expand Down Expand Up @@ -288,18 +290,10 @@ TEST_F(ZipReaderTest, RegularFile) {

EXPECT_EQ(target_path, entry->path);
EXPECT_EQ(13527, entry->original_size);

// The expected time stamp: 2009-05-29 06:22:20
base::Time::Exploded exploded = {}; // Zero-clear.
entry->last_modified.UTCExplode(&exploded);
EXPECT_EQ(2009, exploded.year);
EXPECT_EQ(5, exploded.month);
EXPECT_EQ(29, exploded.day_of_month);
EXPECT_EQ(6, exploded.hour);
EXPECT_EQ(22, exploded.minute);
EXPECT_EQ(20, exploded.second);
EXPECT_EQ(0, exploded.millisecond);

EXPECT_EQ("2009-05-29 06:22:20.000",
base::UnlocalizedTimeFormatWithPattern(entry->last_modified,
"y-MM-dd HH:mm:ss.SSS",
icu::TimeZone::getGMT()));
EXPECT_FALSE(entry->is_unsafe);
EXPECT_FALSE(entry->is_directory);
}
Expand Down Expand Up @@ -396,18 +390,10 @@ TEST_F(ZipReaderTest, Directory) {
EXPECT_EQ(target_path, entry->path);
// The directory size should be zero.
EXPECT_EQ(0, entry->original_size);

// The expected time stamp: 2009-05-31 15:49:52
base::Time::Exploded exploded = {}; // Zero-clear.
entry->last_modified.UTCExplode(&exploded);
EXPECT_EQ(2009, exploded.year);
EXPECT_EQ(5, exploded.month);
EXPECT_EQ(31, exploded.day_of_month);
EXPECT_EQ(15, exploded.hour);
EXPECT_EQ(49, exploded.minute);
EXPECT_EQ(52, exploded.second);
EXPECT_EQ(0, exploded.millisecond);

EXPECT_EQ("2009-05-31 15:49:52.000",
base::UnlocalizedTimeFormatWithPattern(entry->last_modified,
"y-MM-dd HH:mm:ss.SSS",
icu::TimeZone::getGMT()));
EXPECT_FALSE(entry->is_unsafe);
EXPECT_TRUE(entry->is_directory);
}
Expand Down
6 changes: 3 additions & 3 deletions doc/contributing/maintaining/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This a list of all the dependencies:
* [undici 5.23.0][]
* [uvwasi 0.0.16][]
* [V8 11.3.244.8][]
* [zlib 1.2.13.1-motley-2359864][]
* [zlib 1.2.13.1-motley-3f0af7f][]

Any code which meets one or more of these conditions should
be managed as a dependency:
Expand Down Expand Up @@ -311,7 +311,7 @@ See [maintaining-web-assembly][] for more informations.
high-performance JavaScript and WebAssembly engine, written in C++.
See [maintaining-V8][] for more informations.

### zlib 1.2.13.1-motley-2359864
### zlib 1.2.13.1-motley-3f0af7f

The [zlib](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib)
dependency lossless data-compression library,
Expand Down Expand Up @@ -349,4 +349,4 @@ performance improvements not currently available in standard zlib.
[update-openssl-action]: ../../../.github/workflows/update-openssl.yml
[uvwasi 0.0.16]: #uvwasi-0016
[v8 11.3.244.8]: #v8-1132448
[zlib 1.2.13.1-motley-2359864]: #zlib-12131-motley-2359864
[zlib 1.2.13.1-motley-3f0af7f]: #zlib-12131-motley-3f0af7f

0 comments on commit ef2de63

Please sign in to comment.