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. 14load("@bazel_skylib//rules:diff_test.bzl", "diff_test") 15 16def apex_package_name_test(name, apex, expected_package_name): 17 """Compare the actual package name of an apex using aapt2.""" 18 native.genrule( 19 name = name + "_actual_package_name", 20 tools = ["//frameworks/base/tools/aapt2"], 21 srcs = [apex], 22 outs = [name + "_actual_package_name.txt"], 23 cmd = "$(location //frameworks/base/tools/aapt2) dump packagename $< > $@", 24 tags = ["manual"], 25 ) 26 27 native.genrule( 28 name = name + "_expected_package_name", 29 outs = [name + "expected_package_name.txt"], 30 cmd = "echo " + expected_package_name + " > $@", 31 tags = ["manual"], 32 ) 33 34 diff_test( 35 name = name, 36 file1 = name + "_actual_package_name", 37 file2 = name + "_expected_package_name", 38 ) 39