Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b1ac362 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Migrate platform/system/core/libziparchive to p/system/libziparchive"

parents bd05d33c db6e6038
Loading
Loading
Loading
Loading

libziparchive/.clang-format

deleted120000 → 0
+0 −1
Original line number Diff line number Diff line
../.clang-format-2
 No newline at end of file

libziparchive/Android.bp

deleted100644 → 0
+0 −237
Original line number Diff line number Diff line
//
// Copyright (C) 2013 The Android Open Source Project
//
// 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.

cc_defaults {
    name: "libziparchive_flags",
    cflags: [
        // ZLIB_CONST turns on const for input buffers, which is pretty standard.
        "-DZLIB_CONST",
        "-Werror",
        "-Wall",
        "-D_FILE_OFFSET_BITS=64",
    ],
    cppflags: [
        // Incorrectly warns when C++11 empty brace {} initializer is used.
        // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489
        "-Wno-missing-field-initializers",
        "-Wconversion",
        "-Wno-sign-conversion",
    ],

    // Enable -Wold-style-cast only for non-Windows targets.  _islower_l,
    // _isupper_l etc. in MinGW locale_win32.h (included from
    // libcxx/include/__locale) has an old-style-cast.
    target: {
        not_windows: {
            cppflags: [
                "-Wold-style-cast",
            ],
        },
    },
    sanitize: {
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
            "shift",
            "integer-divide-by-zero",
            "implicit-signed-integer-truncation",
            // TODO: Fix crash when we enable this option
            // "implicit-unsigned-integer-truncation",
            // TODO: not tested yet.
            // "implicit-integer-sign-change",
        ],
    },
}

cc_defaults {
    name: "libziparchive_defaults",
    srcs: [
        "zip_archive.cc",
        "zip_archive_stream_entry.cc",
        "zip_cd_entry_map.cc",
        "zip_error.cpp",
        "zip_writer.cc",
    ],

    target: {
        windows: {
            cflags: ["-mno-ms-bitfields"],

            enabled: true,
        },
    },

    shared_libs: [
        "libbase",
        "liblog",
    ],

    // for FRIEND_TEST
    static_libs: ["libgtest_prod"],
    export_static_lib_headers: ["libgtest_prod"],

    export_include_dirs: ["include"],
}

cc_library {
    name: "libziparchive",
    host_supported: true,
    vendor_available: true,
    recovery_available: true,
    native_bridge_supported: true,
    vndk: {
        enabled: true,
    },
    double_loadable: true,
    export_shared_lib_headers: ["libbase"],

    defaults: [
        "libziparchive_defaults",
        "libziparchive_flags",
    ],
    shared_libs: [
        "liblog",
        "libbase",
        "libz",
    ],
    target: {
        linux_bionic: {
            enabled: true,
        },
    },

    apex_available: [
        "//apex_available:platform",
        "com.android.art.debug",
        "com.android.art.release",
    ],
}

// Tests.
cc_test {
    name: "ziparchive-tests",
    host_supported: true,
    defaults: ["libziparchive_flags"],

    data: [
        "testdata/**/*",
    ],

    srcs: [
        "entry_name_utils_test.cc",
        "zip_archive_test.cc",
        "zip_writer_test.cc",
    ],
    shared_libs: [
        "libbase",
        "liblog",
    ],

    static_libs: [
        "libziparchive",
        "libz",
        "libutils",
    ],

    target: {
        host: {
            cppflags: ["-Wno-unnamed-type-template-args"],
        },
        windows: {
            enabled: true,
        },
    },
    test_suites: ["device-tests"],
}

// Performance benchmarks.
cc_benchmark {
    name: "ziparchive-benchmarks",
    defaults: ["libziparchive_flags"],

    srcs: [
        "zip_archive_benchmark.cpp",
    ],
    shared_libs: [
        "libbase",
        "liblog",
    ],

    static_libs: [
        "libziparchive",
        "libz",
        "libutils",
    ],

    target: {
        host: {
            cppflags: ["-Wno-unnamed-type-template-args"],
        },
    },
}

cc_binary {
    name: "ziptool",
    defaults: ["libziparchive_flags"],
    srcs: ["ziptool.cpp"],
    shared_libs: [
        "libbase",
        "libziparchive",
    ],
    recovery_available: true,
    host_supported: true,
    target: {
        android: {
            symlinks: ["unzip", "zipinfo"],
        },
    },
}

cc_fuzz {
    name: "libziparchive_fuzzer",
    srcs: ["libziparchive_fuzzer.cpp"],
    static_libs: ["libziparchive", "libbase", "libz", "liblog"],
    host_supported: true,
    corpus: ["testdata/*"],
}

sh_test {
    name: "ziptool-tests",
    src: "run-ziptool-tests-on-android.sh",
    filename: "run-ziptool-tests-on-android.sh",
    test_suites: ["general-tests"],
    host_supported: true,
    device_supported: false,
    test_config: "ziptool-tests.xml",
    data: ["cli-tests/**/*"],
    target_required: ["cli-test", "ziptool"],
}

python_test_host {
    name: "ziparchive_tests_large",
    srcs: ["test_ziparchive_large.py"],
    main: "test_ziparchive_large.py",
    version: {
        py2: {
            enabled: true,
            embedded_launcher: false,
        },
        py3: {
            enabled: false,
            embedded_launcher: false,
        },
    },
    test_suites: ["general-tests"],
}

libziparchive/OWNERS

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
narayan@google.com
−1.06 KiB

File deleted.

