xref: /aosp_15_r20/build/bazel/tests/apex/apex_compression_test.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2022 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15def apex_compression_test(name, apex, compressed):
16    """This verifies APEX or compressed APEX file:
17        1) has the correct file extension name
18        2) contains the required files specified by the APEX file format
19    """
20
21    native.sh_library(
22        name = name + "_wrapper_sh_lib",
23        data = [apex],
24    )
25
26    args = ["$(location " + apex + ")"]
27    if compressed:
28        args.append("compressed")
29
30    native.sh_test(
31        name = name,
32        srcs = ["apex_compression_test.sh"],
33        deps = ["@bazel_tools//tools/bash/runfiles"],
34        data = [
35            ":" + name + "_wrapper_sh_lib",
36            "@bazel_tools//tools/zip:zipper",
37            apex,
38        ],
39        args = args,
40        target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"],
41    )
42