Skip to content

Commit

Permalink
[ios] Make zlib_unittests pass on iOS.
Browse files Browse the repository at this point in the history
Change OS_MAC to OS_APPLE to define same behavior for iOS as Mac.
Add globlist, filelist so we can bundle the test data up into
a PAK file to run.

Bug: 1429689
Change-Id: Ib401cda45edab951a8e9483056685734a03edff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4389623
Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1125638}
  • Loading branch information
dtapuska authored and Chromium LUCI CQ committed Apr 3, 2023
1 parent 47920d0 commit d618ef5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
4 changes: 4 additions & 0 deletions third_party/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ if (build_with_chromium) {

data = [ "google/test/data/" ]

if (is_ios) {
bundle_deps = [ "google:zlib_pak_bundle_data" ]
}

deps = [
":zlib",
"google:compression_utils",
Expand Down
11 changes: 11 additions & 0 deletions third_party/zlib/google/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

import("//build_overrides/build.gni")

if (build_with_chromium && is_ios) {
import("//build/config/ios/bundle_data_from_filelist.gni")
}

if (build_with_chromium) {
static_library("zip") {
sources = [
Expand Down Expand Up @@ -35,6 +39,13 @@ if (build_with_chromium) {
]
public_deps = [ ":compression_utils_portable" ]
}

if (is_ios) {
bundle_data_from_filelist("zlib_pak_bundle_data") {
testonly = true
filelist_name = "test_data.filelist"
}
}
}

# This allows other users of Chromium's zlib library, but don't use Chromium's
Expand Down
32 changes: 32 additions & 0 deletions third_party/zlib/google/test_data.filelist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# NOTE: this file is generated by build/ios/update_bundle_filelist.py
# If it requires updating, you should get a presubmit error with
# instructions on how to regenerate. Otherwise, do not edit.
test/data/Different Encryptions.zip
test/data/Empty Dir Same Name As File.zip
test/data/Mixed Paths.zip
test/data/Parent Dir Same Name As File.zip
test/data/README.md
test/data/Repeated Dir Name.zip
test/data/Repeated File Name With Different Cases.zip
test/data/Repeated File Name.zip
test/data/SJIS Bug 846195.zip
test/data/Windows Special Names.zip
test/data/Wrong CRC.zip
test/data/create_test_zip.sh
test/data/empty.zip
test/data/evil.zip
test/data/evil_via_absolute_file_name.zip
test/data/evil_via_invalid_utf8.zip
test/data/test.zip
test/data/test/foo.txt
test/data/test/foo/bar.txt
test/data/test/foo/bar/.hidden
test/data/test/foo/bar/baz.txt
test/data/test/foo/bar/quux.txt
test/data/test_encrypted.zip
test/data/test_mismatch_size.zip
test/data/test_nocompress.zip
test/data/test_posix_permissions.zip
8 changes: 8 additions & 0 deletions third_party/zlib/google/test_data.globlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# See build/ios/update_bundle_filelist.py for details on how .globlist
# files are used to update their .filelist counterparts.
test/data/**
test/data/test/foo/bar/.hidden
8 changes: 4 additions & 4 deletions third_party/zlib/google/zip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ TEST_F(ZipTest, UnzipWindowsSpecialNames) {
"NUL .txt",
"NUL .txt",
"NUL ..txt",
#ifndef OS_MAC
#ifndef OS_APPLE
"Nul.txt",
#endif
"nul.very long extension",
Expand Down Expand Up @@ -669,7 +669,7 @@ TEST_F(ZipTest, UnzipWindowsSpecialNames) {
}

TEST_F(ZipTest, UnzipDifferentCases) {
#if defined(OS_WIN) || defined(OS_MAC)
#if defined(OS_WIN) || defined(OS_APPLE)
// Only the first file (with mixed case) is extracted.
EXPECT_FALSE(zip::Unzip(GetDataDirectory().AppendASCII(
"Repeated File Name With Different Cases.zip"),
Expand Down Expand Up @@ -711,7 +711,7 @@ TEST_F(ZipTest, UnzipDifferentCasesContinueOnError) {

std::string contents;

#if defined(OS_WIN) || defined(OS_MAC)
#if defined(OS_WIN) || defined(OS_APPLE)
// Only the first file (with mixed case) has been extracted.
EXPECT_THAT(
GetRelativePaths(test_dir_, base::FileEnumerator::FileType::FILES),
Expand Down Expand Up @@ -782,7 +782,7 @@ TEST_F(ZipTest, UnzipMixedPaths) {
"Space→ ", //
"c/NUL", // Disappears on Windows
"nul.very long extension", // Disappears on Windows
#ifndef OS_MAC
#ifndef OS_APPLE
"CASE", // Conflicts with "Case"
"case", // Conflicts with "Case"
#endif
Expand Down

0 comments on commit d618ef5

Please sign in to comment.