+0 −148
Original line number Diff line number Diff line
# unzip tests.

# Note: since "master key", Android uses libziparchive for all zip file
# handling, and that scans the whole central directory immediately. Not only
# lookups by name but also iteration is implemented using the resulting hash
# table, meaning that any test that makes assumptions about iteration order
# will fail on Android.

name: unzip -l
command: unzip -l $FILES/example.zip d1/d2/x.txt
after: [ ! -f d1/d2/x.txt ]
expected-stdout:
	Archive:  $FILES/example.zip
	  Length      Date    Time    Name
	---------  ---------- -----   ----
	     1024  2017-06-04 08:45   d1/d2/x.txt
	---------                     -------
	     1024                     1 file
---

name: unzip -lq
command: unzip -lq $FILES/example.zip d1/d2/x.txt
after: [ ! -f d1/d2/x.txt ]
expected-stdout:
	  Length      Date    Time    Name
	---------  ---------- -----   ----
	     1024  2017-06-04 08:45   d1/d2/x.txt
	---------                     -------
	     1024                     1 file
---

name: unzip -lv
command: unzip -lv $FILES/example.zip d1/d2/x.txt
after: [ ! -f d1/d2/file ]
expected-stdout:
	Archive:  $FILES/example.zip
	 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
	--------  ------  ------- ---- ---------- ----- --------  ----
	    1024  Defl:N       11  99% 2017-06-04 08:45 48d7f063  d1/d2/x.txt
	--------          -------  ---                            -------
	    1024               11  99%                            1 file
---

name: unzip -v
command: unzip -v $FILES/example.zip d1/d2/x.txt
after: [ ! -f d1/d2/file ]
expected-stdout:
	Archive:  $FILES/example.zip
	 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
	--------  ------  ------- ---- ---------- ----- --------  ----
	    1024  Defl:N       11  99% 2017-06-04 08:45 48d7f063  d1/d2/x.txt
	--------          -------  ---                            -------
	    1024               11  99%                            1 file
---

name: unzip one file
command: unzip -q $FILES/example.zip d1/d2/a.txt && cat d1/d2/a.txt
after: [ ! -f d1/d2/b.txt ]
expected-stdout:
	a
---

name: unzip all files
command: unzip -q $FILES/example.zip
after: [ -f d1/d2/a.txt ]
after: [ -f d1/d2/b.txt ]
after: [ -f d1/d2/c.txt ]
after: [ -f d1/d2/empty.txt ]
after: [ -f d1/d2/x.txt ]
after: [ -d d1/d2/dir ]
expected-stdout:
---

name: unzip -o
before: mkdir -p d1/d2
before: echo b > d1/d2/a.txt
command: unzip -q -o $FILES/example.zip d1/d2/a.txt && cat d1/d2/a.txt
expected-stdout:
	a
---

name: unzip -n
before: mkdir -p d1/d2
before: echo b > d1/d2/a.txt
command: unzip -q -n $FILES/example.zip d1/d2/a.txt && cat d1/d2/a.txt
expected-stdout:
	b
---

# The reference implementation will create *one* level of missing directories,
# so this succeeds.
name: unzip -d shallow non-existent
command: unzip -q -d will-be-created $FILES/example.zip d1/d2/a.txt
after: [ -d will-be-created ]
after: [ -f will-be-created/d1/d2/a.txt ]
---

# The reference implementation will *only* create one level of missing
# directories, so this fails.
name: unzip -d deep non-existent
command: unzip -q -d oh-no/will-not-be-created $FILES/example.zip d1/d2/a.txt 2> stderr ; echo $? > status
after: [ ! -d oh-no ]
after: [ ! -d oh-no/will-not-be-created ]
after: [ ! -f oh-no/will-not-be-created/d1/d2/a.txt ]
after: grep -q "oh-no/will-not-be-created" stderr
after: grep -q "No such file or directory" stderr
# The reference implementation has *lots* of non-zero exit values, but we stick to 0 and 1.
after: [ $(cat status) -gt 0 ]
---

name: unzip -d exists
before: mkdir dir
command: unzip -q -d dir $FILES/example.zip d1/d2/a.txt && cat dir/d1/d2/a.txt
after: [ ! -f d1/d2/a.txt ]
expected-stdout:
	a
---

name: unzip -p
command: unzip -p $FILES/example.zip d1/d2/a.txt
after: [ ! -f d1/d2/a.txt ]
expected-stdout:
	a
---

name: unzip -x FILE...
# Note: the RI ignores -x DIR for some reason, but it's not obvious we should.
command: unzip -q $FILES/example.zip -x d1/d2/a.txt d1/d2/b.txt d1/d2/empty.txt d1/d2/x.txt && cat d1/d2/c.txt
after: [ ! -f d1/d2/a.txt ]
after: [ ! -f d1/d2/b.txt ]
after: [ ! -f d1/d2/empty.txt ]
after: [ ! -f d1/d2/x.txt ]
after: [ -d d1/d2/dir ]
expected-stdout:
	ccc
---

name: unzip FILE -x FILE...
command: unzip -q $FILES/example.zip d1/d2/a.txt d1/d2/b.txt -x d1/d2/a.txt && cat d1/d2/b.txt
after: [ ! -f d1/d2/a.txt ]
after: [ -f d1/d2/b.txt ]
after: [ ! -f d1/d2/c.txt ]
after: [ ! -f d1/d2/empty.txt ]
after: [ ! -f d1/d2/x.txt ]
after: [ ! -d d1/d2/dir ]
expected-stdout:
	bb
---
Loading