blob: b0a2966b305a2f3b312ce352810dd0c3a57c25ab [file] [log] [blame]
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04001// Copyright 2021 Google Inc. All rights reserved.
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
15package bp2build
16
17import (
18 "android/soong/android"
19 "android/soong/apex"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040020 "android/soong/cc"
Jingwen Chendf165c92022-06-08 16:00:39 +000021 "android/soong/etc"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040022 "android/soong/java"
Jingwen Chenb07c9012021-12-08 10:05:45 +000023 "android/soong/sh"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040024
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040025 "testing"
26)
27
Sam Delmerico3177a6e2022-06-21 19:28:33 +000028func runApexTestCase(t *testing.T, tc Bp2buildTestCase) {
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040029 t.Helper()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000030 RunBp2BuildTestCase(t, registerApexModuleTypes, tc)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040031}
32
33func registerApexModuleTypes(ctx android.RegistrationContext) {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040034 // CC module types needed as they can be APEX dependencies
35 cc.RegisterCCBuildComponents(ctx)
36
Jingwen Chenb07c9012021-12-08 10:05:45 +000037 ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
38 ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040039 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
40 ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
41 ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
42 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
Jingwen Chen81c67d32022-06-08 16:08:25 +000043 ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040044}
45
Sam Delmerico3177a6e2022-06-21 19:28:33 +000046func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) {
Wei Li1c66fc72022-05-09 23:59:14 -070047 t.Helper()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000048 RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc)
Wei Li1c66fc72022-05-09 23:59:14 -070049}
50
51func registerOverrideApexModuleTypes(ctx android.RegistrationContext) {
52 // CC module types needed as they can be APEX dependencies
53 cc.RegisterCCBuildComponents(ctx)
54
55 ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
56 ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
57 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
58 ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
59 ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
60 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
61 ctx.RegisterModuleType("apex", apex.BundleFactory)
Jingwen Chendf165c92022-06-08 16:00:39 +000062 ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
Wei Li1c66fc72022-05-09 23:59:14 -070063}
64
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040065func TestApexBundleSimple(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +000066 runApexTestCase(t, Bp2buildTestCase{
67 Description: "apex - example with all props, file_context is a module in same Android.bp",
68 ModuleTypeUnderTest: "apex",
69 ModuleTypeUnderTestFactory: apex.BundleFactory,
70 Filesystem: map[string]string{},
71 Blueprint: `
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040072apex_key {
Jingwen Chenb07c9012021-12-08 10:05:45 +000073 name: "com.android.apogee.key",
74 public_key: "com.android.apogee.avbpubkey",
75 private_key: "com.android.apogee.pem",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040076 bazel_module: { bp2build_available: false },
77}
78
79android_app_certificate {
Jingwen Chenb07c9012021-12-08 10:05:45 +000080 name: "com.android.apogee.certificate",
81 certificate: "com.android.apogee",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040082 bazel_module: { bp2build_available: false },
83}
84
85cc_library {
Jingwen Chenb07c9012021-12-08 10:05:45 +000086 name: "native_shared_lib_1",
87 bazel_module: { bp2build_available: false },
88}
89
90cc_library {
91 name: "native_shared_lib_2",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040092 bazel_module: { bp2build_available: false },
93}
94
Jingwen Chen81c67d32022-06-08 16:08:25 +000095prebuilt_etc {
96 name: "prebuilt_1",
Jingwen Chenb07c9012021-12-08 10:05:45 +000097 bazel_module: { bp2build_available: false },
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -040098}
99
Jingwen Chen81c67d32022-06-08 16:08:25 +0000100prebuilt_etc {
101 name: "prebuilt_2",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000102 bazel_module: { bp2build_available: false },
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400103}
104
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400105filegroup {
106 name: "com.android.apogee-file_contexts",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000107 srcs: [
Wei Li1c66fc72022-05-09 23:59:14 -0700108 "com.android.apogee-file_contexts",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000109 ],
110 bazel_module: { bp2build_available: false },
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400111}
112
Jingwen Chenb07c9012021-12-08 10:05:45 +0000113cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
114sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
115
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400116apex {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400117 name: "com.android.apogee",
118 manifest: "apogee_manifest.json",
119 androidManifest: "ApogeeAndroidManifest.xml",
Wei Li1c66fc72022-05-09 23:59:14 -0700120 file_contexts: ":com.android.apogee-file_contexts",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400121 min_sdk_version: "29",
122 key: "com.android.apogee.key",
123 certificate: "com.android.apogee.certificate",
124 updatable: false,
125 installable: false,
Wei Lif034cb42022-01-19 15:54:31 -0800126 compressible: false,
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400127 native_shared_libs: [
128 "native_shared_lib_1",
129 "native_shared_lib_2",
130 ],
131 binaries: [
Jingwen Chenb07c9012021-12-08 10:05:45 +0000132 "cc_binary_1",
133 "sh_binary_2",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400134 ],
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400135 prebuilts: [
Jingwen Chen81c67d32022-06-08 16:08:25 +0000136 "prebuilt_1",
137 "prebuilt_2",
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400138 ],
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000139 package_name: "com.android.apogee.test.package",
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000140 logging_parent: "logging.parent",
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400141}
142`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000143 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000144 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500145 "android_manifest": `"ApogeeAndroidManifest.xml"`,
146 "binaries": `[
Jingwen Chenb07c9012021-12-08 10:05:45 +0000147 ":cc_binary_1",
148 ":sh_binary_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500149 ]`,
150 "certificate": `":com.android.apogee.certificate"`,
151 "file_contexts": `":com.android.apogee-file_contexts"`,
152 "installable": "False",
153 "key": `":com.android.apogee.key"`,
154 "manifest": `"apogee_manifest.json"`,
155 "min_sdk_version": `"29"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800156 "native_shared_libs_32": `[
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400157 ":native_shared_lib_1",
158 ":native_shared_lib_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500159 ]`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800160 "native_shared_libs_64": `select({
161 "//build/bazel/platforms/arch:arm64": [
162 ":native_shared_lib_1",
163 ":native_shared_lib_2",
164 ],
165 "//build/bazel/platforms/arch:x86_64": [
166 ":native_shared_lib_1",
167 ":native_shared_lib_2",
168 ],
169 "//conditions:default": [],
170 })`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500171 "prebuilts": `[
Jingwen Chen81c67d32022-06-08 16:08:25 +0000172 ":prebuilt_1",
173 ":prebuilt_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500174 ]`,
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000175 "updatable": "False",
176 "compressible": "False",
177 "package_name": `"com.android.apogee.test.package"`,
178 "logging_parent": `"logging.parent"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500179 }),
180 }})
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400181}
182
Wei Li1c66fc72022-05-09 23:59:14 -0700183func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000184 runApexTestCase(t, Bp2buildTestCase{
185 Description: "apex - file contexts is a module in another Android.bp",
186 ModuleTypeUnderTest: "apex",
187 ModuleTypeUnderTestFactory: apex.BundleFactory,
188 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700189 "a/b/Android.bp": `
190filegroup {
191 name: "com.android.apogee-file_contexts",
192 srcs: [
193 "com.android.apogee-file_contexts",
194 ],
195 bazel_module: { bp2build_available: false },
196}
197`,
198 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000199 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700200apex {
201 name: "com.android.apogee",
202 file_contexts: ":com.android.apogee-file_contexts",
203}
204`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000205 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000206 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700207 "file_contexts": `"//a/b:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700208 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700209 }),
210 }})
211}
212
213func TestApexBundleSimple_fileContextsIsFile(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000214 runApexTestCase(t, Bp2buildTestCase{
215 Description: "apex - file contexts is a file",
216 ModuleTypeUnderTest: "apex",
217 ModuleTypeUnderTestFactory: apex.BundleFactory,
218 Filesystem: map[string]string{},
219 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700220apex {
221 name: "com.android.apogee",
222 file_contexts: "file_contexts_file",
223}
224`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000225 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000226 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700227 "file_contexts": `"file_contexts_file"`,
Wei Li40f98732022-05-20 22:08:11 -0700228 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700229 }),
230 }})
231}
232
233func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000234 runApexTestCase(t, Bp2buildTestCase{
235 Description: "apex - file contexts is not specified",
236 ModuleTypeUnderTest: "apex",
237 ModuleTypeUnderTestFactory: apex.BundleFactory,
238 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700239 "system/sepolicy/apex/Android.bp": `
240filegroup {
241 name: "com.android.apogee-file_contexts",
242 srcs: [
243 "com.android.apogee-file_contexts",
244 ],
245 bazel_module: { bp2build_available: false },
246}
247`,
248 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000249 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700250apex {
251 name: "com.android.apogee",
252}
253`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000254 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000255 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700256 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700257 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700258 }),
259 }})
260}
261
Yu Liu4ae55d12022-01-05 17:17:23 -0800262func TestApexBundleCompileMultilibBoth(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000263 runApexTestCase(t, Bp2buildTestCase{
264 Description: "apex - example with compile_multilib=both",
265 ModuleTypeUnderTest: "apex",
266 ModuleTypeUnderTestFactory: apex.BundleFactory,
267 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700268 "system/sepolicy/apex/Android.bp": `
269filegroup {
270 name: "com.android.apogee-file_contexts",
271 srcs: [ "apogee-file_contexts", ],
272 bazel_module: { bp2build_available: false },
273}
274`,
275 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000276 Blueprint: createMultilibBlueprint("both"),
277 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000278 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800279 "native_shared_libs_32": `[
280 ":native_shared_lib_1",
281 ":native_shared_lib_3",
282 ] + select({
283 "//build/bazel/platforms/arch:arm": [":native_shared_lib_2"],
284 "//build/bazel/platforms/arch:x86": [":native_shared_lib_2"],
285 "//conditions:default": [],
286 })`,
287 "native_shared_libs_64": `select({
288 "//build/bazel/platforms/arch:arm64": [
289 ":native_shared_lib_1",
290 ":native_shared_lib_4",
291 ":native_shared_lib_2",
292 ],
293 "//build/bazel/platforms/arch:x86_64": [
294 ":native_shared_lib_1",
295 ":native_shared_lib_4",
296 ":native_shared_lib_2",
297 ],
298 "//conditions:default": [],
299 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700300 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700301 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800302 }),
303 }})
304}
305
306func TestApexBundleCompileMultilibFirst(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000307 runApexTestCase(t, Bp2buildTestCase{
308 Description: "apex - example with compile_multilib=first",
309 ModuleTypeUnderTest: "apex",
310 ModuleTypeUnderTestFactory: apex.BundleFactory,
311 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700312 "system/sepolicy/apex/Android.bp": `
313filegroup {
314 name: "com.android.apogee-file_contexts",
315 srcs: [ "apogee-file_contexts", ],
316 bazel_module: { bp2build_available: false },
317}
318`,
319 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000320 Blueprint: createMultilibBlueprint("first"),
321 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000322 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800323 "native_shared_libs_32": `select({
324 "//build/bazel/platforms/arch:arm": [
325 ":native_shared_lib_1",
326 ":native_shared_lib_3",
327 ":native_shared_lib_2",
328 ],
329 "//build/bazel/platforms/arch:x86": [
330 ":native_shared_lib_1",
331 ":native_shared_lib_3",
332 ":native_shared_lib_2",
333 ],
334 "//conditions:default": [],
335 })`,
336 "native_shared_libs_64": `select({
337 "//build/bazel/platforms/arch:arm64": [
338 ":native_shared_lib_1",
339 ":native_shared_lib_4",
340 ":native_shared_lib_2",
341 ],
342 "//build/bazel/platforms/arch:x86_64": [
343 ":native_shared_lib_1",
344 ":native_shared_lib_4",
345 ":native_shared_lib_2",
346 ],
347 "//conditions:default": [],
348 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700349 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700350 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800351 }),
352 }})
353}
354
355func TestApexBundleCompileMultilib32(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000356 runApexTestCase(t, Bp2buildTestCase{
357 Description: "apex - example with compile_multilib=32",
358 ModuleTypeUnderTest: "apex",
359 ModuleTypeUnderTestFactory: apex.BundleFactory,
360 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700361 "system/sepolicy/apex/Android.bp": `
362filegroup {
363 name: "com.android.apogee-file_contexts",
364 srcs: [ "apogee-file_contexts", ],
365 bazel_module: { bp2build_available: false },
366}
367`,
368 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000369 Blueprint: createMultilibBlueprint("32"),
370 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000371 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800372 "native_shared_libs_32": `[
373 ":native_shared_lib_1",
374 ":native_shared_lib_3",
375 ] + select({
376 "//build/bazel/platforms/arch:arm": [":native_shared_lib_2"],
377 "//build/bazel/platforms/arch:x86": [":native_shared_lib_2"],
378 "//conditions:default": [],
379 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700380 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700381 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800382 }),
383 }})
384}
385
386func TestApexBundleCompileMultilib64(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000387 runApexTestCase(t, Bp2buildTestCase{
388 Description: "apex - example with compile_multilib=64",
389 ModuleTypeUnderTest: "apex",
390 ModuleTypeUnderTestFactory: apex.BundleFactory,
391 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700392 "system/sepolicy/apex/Android.bp": `
393filegroup {
394 name: "com.android.apogee-file_contexts",
395 srcs: [ "apogee-file_contexts", ],
396 bazel_module: { bp2build_available: false },
397}
398`,
399 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000400 Blueprint: createMultilibBlueprint("64"),
401 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000402 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800403 "native_shared_libs_64": `select({
404 "//build/bazel/platforms/arch:arm64": [
405 ":native_shared_lib_1",
406 ":native_shared_lib_4",
407 ":native_shared_lib_2",
408 ],
409 "//build/bazel/platforms/arch:x86_64": [
410 ":native_shared_lib_1",
411 ":native_shared_lib_4",
412 ":native_shared_lib_2",
413 ],
414 "//conditions:default": [],
415 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700416 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700417 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800418 }),
419 }})
420}
421
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400422func TestApexBundleDefaultPropertyValues(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000423 runApexTestCase(t, Bp2buildTestCase{
424 Description: "apex - default property values",
425 ModuleTypeUnderTest: "apex",
426 ModuleTypeUnderTestFactory: apex.BundleFactory,
427 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700428 "system/sepolicy/apex/Android.bp": `
429filegroup {
430 name: "com.android.apogee-file_contexts",
431 srcs: [ "apogee-file_contexts", ],
432 bazel_module: { bp2build_available: false },
433}
434`,
435 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000436 Blueprint: `
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400437apex {
438 name: "com.android.apogee",
439 manifest: "apogee_manifest.json",
440}
441`,
Alixe06d75b2022-08-31 18:28:19 +0000442 ExpectedBazelTargets: []string{MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700443 "manifest": `"apogee_manifest.json"`,
444 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500445 }),
446 }})
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400447}
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000448
449func TestApexBundleHasBazelModuleProps(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000450 runApexTestCase(t, Bp2buildTestCase{
451 Description: "apex - has bazel module props",
452 ModuleTypeUnderTest: "apex",
453 ModuleTypeUnderTestFactory: apex.BundleFactory,
454 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700455 "system/sepolicy/apex/Android.bp": `
456filegroup {
457 name: "apogee-file_contexts",
458 srcs: [ "apogee-file_contexts", ],
459 bazel_module: { bp2build_available: false },
460}
461`,
462 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000463 Blueprint: `
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000464apex {
465 name: "apogee",
466 manifest: "manifest.json",
467 bazel_module: { bp2build_available: true },
468}
469`,
Alixe06d75b2022-08-31 18:28:19 +0000470 ExpectedBazelTargets: []string{MakeBazelTarget("apex", "apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700471 "manifest": `"manifest.json"`,
472 "file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500473 }),
474 }})
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000475}
Yu Liu4ae55d12022-01-05 17:17:23 -0800476
477func createMultilibBlueprint(compile_multilib string) string {
478 return `
479cc_library {
480 name: "native_shared_lib_1",
481 bazel_module: { bp2build_available: false },
482}
483
484cc_library {
485 name: "native_shared_lib_2",
486 bazel_module: { bp2build_available: false },
487}
488
489cc_library {
490 name: "native_shared_lib_3",
491 bazel_module: { bp2build_available: false },
492}
493
494cc_library {
495 name: "native_shared_lib_4",
496 bazel_module: { bp2build_available: false },
497}
498
499apex {
500 name: "com.android.apogee",
501 compile_multilib: "` + compile_multilib + `",
502 multilib: {
503 both: {
504 native_shared_libs: [
505 "native_shared_lib_1",
506 ],
507 },
508 first: {
509 native_shared_libs: [
510 "native_shared_lib_2",
511 ],
512 },
513 lib32: {
514 native_shared_libs: [
515 "native_shared_lib_3",
516 ],
517 },
518 lib64: {
519 native_shared_libs: [
520 "native_shared_lib_4",
521 ],
522 },
523 },
524}`
525}
Wei Li1c66fc72022-05-09 23:59:14 -0700526
527func TestBp2BuildOverrideApex(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000528 runOverrideApexTestCase(t, Bp2buildTestCase{
529 Description: "override_apex",
530 ModuleTypeUnderTest: "override_apex",
531 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
532 Filesystem: map[string]string{},
533 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700534apex_key {
535 name: "com.android.apogee.key",
536 public_key: "com.android.apogee.avbpubkey",
537 private_key: "com.android.apogee.pem",
538 bazel_module: { bp2build_available: false },
539}
540
541android_app_certificate {
542 name: "com.android.apogee.certificate",
543 certificate: "com.android.apogee",
544 bazel_module: { bp2build_available: false },
545}
546
547cc_library {
548 name: "native_shared_lib_1",
549 bazel_module: { bp2build_available: false },
550}
551
552cc_library {
553 name: "native_shared_lib_2",
554 bazel_module: { bp2build_available: false },
555}
556
Jingwen Chen81c67d32022-06-08 16:08:25 +0000557prebuilt_etc {
558 name: "prebuilt_1",
Wei Li1c66fc72022-05-09 23:59:14 -0700559 bazel_module: { bp2build_available: false },
560}
561
Jingwen Chen81c67d32022-06-08 16:08:25 +0000562prebuilt_etc {
563 name: "prebuilt_2",
Wei Li1c66fc72022-05-09 23:59:14 -0700564 bazel_module: { bp2build_available: false },
565}
566
567filegroup {
568 name: "com.android.apogee-file_contexts",
569 srcs: [
570 "com.android.apogee-file_contexts",
571 ],
572 bazel_module: { bp2build_available: false },
573}
574
575cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
576sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
577
578apex {
579 name: "com.android.apogee",
580 manifest: "apogee_manifest.json",
581 androidManifest: "ApogeeAndroidManifest.xml",
582 file_contexts: ":com.android.apogee-file_contexts",
583 min_sdk_version: "29",
584 key: "com.android.apogee.key",
585 certificate: "com.android.apogee.certificate",
586 updatable: false,
587 installable: false,
588 compressible: false,
589 native_shared_libs: [
590 "native_shared_lib_1",
591 "native_shared_lib_2",
592 ],
593 binaries: [
594 "cc_binary_1",
595 "sh_binary_2",
596 ],
597 prebuilts: [
Jingwen Chen81c67d32022-06-08 16:08:25 +0000598 "prebuilt_1",
599 "prebuilt_2",
Wei Li1c66fc72022-05-09 23:59:14 -0700600 ],
601 bazel_module: { bp2build_available: false },
602}
603
604apex_key {
605 name: "com.google.android.apogee.key",
606 public_key: "com.google.android.apogee.avbpubkey",
607 private_key: "com.google.android.apogee.pem",
608 bazel_module: { bp2build_available: false },
609}
610
611android_app_certificate {
612 name: "com.google.android.apogee.certificate",
613 certificate: "com.google.android.apogee",
614 bazel_module: { bp2build_available: false },
615}
616
617override_apex {
618 name: "com.google.android.apogee",
619 base: ":com.android.apogee",
620 key: "com.google.android.apogee.key",
621 certificate: "com.google.android.apogee.certificate",
622 prebuilts: [],
623 compressible: true,
624}
625`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000626 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000627 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700628 "android_manifest": `"ApogeeAndroidManifest.xml"`,
629 "binaries": `[
630 ":cc_binary_1",
631 ":sh_binary_2",
632 ]`,
633 "certificate": `":com.google.android.apogee.certificate"`,
634 "file_contexts": `":com.android.apogee-file_contexts"`,
635 "installable": "False",
636 "key": `":com.google.android.apogee.key"`,
637 "manifest": `"apogee_manifest.json"`,
638 "min_sdk_version": `"29"`,
639 "native_shared_libs_32": `[
640 ":native_shared_lib_1",
641 ":native_shared_lib_2",
642 ]`,
643 "native_shared_libs_64": `select({
644 "//build/bazel/platforms/arch:arm64": [
645 ":native_shared_lib_1",
646 ":native_shared_lib_2",
647 ],
648 "//build/bazel/platforms/arch:x86_64": [
649 ":native_shared_lib_1",
650 ":native_shared_lib_2",
651 ],
652 "//conditions:default": [],
653 })`,
654 "prebuilts": `[]`,
655 "updatable": "False",
656 "compressible": "True",
657 }),
658 }})
659}
Wei Li40f98732022-05-20 22:08:11 -0700660
661func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000662 runOverrideApexTestCase(t, Bp2buildTestCase{
663 Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
664 ModuleTypeUnderTest: "override_apex",
665 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
666 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700667 "system/sepolicy/apex/Android.bp": `
668filegroup {
669 name: "com.android.apogee-file_contexts",
670 srcs: [ "apogee-file_contexts", ],
671 bazel_module: { bp2build_available: false },
672}`,
673 "a/b/Android.bp": `
674apex {
675 name: "com.android.apogee",
676 bazel_module: { bp2build_available: false },
677}
678`,
679 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000680 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700681override_apex {
682 name: "com.google.android.apogee",
683 base: ":com.android.apogee",
684}
685`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000686 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000687 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li40f98732022-05-20 22:08:11 -0700688 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
689 "manifest": `"//a/b:apex_manifest.json"`,
690 }),
691 }})
692}
693
694func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000695 runOverrideApexTestCase(t, Bp2buildTestCase{
696 Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
697 ModuleTypeUnderTest: "override_apex",
698 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
699 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700700 "system/sepolicy/apex/Android.bp": `
701filegroup {
702 name: "com.android.apogee-file_contexts",
703 srcs: [ "apogee-file_contexts", ],
704 bazel_module: { bp2build_available: false },
705}`,
706 "a/b/Android.bp": `
707apex {
708 name: "com.android.apogee",
709 manifest: "apogee_manifest.json",
710 bazel_module: { bp2build_available: false },
711}
712`,
713 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000714 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700715override_apex {
716 name: "com.google.android.apogee",
717 base: ":com.android.apogee",
718}
719`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000720 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000721 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li40f98732022-05-20 22:08:11 -0700722 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
723 "manifest": `"//a/b:apogee_manifest.json"`,
724 }),
725 }})
726}
727
728func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000729 runOverrideApexTestCase(t, Bp2buildTestCase{
730 Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
731 ModuleTypeUnderTest: "override_apex",
732 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
733 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700734 "system/sepolicy/apex/Android.bp": `
735filegroup {
736 name: "com.android.apogee-file_contexts",
737 srcs: [ "apogee-file_contexts", ],
738 bazel_module: { bp2build_available: false },
739}`,
740 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000741 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700742apex {
743 name: "com.android.apogee",
744 bazel_module: { bp2build_available: false },
745}
746
747override_apex {
748 name: "com.google.android.apogee",
749 base: ":com.android.apogee",
750}
751`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000752 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000753 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li40f98732022-05-20 22:08:11 -0700754 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
755 "manifest": `"apex_manifest.json"`,
756 }),
757 }})
758}
759
760func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000761 runOverrideApexTestCase(t, Bp2buildTestCase{
762 Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
763 ModuleTypeUnderTest: "override_apex",
764 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
765 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700766 "system/sepolicy/apex/Android.bp": `
767filegroup {
768 name: "com.android.apogee-file_contexts",
769 srcs: [ "apogee-file_contexts", ],
770 bazel_module: { bp2build_available: false },
771}`,
772 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000773 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700774apex {
775 name: "com.android.apogee",
776 manifest: "apogee_manifest.json",
777 bazel_module: { bp2build_available: false },
778}
779
780override_apex {
781 name: "com.google.android.apogee",
782 base: ":com.android.apogee",
783}
784`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000785 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000786 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li40f98732022-05-20 22:08:11 -0700787 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
788 "manifest": `"apogee_manifest.json"`,
789 }),
790 }})
791}
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000792
793func TestApexBundleSimple_packageNameOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000794 runOverrideApexTestCase(t, Bp2buildTestCase{
795 Description: "override_apex - override package name",
796 ModuleTypeUnderTest: "override_apex",
797 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
798 Filesystem: map[string]string{
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000799 "system/sepolicy/apex/Android.bp": `
800filegroup {
801 name: "com.android.apogee-file_contexts",
802 srcs: [ "apogee-file_contexts", ],
803 bazel_module: { bp2build_available: false },
804}`,
805 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000806 Blueprint: `
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000807apex {
808 name: "com.android.apogee",
809 bazel_module: { bp2build_available: false },
810}
811
812override_apex {
813 name: "com.google.android.apogee",
814 base: ":com.android.apogee",
815 package_name: "com.google.android.apogee",
816}
817`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000818 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000819 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000820 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
821 "manifest": `"apex_manifest.json"`,
822 "package_name": `"com.google.android.apogee"`,
823 }),
824 }})
825}
Jingwen Chendf165c92022-06-08 16:00:39 +0000826
827func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000828 runOverrideApexTestCase(t, Bp2buildTestCase{
829 Description: "override_apex - no override",
830 ModuleTypeUnderTest: "override_apex",
831 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
832 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000833 "system/sepolicy/apex/Android.bp": `
834filegroup {
835 name: "com.android.apogee-file_contexts",
836 srcs: [ "apogee-file_contexts", ],
837 bazel_module: { bp2build_available: false },
838}`,
839 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000840 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000841prebuilt_etc {
842 name: "prebuilt_file",
843 bazel_module: { bp2build_available: false },
844}
845
846apex {
847 name: "com.android.apogee",
848 bazel_module: { bp2build_available: false },
849 prebuilts: ["prebuilt_file"]
850}
851
852override_apex {
853 name: "com.google.android.apogee",
854 base: ":com.android.apogee",
855}
856`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000857 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000858 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chendf165c92022-06-08 16:00:39 +0000859 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
860 "manifest": `"apex_manifest.json"`,
861 "prebuilts": `[":prebuilt_file"]`,
862 }),
863 }})
864}
865
866func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000867 runOverrideApexTestCase(t, Bp2buildTestCase{
868 Description: "override_apex - ooverride",
869 ModuleTypeUnderTest: "override_apex",
870 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
871 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000872 "system/sepolicy/apex/Android.bp": `
873filegroup {
874 name: "com.android.apogee-file_contexts",
875 srcs: [ "apogee-file_contexts", ],
876 bazel_module: { bp2build_available: false },
877}`,
878 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000879 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000880prebuilt_etc {
881 name: "prebuilt_file",
882 bazel_module: { bp2build_available: false },
883}
884
885prebuilt_etc {
886 name: "prebuilt_file2",
887 bazel_module: { bp2build_available: false },
888}
889
890apex {
891 name: "com.android.apogee",
892 bazel_module: { bp2build_available: false },
893 prebuilts: ["prebuilt_file"]
894}
895
896override_apex {
897 name: "com.google.android.apogee",
898 base: ":com.android.apogee",
899 prebuilts: ["prebuilt_file2"]
900}
901`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000902 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000903 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chendf165c92022-06-08 16:00:39 +0000904 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
905 "manifest": `"apex_manifest.json"`,
906 "prebuilts": `[":prebuilt_file2"]`,
907 }),
908 }})
909}
910
911func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000912 runOverrideApexTestCase(t, Bp2buildTestCase{
913 Description: "override_apex - override with empty list",
914 ModuleTypeUnderTest: "override_apex",
915 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
916 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000917 "system/sepolicy/apex/Android.bp": `
918filegroup {
919 name: "com.android.apogee-file_contexts",
920 srcs: [ "apogee-file_contexts", ],
921 bazel_module: { bp2build_available: false },
922}`,
923 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000924 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000925prebuilt_etc {
926 name: "prebuilt_file",
927 bazel_module: { bp2build_available: false },
928}
929
930apex {
931 name: "com.android.apogee",
932 bazel_module: { bp2build_available: false },
933 prebuilts: ["prebuilt_file"]
934}
935
936override_apex {
937 name: "com.google.android.apogee",
938 base: ":com.android.apogee",
939 prebuilts: [],
940}
941`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000942 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000943 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chendf165c92022-06-08 16:00:39 +0000944 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
945 "manifest": `"apex_manifest.json"`,
946 "prebuilts": `[]`,
947 }),
948 }})
949}
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000950
951func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000952 runOverrideApexTestCase(t, Bp2buildTestCase{
953 Description: "override_apex - logging_parent - no override",
954 ModuleTypeUnderTest: "override_apex",
955 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
956 Filesystem: map[string]string{
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000957 "system/sepolicy/apex/Android.bp": `
958filegroup {
959 name: "com.android.apogee-file_contexts",
960 srcs: [ "apogee-file_contexts", ],
961 bazel_module: { bp2build_available: false },
962}`,
963 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000964 Blueprint: `
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000965apex {
966 name: "com.android.apogee",
967 bazel_module: { bp2build_available: false },
968 logging_parent: "foo.bar.baz",
969}
970
971override_apex {
972 name: "com.google.android.apogee",
973 base: ":com.android.apogee",
974}
975`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000976 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000977 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000978 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
979 "manifest": `"apex_manifest.json"`,
980 "logging_parent": `"foo.bar.baz"`,
981 }),
982 }})
983}
984
985func TestApexBundleSimple_LoggingParentOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000986 runOverrideApexTestCase(t, Bp2buildTestCase{
987 Description: "override_apex - logging_parent - override",
988 ModuleTypeUnderTest: "override_apex",
989 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
990 Filesystem: map[string]string{
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000991 "system/sepolicy/apex/Android.bp": `
992filegroup {
993 name: "com.android.apogee-file_contexts",
994 srcs: [ "apogee-file_contexts", ],
995 bazel_module: { bp2build_available: false },
996}`,
997 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000998 Blueprint: `
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000999apex {
1000 name: "com.android.apogee",
1001 bazel_module: { bp2build_available: false },
1002 logging_parent: "foo.bar.baz",
1003}
1004
1005override_apex {
1006 name: "com.google.android.apogee",
1007 base: ":com.android.apogee",
1008 logging_parent: "foo.bar.baz.override",
1009}
1010`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001011 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +00001012 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001013 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
1014 "manifest": `"apex_manifest.json"`,
1015 "logging_parent": `"foo.bar.baz.override"`,
1016 }),
1017 }})
1018}