Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 1 | // 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 | |
| 15 | package bp2build |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "android/soong/apex" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 20 | "android/soong/cc" |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 21 | "android/soong/etc" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 22 | "android/soong/java" |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 23 | "android/soong/sh" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 24 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 25 | "fmt" |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 26 | "testing" |
| 27 | ) |
| 28 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 29 | func runApexTestCase(t *testing.T, tc Bp2buildTestCase) { |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 30 | t.Helper() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 31 | RunBp2BuildTestCase(t, registerApexModuleTypes, tc) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | func registerApexModuleTypes(ctx android.RegistrationContext) { |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 35 | // CC module types needed as they can be APEX dependencies |
| 36 | cc.RegisterCCBuildComponents(ctx) |
| 37 | |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 38 | ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory) |
| 39 | ctx.RegisterModuleType("cc_binary", cc.BinaryFactory) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 40 | ctx.RegisterModuleType("cc_library", cc.LibraryFactory) |
| 41 | ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory) |
| 42 | ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory) |
| 43 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 44 | ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory) |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 45 | ctx.RegisterModuleType("cc_test", cc.TestFactory) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 48 | func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) { |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 49 | t.Helper() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 50 | RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | func registerOverrideApexModuleTypes(ctx android.RegistrationContext) { |
| 54 | // CC module types needed as they can be APEX dependencies |
| 55 | cc.RegisterCCBuildComponents(ctx) |
| 56 | |
| 57 | ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory) |
| 58 | ctx.RegisterModuleType("cc_binary", cc.BinaryFactory) |
| 59 | ctx.RegisterModuleType("cc_library", cc.LibraryFactory) |
| 60 | ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory) |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 61 | ctx.RegisterModuleType("apex_test", apex.TestApexBundleFactory) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 62 | ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory) |
| 63 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
| 64 | ctx.RegisterModuleType("apex", apex.BundleFactory) |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 65 | ctx.RegisterModuleType("apex_defaults", apex.DefaultsFactory) |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 66 | ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory) |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 67 | ctx.RegisterModuleType("soong_config_module_type", android.SoongConfigModuleTypeFactory) |
| 68 | ctx.RegisterModuleType("soong_config_string_variable", android.SoongConfigStringVariableDummyFactory) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 71 | func TestApexBundleSimple(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 72 | runApexTestCase(t, Bp2buildTestCase{ |
| 73 | Description: "apex - example with all props, file_context is a module in same Android.bp", |
| 74 | ModuleTypeUnderTest: "apex", |
| 75 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 76 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 77 | StubbedBuildDefinitions: []string{"com.android.apogee.key", "com.android.apogee.certificate", "native_shared_lib_1", "native_shared_lib_2", |
| 78 | "prebuilt_1", "prebuilt_2", "com.android.apogee-file_contexts", "cc_binary_1", "sh_binary_2"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 79 | Blueprint: ` |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 80 | apex_key { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 81 | name: "com.android.apogee.key", |
| 82 | public_key: "com.android.apogee.avbpubkey", |
| 83 | private_key: "com.android.apogee.pem", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | android_app_certificate { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 87 | name: "com.android.apogee.certificate", |
| 88 | certificate: "com.android.apogee", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | cc_library { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 92 | name: "native_shared_lib_1", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | cc_library { |
| 96 | name: "native_shared_lib_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 97 | } |
| 98 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 99 | prebuilt_etc { |
| 100 | name: "prebuilt_1", |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 101 | } |
| 102 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 103 | prebuilt_etc { |
| 104 | name: "prebuilt_2", |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 105 | } |
| 106 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 107 | filegroup { |
| 108 | name: "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 109 | srcs: [ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 110 | "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 111 | ], |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 112 | } |
| 113 | |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 114 | cc_binary { name: "cc_binary_1"} |
Chris Parsons | 0c4de1f | 2023-09-21 20:36:35 +0000 | [diff] [blame^] | 115 | sh_binary { name: "sh_binary_2", src: "foo.sh"} |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 116 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 117 | apex { |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 118 | name: "com.android.apogee", |
| 119 | manifest: "apogee_manifest.json", |
| 120 | androidManifest: "ApogeeAndroidManifest.xml", |
Sam Delmerico | e860d14 | 2023-06-06 15:47:30 -0400 | [diff] [blame] | 121 | apex_available_name: "apogee_apex_name", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 122 | file_contexts: ":com.android.apogee-file_contexts", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 123 | min_sdk_version: "29", |
| 124 | key: "com.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 125 | certificate: ":com.android.apogee.certificate", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 126 | updatable: false, |
| 127 | installable: false, |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 128 | compressible: false, |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 129 | native_shared_libs: [ |
| 130 | "native_shared_lib_1", |
| 131 | "native_shared_lib_2", |
| 132 | ], |
| 133 | binaries: [ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 134 | "cc_binary_1", |
| 135 | "sh_binary_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 136 | ], |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 137 | prebuilts: [ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 138 | "prebuilt_1", |
| 139 | "prebuilt_2", |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 140 | ], |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 141 | package_name: "com.android.apogee.test.package", |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 142 | logging_parent: "logging.parent", |
Sam Delmerico | e860d14 | 2023-06-06 15:47:30 -0400 | [diff] [blame] | 143 | variant_version: "3", |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 144 | } |
| 145 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 146 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 147 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Sam Delmerico | e860d14 | 2023-06-06 15:47:30 -0400 | [diff] [blame] | 148 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
| 149 | "apex_available_name": `"apogee_apex_name"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 150 | "binaries": `[ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 151 | ":cc_binary_1", |
| 152 | ":sh_binary_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 153 | ]`, |
| 154 | "certificate": `":com.android.apogee.certificate"`, |
| 155 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 156 | "installable": "False", |
| 157 | "key": `":com.android.apogee.key"`, |
| 158 | "manifest": `"apogee_manifest.json"`, |
| 159 | "min_sdk_version": `"29"`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 160 | "native_shared_libs_32": `select({ |
| 161 | "//build/bazel/platforms/arch:arm": [ |
| 162 | ":native_shared_lib_1", |
| 163 | ":native_shared_lib_2", |
| 164 | ], |
| 165 | "//build/bazel/platforms/arch:x86": [ |
| 166 | ":native_shared_lib_1", |
| 167 | ":native_shared_lib_2", |
| 168 | ], |
| 169 | "//conditions:default": [], |
| 170 | })`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 171 | "native_shared_libs_64": `select({ |
| 172 | "//build/bazel/platforms/arch:arm64": [ |
| 173 | ":native_shared_lib_1", |
| 174 | ":native_shared_lib_2", |
| 175 | ], |
| 176 | "//build/bazel/platforms/arch:x86_64": [ |
| 177 | ":native_shared_lib_1", |
| 178 | ":native_shared_lib_2", |
| 179 | ], |
| 180 | "//conditions:default": [], |
| 181 | })`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 182 | "prebuilts": `[ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 183 | ":prebuilt_1", |
| 184 | ":prebuilt_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 185 | ]`, |
Sam Delmerico | e860d14 | 2023-06-06 15:47:30 -0400 | [diff] [blame] | 186 | "updatable": "False", |
| 187 | "compressible": "False", |
| 188 | "package_name": `"com.android.apogee.test.package"`, |
| 189 | "logging_parent": `"logging.parent"`, |
| 190 | "variant_version": `"3"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 191 | }), |
| 192 | }}) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 193 | } |
| 194 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 195 | func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 196 | runApexTestCase(t, Bp2buildTestCase{ |
| 197 | Description: "apex - file contexts is a module in another Android.bp", |
| 198 | ModuleTypeUnderTest: "apex", |
| 199 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 200 | StubbedBuildDefinitions: []string{"//a/b:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 201 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 202 | "a/b/Android.bp": ` |
| 203 | filegroup { |
| 204 | name: "com.android.apogee-file_contexts", |
| 205 | srcs: [ |
| 206 | "com.android.apogee-file_contexts", |
| 207 | ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 208 | } |
| 209 | `, |
| 210 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 211 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 212 | apex { |
| 213 | name: "com.android.apogee", |
| 214 | file_contexts: ":com.android.apogee-file_contexts", |
| 215 | } |
| 216 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 217 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 218 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 219 | "file_contexts": `"//a/b:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 220 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 221 | }), |
| 222 | }}) |
| 223 | } |
| 224 | |
| 225 | func TestApexBundleSimple_fileContextsIsFile(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 226 | runApexTestCase(t, Bp2buildTestCase{ |
| 227 | Description: "apex - file contexts is a file", |
| 228 | ModuleTypeUnderTest: "apex", |
| 229 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 230 | Filesystem: map[string]string{}, |
| 231 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 232 | apex { |
| 233 | name: "com.android.apogee", |
| 234 | file_contexts: "file_contexts_file", |
| 235 | } |
| 236 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 237 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 238 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 239 | "file_contexts": `"file_contexts_file"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 240 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 241 | }), |
| 242 | }}) |
| 243 | } |
| 244 | |
| 245 | func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 246 | runApexTestCase(t, Bp2buildTestCase{ |
| 247 | Description: "apex - file contexts is not specified", |
| 248 | ModuleTypeUnderTest: "apex", |
| 249 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 250 | StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 251 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 252 | "system/sepolicy/apex/Android.bp": ` |
| 253 | filegroup { |
| 254 | name: "com.android.apogee-file_contexts", |
| 255 | srcs: [ |
| 256 | "com.android.apogee-file_contexts", |
| 257 | ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 258 | } |
| 259 | `, |
| 260 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 261 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 262 | apex { |
| 263 | name: "com.android.apogee", |
| 264 | } |
| 265 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 266 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 267 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 268 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 269 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 270 | }), |
| 271 | }}) |
| 272 | } |
| 273 | |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 274 | func TestApexBundleCompileMultilibBoth(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 275 | runApexTestCase(t, Bp2buildTestCase{ |
| 276 | Description: "apex - example with compile_multilib=both", |
| 277 | ModuleTypeUnderTest: "apex", |
| 278 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 279 | StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 280 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 281 | "system/sepolicy/apex/Android.bp": ` |
| 282 | filegroup { |
| 283 | name: "com.android.apogee-file_contexts", |
| 284 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 285 | } |
| 286 | `, |
| 287 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 288 | Blueprint: createMultilibBlueprint(`compile_multilib: "both",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 289 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 290 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 291 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 292 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 293 | ":native_shared_lib_for_both", |
| 294 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 295 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 296 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 297 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 298 | "//conditions:default": [], |
| 299 | })`, |
| 300 | "native_shared_libs_64": `select({ |
| 301 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 302 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 303 | ":native_shared_lib_for_both", |
| 304 | ":native_shared_lib_for_lib64", |
| 305 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 306 | ], |
| 307 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 308 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 309 | ":native_shared_lib_for_both", |
| 310 | ":native_shared_lib_for_lib64", |
| 311 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 312 | ], |
| 313 | "//conditions:default": [], |
| 314 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 315 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 316 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 317 | }), |
| 318 | }}) |
| 319 | } |
| 320 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 321 | func TestApexBundleCompileMultilibFirstAndDefaultValue(t *testing.T) { |
| 322 | expectedBazelTargets := []string{ |
| 323 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 324 | "native_shared_libs_32": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 325 | "//build/bazel/platforms/arch:arm": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 326 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 327 | ":native_shared_lib_for_both", |
| 328 | ":native_shared_lib_for_lib32", |
| 329 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 330 | ], |
| 331 | "//build/bazel/platforms/arch:x86": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 332 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 333 | ":native_shared_lib_for_both", |
| 334 | ":native_shared_lib_for_lib32", |
| 335 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 336 | ], |
| 337 | "//conditions:default": [], |
| 338 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 339 | "native_shared_libs_64": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 340 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 341 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 342 | ":native_shared_lib_for_both", |
| 343 | ":native_shared_lib_for_lib64", |
| 344 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 345 | ], |
| 346 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 347 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 348 | ":native_shared_lib_for_both", |
| 349 | ":native_shared_lib_for_lib64", |
| 350 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 351 | ], |
| 352 | "//conditions:default": [], |
| 353 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 354 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 355 | "manifest": `"apex_manifest.json"`, |
| 356 | }), |
| 357 | } |
| 358 | |
| 359 | // "first" is the default value of compile_multilib prop so `compile_multilib_: "first"` and unset compile_multilib |
| 360 | // should result to the same bp2build output |
| 361 | compileMultiLibPropValues := []string{`compile_multilib: "first",`, ""} |
| 362 | for _, compileMultiLibProp := range compileMultiLibPropValues { |
| 363 | descriptionSuffix := compileMultiLibProp |
| 364 | if descriptionSuffix == "" { |
| 365 | descriptionSuffix = "compile_multilib unset" |
| 366 | } |
| 367 | runApexTestCase(t, Bp2buildTestCase{ |
| 368 | Description: "apex - example with " + compileMultiLibProp, |
| 369 | ModuleTypeUnderTest: "apex", |
| 370 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 371 | StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"), |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 372 | Filesystem: map[string]string{ |
| 373 | "system/sepolicy/apex/Android.bp": ` |
| 374 | filegroup { |
| 375 | name: "com.android.apogee-file_contexts", |
| 376 | srcs: [ "apogee-file_contexts", ], |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 377 | } |
| 378 | `, |
| 379 | }, |
| 380 | Blueprint: createMultilibBlueprint(compileMultiLibProp), |
| 381 | ExpectedBazelTargets: expectedBazelTargets, |
| 382 | }) |
| 383 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | func TestApexBundleCompileMultilib32(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 387 | runApexTestCase(t, Bp2buildTestCase{ |
| 388 | Description: "apex - example with compile_multilib=32", |
| 389 | ModuleTypeUnderTest: "apex", |
| 390 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 391 | StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 392 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 393 | "system/sepolicy/apex/Android.bp": ` |
| 394 | filegroup { |
| 395 | name: "com.android.apogee-file_contexts", |
| 396 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 397 | } |
| 398 | `, |
| 399 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 400 | Blueprint: createMultilibBlueprint(`compile_multilib: "32",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 401 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 402 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 403 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 404 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 405 | ":native_shared_lib_for_both", |
| 406 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 407 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 408 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 409 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 410 | "//conditions:default": [], |
| 411 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 412 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 413 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 414 | }), |
| 415 | }}) |
| 416 | } |
| 417 | |
| 418 | func TestApexBundleCompileMultilib64(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 419 | runApexTestCase(t, Bp2buildTestCase{ |
| 420 | Description: "apex - example with compile_multilib=64", |
| 421 | ModuleTypeUnderTest: "apex", |
| 422 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 423 | StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 424 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 425 | "system/sepolicy/apex/Android.bp": ` |
| 426 | filegroup { |
| 427 | name: "com.android.apogee-file_contexts", |
| 428 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 429 | } |
| 430 | `, |
| 431 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 432 | Blueprint: createMultilibBlueprint(`compile_multilib: "64",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 433 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 434 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 435 | "native_shared_libs_64": `select({ |
| 436 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 437 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 438 | ":native_shared_lib_for_both", |
| 439 | ":native_shared_lib_for_lib64", |
| 440 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 441 | ], |
| 442 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 443 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 444 | ":native_shared_lib_for_both", |
| 445 | ":native_shared_lib_for_lib64", |
| 446 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 447 | ], |
| 448 | "//conditions:default": [], |
| 449 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 450 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 451 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 452 | }), |
| 453 | }}) |
| 454 | } |
| 455 | |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 456 | func multilibStubNames() []string { |
| 457 | return []string{"native_shared_lib_for_both", "native_shared_lib_for_first", "native_shared_lib_for_lib32", "native_shared_lib_for_lib64", |
| 458 | "native_shared_lib_for_lib64", "unnested_native_shared_lib"} |
| 459 | } |
| 460 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 461 | func createMultilibBlueprint(compile_multilib string) string { |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 462 | return fmt.Sprintf(` |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 463 | cc_library { |
| 464 | name: "native_shared_lib_for_both", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | cc_library { |
| 468 | name: "native_shared_lib_for_first", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | cc_library { |
| 472 | name: "native_shared_lib_for_lib32", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | cc_library { |
| 476 | name: "native_shared_lib_for_lib64", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 477 | } |
| 478 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 479 | cc_library { |
| 480 | name: "unnested_native_shared_lib", |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 481 | } |
| 482 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 483 | apex { |
| 484 | name: "com.android.apogee", |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 485 | %s |
| 486 | native_shared_libs: ["unnested_native_shared_lib"], |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 487 | multilib: { |
| 488 | both: { |
| 489 | native_shared_libs: [ |
| 490 | "native_shared_lib_for_both", |
| 491 | ], |
| 492 | }, |
| 493 | first: { |
| 494 | native_shared_libs: [ |
| 495 | "native_shared_lib_for_first", |
| 496 | ], |
| 497 | }, |
| 498 | lib32: { |
| 499 | native_shared_libs: [ |
| 500 | "native_shared_lib_for_lib32", |
| 501 | ], |
| 502 | }, |
| 503 | lib64: { |
| 504 | native_shared_libs: [ |
| 505 | "native_shared_lib_for_lib64", |
| 506 | ], |
| 507 | }, |
| 508 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 509 | }`, compile_multilib) |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 512 | func TestApexBundleDefaultPropertyValues(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 513 | runApexTestCase(t, Bp2buildTestCase{ |
| 514 | Description: "apex - default property values", |
| 515 | ModuleTypeUnderTest: "apex", |
| 516 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 517 | StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 518 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 519 | "system/sepolicy/apex/Android.bp": ` |
| 520 | filegroup { |
| 521 | name: "com.android.apogee-file_contexts", |
| 522 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 523 | } |
| 524 | `, |
| 525 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 526 | Blueprint: ` |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 527 | apex { |
| 528 | name: "com.android.apogee", |
| 529 | manifest: "apogee_manifest.json", |
| 530 | } |
| 531 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 532 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 533 | "manifest": `"apogee_manifest.json"`, |
| 534 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 535 | }), |
| 536 | }}) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 537 | } |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 538 | |
| 539 | func TestApexBundleHasBazelModuleProps(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 540 | runApexTestCase(t, Bp2buildTestCase{ |
| 541 | Description: "apex - has bazel module props", |
| 542 | ModuleTypeUnderTest: "apex", |
| 543 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 544 | StubbedBuildDefinitions: []string{"//system/sepolicy/apex:apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 545 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 546 | "system/sepolicy/apex/Android.bp": ` |
| 547 | filegroup { |
| 548 | name: "apogee-file_contexts", |
| 549 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 550 | } |
| 551 | `, |
| 552 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 553 | Blueprint: ` |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 554 | apex { |
| 555 | name: "apogee", |
| 556 | manifest: "manifest.json", |
| 557 | bazel_module: { bp2build_available: true }, |
| 558 | } |
| 559 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 560 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 561 | "manifest": `"manifest.json"`, |
| 562 | "file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 563 | }), |
| 564 | }}) |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 565 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 566 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 567 | func TestBp2BuildOverrideApex(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 568 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 569 | Description: "override_apex", |
| 570 | ModuleTypeUnderTest: "override_apex", |
| 571 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 572 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 573 | StubbedBuildDefinitions: []string{"com.android.apogee.key", "com.android.apogee.certificate", "native_shared_lib_1", |
| 574 | "native_shared_lib_2", "prebuilt_1", "prebuilt_2", "com.android.apogee-file_contexts", "cc_binary_1", |
| 575 | "sh_binary_2", "com.android.apogee", "com.google.android.apogee.key", "com.google.android.apogee.certificate"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 576 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 577 | apex_key { |
| 578 | name: "com.android.apogee.key", |
| 579 | public_key: "com.android.apogee.avbpubkey", |
| 580 | private_key: "com.android.apogee.pem", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | android_app_certificate { |
| 584 | name: "com.android.apogee.certificate", |
| 585 | certificate: "com.android.apogee", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | cc_library { |
| 589 | name: "native_shared_lib_1", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | cc_library { |
| 593 | name: "native_shared_lib_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 594 | } |
| 595 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 596 | prebuilt_etc { |
| 597 | name: "prebuilt_1", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 598 | } |
| 599 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 600 | prebuilt_etc { |
| 601 | name: "prebuilt_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | filegroup { |
| 605 | name: "com.android.apogee-file_contexts", |
| 606 | srcs: [ |
| 607 | "com.android.apogee-file_contexts", |
| 608 | ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 611 | cc_binary { name: "cc_binary_1" } |
Chris Parsons | 0c4de1f | 2023-09-21 20:36:35 +0000 | [diff] [blame^] | 612 | sh_binary { name: "sh_binary_2", src: "foo.sh"} |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 613 | |
| 614 | apex { |
| 615 | name: "com.android.apogee", |
| 616 | manifest: "apogee_manifest.json", |
| 617 | androidManifest: "ApogeeAndroidManifest.xml", |
| 618 | file_contexts: ":com.android.apogee-file_contexts", |
| 619 | min_sdk_version: "29", |
| 620 | key: "com.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 621 | certificate: ":com.android.apogee.certificate", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 622 | updatable: false, |
| 623 | installable: false, |
| 624 | compressible: false, |
| 625 | native_shared_libs: [ |
| 626 | "native_shared_lib_1", |
| 627 | "native_shared_lib_2", |
| 628 | ], |
| 629 | binaries: [ |
| 630 | "cc_binary_1", |
| 631 | "sh_binary_2", |
| 632 | ], |
| 633 | prebuilts: [ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 634 | "prebuilt_1", |
| 635 | "prebuilt_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 636 | ], |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | apex_key { |
| 640 | name: "com.google.android.apogee.key", |
| 641 | public_key: "com.google.android.apogee.avbpubkey", |
| 642 | private_key: "com.google.android.apogee.pem", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | android_app_certificate { |
| 646 | name: "com.google.android.apogee.certificate", |
| 647 | certificate: "com.google.android.apogee", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | override_apex { |
| 651 | name: "com.google.android.apogee", |
| 652 | base: ":com.android.apogee", |
| 653 | key: "com.google.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 654 | certificate: ":com.google.android.apogee.certificate", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 655 | prebuilts: [], |
| 656 | compressible: true, |
| 657 | } |
| 658 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 659 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 660 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 661 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 662 | "base_apex_name": `"com.android.apogee"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 663 | "binaries": `[ |
| 664 | ":cc_binary_1", |
| 665 | ":sh_binary_2", |
| 666 | ]`, |
| 667 | "certificate": `":com.google.android.apogee.certificate"`, |
| 668 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 669 | "installable": "False", |
| 670 | "key": `":com.google.android.apogee.key"`, |
| 671 | "manifest": `"apogee_manifest.json"`, |
| 672 | "min_sdk_version": `"29"`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 673 | "native_shared_libs_32": `select({ |
| 674 | "//build/bazel/platforms/arch:arm": [ |
| 675 | ":native_shared_lib_1", |
| 676 | ":native_shared_lib_2", |
| 677 | ], |
| 678 | "//build/bazel/platforms/arch:x86": [ |
| 679 | ":native_shared_lib_1", |
| 680 | ":native_shared_lib_2", |
| 681 | ], |
| 682 | "//conditions:default": [], |
| 683 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 684 | "native_shared_libs_64": `select({ |
| 685 | "//build/bazel/platforms/arch:arm64": [ |
| 686 | ":native_shared_lib_1", |
| 687 | ":native_shared_lib_2", |
| 688 | ], |
| 689 | "//build/bazel/platforms/arch:x86_64": [ |
| 690 | ":native_shared_lib_1", |
| 691 | ":native_shared_lib_2", |
| 692 | ], |
| 693 | "//conditions:default": [], |
| 694 | })`, |
| 695 | "prebuilts": `[]`, |
| 696 | "updatable": "False", |
| 697 | "compressible": "True", |
| 698 | }), |
| 699 | }}) |
| 700 | } |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 701 | |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 702 | func TestOverrideApexTest(t *testing.T) { |
| 703 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 704 | Description: "override_apex", |
| 705 | ModuleTypeUnderTest: "override_apex", |
| 706 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 707 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 708 | StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "native_shared_lib_1", |
| 709 | "prebuilt_1", "com.android.apogee-file_contexts", "cc_binary_1", "sh_binary_2", |
| 710 | "com.android.apogee", "com.google.android.apogee.key", "com.google.android.apogee.certificate", "com.android.apogee.key"}, |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 711 | Blueprint: ` |
| 712 | apex_key { |
| 713 | name: "com.android.apogee.key", |
| 714 | public_key: "com.android.apogee.avbpubkey", |
| 715 | private_key: "com.android.apogee.pem", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | android_app_certificate { |
| 719 | name: "com.android.apogee.certificate", |
| 720 | certificate: "com.android.apogee", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | cc_library { |
| 724 | name: "native_shared_lib_1", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | prebuilt_etc { |
| 728 | name: "prebuilt_1", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | filegroup { |
| 732 | name: "com.android.apogee-file_contexts", |
| 733 | srcs: [ |
| 734 | "com.android.apogee-file_contexts", |
| 735 | ], |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 736 | } |
| 737 | |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 738 | cc_binary { name: "cc_binary_1"} |
Chris Parsons | 0c4de1f | 2023-09-21 20:36:35 +0000 | [diff] [blame^] | 739 | sh_binary { name: "sh_binary_2", src: "foo.sh"} |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 740 | |
| 741 | apex_test { |
| 742 | name: "com.android.apogee", |
| 743 | manifest: "apogee_manifest.json", |
| 744 | androidManifest: "ApogeeAndroidManifest.xml", |
| 745 | file_contexts: ":com.android.apogee-file_contexts", |
| 746 | min_sdk_version: "29", |
| 747 | key: "com.android.apogee.key", |
| 748 | certificate: ":com.android.apogee.certificate", |
| 749 | updatable: false, |
| 750 | installable: false, |
| 751 | compressible: false, |
| 752 | native_shared_libs: [ |
| 753 | "native_shared_lib_1", |
| 754 | ], |
| 755 | binaries: [ |
| 756 | "cc_binary_1", |
| 757 | "sh_binary_2", |
| 758 | ], |
| 759 | prebuilts: [ |
| 760 | "prebuilt_1", |
| 761 | ], |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | apex_key { |
| 765 | name: "com.google.android.apogee.key", |
| 766 | public_key: "com.google.android.apogee.avbpubkey", |
| 767 | private_key: "com.google.android.apogee.pem", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | android_app_certificate { |
| 771 | name: "com.google.android.apogee.certificate", |
| 772 | certificate: "com.google.android.apogee", |
Liz Kammer | 1a1c9df | 2023-03-28 11:39:50 -0400 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | override_apex { |
| 776 | name: "com.google.android.apogee", |
| 777 | base: ":com.android.apogee", |
| 778 | key: "com.google.android.apogee.key", |
| 779 | certificate: ":com.google.android.apogee.certificate", |
| 780 | prebuilts: [], |
| 781 | compressible: true, |
| 782 | } |
| 783 | `, |
| 784 | ExpectedBazelTargets: []string{ |
| 785 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
| 786 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
| 787 | "base_apex_name": `"com.android.apogee"`, |
| 788 | "binaries": `[ |
| 789 | ":cc_binary_1", |
| 790 | ":sh_binary_2", |
| 791 | ]`, |
| 792 | "certificate": `":com.google.android.apogee.certificate"`, |
| 793 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 794 | "installable": "False", |
| 795 | "key": `":com.google.android.apogee.key"`, |
| 796 | "manifest": `"apogee_manifest.json"`, |
| 797 | "min_sdk_version": `"29"`, |
| 798 | "native_shared_libs_32": `select({ |
| 799 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_1"], |
| 800 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_1"], |
| 801 | "//conditions:default": [], |
| 802 | })`, |
| 803 | "native_shared_libs_64": `select({ |
| 804 | "//build/bazel/platforms/arch:arm64": [":native_shared_lib_1"], |
| 805 | "//build/bazel/platforms/arch:x86_64": [":native_shared_lib_1"], |
| 806 | "//conditions:default": [], |
| 807 | })`, |
| 808 | "testonly": "True", |
| 809 | "prebuilts": `[]`, |
| 810 | "updatable": "False", |
| 811 | "compressible": "True", |
| 812 | }), |
| 813 | }}) |
| 814 | } |
| 815 | |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 816 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 817 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 818 | Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp", |
| 819 | ModuleTypeUnderTest: "override_apex", |
| 820 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 821 | StubbedBuildDefinitions: []string{"//a/b:com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 822 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 823 | "system/sepolicy/apex/Android.bp": ` |
| 824 | filegroup { |
| 825 | name: "com.android.apogee-file_contexts", |
| 826 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 827 | }`, |
| 828 | "a/b/Android.bp": ` |
| 829 | apex { |
| 830 | name: "com.android.apogee", |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 831 | } |
| 832 | `, |
| 833 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 834 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 835 | override_apex { |
| 836 | name: "com.google.android.apogee", |
| 837 | base: ":com.android.apogee", |
| 838 | } |
| 839 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 840 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 841 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 842 | "base_apex_name": `"com.android.apogee"`, |
| 843 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 844 | "manifest": `"//a/b:apex_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 845 | }), |
| 846 | }}) |
| 847 | } |
| 848 | |
| 849 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 850 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 851 | Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp", |
| 852 | ModuleTypeUnderTest: "override_apex", |
| 853 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 854 | StubbedBuildDefinitions: []string{"//a/b:com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 855 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 856 | "system/sepolicy/apex/Android.bp": ` |
| 857 | filegroup { |
| 858 | name: "com.android.apogee-file_contexts", |
| 859 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 860 | }`, |
| 861 | "a/b/Android.bp": ` |
| 862 | apex { |
| 863 | name: "com.android.apogee", |
| 864 | manifest: "apogee_manifest.json", |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 865 | } |
| 866 | `, |
| 867 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 868 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 869 | override_apex { |
| 870 | name: "com.google.android.apogee", |
| 871 | base: ":com.android.apogee", |
| 872 | } |
| 873 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 874 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 875 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 876 | "base_apex_name": `"com.android.apogee"`, |
| 877 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 878 | "manifest": `"//a/b:apogee_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 879 | }), |
| 880 | }}) |
| 881 | } |
| 882 | |
| 883 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 884 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 885 | Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp", |
| 886 | ModuleTypeUnderTest: "override_apex", |
| 887 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 888 | StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 889 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 890 | "system/sepolicy/apex/Android.bp": ` |
| 891 | filegroup { |
| 892 | name: "com.android.apogee-file_contexts", |
| 893 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 894 | }`, |
| 895 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 896 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 897 | apex { |
| 898 | name: "com.android.apogee", |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | override_apex { |
| 902 | name: "com.google.android.apogee", |
| 903 | base: ":com.android.apogee", |
| 904 | } |
| 905 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 906 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 907 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 908 | "base_apex_name": `"com.android.apogee"`, |
| 909 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 910 | "manifest": `"apex_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 911 | }), |
| 912 | }}) |
| 913 | } |
| 914 | |
| 915 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 916 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 917 | Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp", |
| 918 | ModuleTypeUnderTest: "override_apex", |
| 919 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 920 | StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 921 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 922 | "system/sepolicy/apex/Android.bp": ` |
| 923 | filegroup { |
| 924 | name: "com.android.apogee-file_contexts", |
| 925 | srcs: [ "apogee-file_contexts", ], |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 926 | }`, |
| 927 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 928 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 929 | apex { |
| 930 | name: "com.android.apogee", |
| 931 | manifest: "apogee_manifest.json", |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | override_apex { |
| 935 | name: "com.google.android.apogee", |
| 936 | base: ":com.android.apogee", |
| 937 | } |
| 938 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 939 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 940 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 941 | "base_apex_name": `"com.android.apogee"`, |
| 942 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 943 | "manifest": `"apogee_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 944 | }), |
| 945 | }}) |
| 946 | } |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 947 | |
| 948 | func TestApexBundleSimple_packageNameOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 949 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 950 | Description: "override_apex - override package name", |
| 951 | ModuleTypeUnderTest: "override_apex", |
| 952 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 953 | StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 954 | Filesystem: map[string]string{ |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 955 | "system/sepolicy/apex/Android.bp": ` |
| 956 | filegroup { |
| 957 | name: "com.android.apogee-file_contexts", |
| 958 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 959 | }`, |
| 960 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 961 | Blueprint: ` |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 962 | apex { |
| 963 | name: "com.android.apogee", |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 964 | } |
| 965 | |
| 966 | override_apex { |
| 967 | name: "com.google.android.apogee", |
| 968 | base: ":com.android.apogee", |
| 969 | package_name: "com.google.android.apogee", |
| 970 | } |
| 971 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 972 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 973 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 974 | "base_apex_name": `"com.android.apogee"`, |
| 975 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 976 | "manifest": `"apex_manifest.json"`, |
| 977 | "package_name": `"com.google.android.apogee"`, |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 978 | }), |
| 979 | }}) |
| 980 | } |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 981 | |
| 982 | func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 983 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 984 | Description: "override_apex - no override", |
| 985 | ModuleTypeUnderTest: "override_apex", |
| 986 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 987 | StubbedBuildDefinitions: []string{"prebuilt_file", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 988 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 989 | "system/sepolicy/apex/Android.bp": ` |
| 990 | filegroup { |
| 991 | name: "com.android.apogee-file_contexts", |
| 992 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 993 | }`, |
| 994 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 995 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 996 | prebuilt_etc { |
| 997 | name: "prebuilt_file", |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | apex { |
| 1001 | name: "com.android.apogee", |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1002 | prebuilts: ["prebuilt_file"] |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | override_apex { |
| 1006 | name: "com.google.android.apogee", |
| 1007 | base: ":com.android.apogee", |
| 1008 | } |
| 1009 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1010 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1011 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1012 | "base_apex_name": `"com.android.apogee"`, |
| 1013 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1014 | "manifest": `"apex_manifest.json"`, |
| 1015 | "prebuilts": `[":prebuilt_file"]`, |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1016 | }), |
| 1017 | }}) |
| 1018 | } |
| 1019 | |
| 1020 | func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1021 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1022 | Description: "override_apex - ooverride", |
| 1023 | ModuleTypeUnderTest: "override_apex", |
| 1024 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1025 | StubbedBuildDefinitions: []string{"prebuilt_file", "prebuilt_file2", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1026 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1027 | "system/sepolicy/apex/Android.bp": ` |
| 1028 | filegroup { |
| 1029 | name: "com.android.apogee-file_contexts", |
| 1030 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1031 | }`, |
| 1032 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1033 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1034 | prebuilt_etc { |
| 1035 | name: "prebuilt_file", |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | prebuilt_etc { |
| 1039 | name: "prebuilt_file2", |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | apex { |
| 1043 | name: "com.android.apogee", |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1044 | prebuilts: ["prebuilt_file"] |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1045 | } |
| 1046 | |
| 1047 | override_apex { |
| 1048 | name: "com.google.android.apogee", |
| 1049 | base: ":com.android.apogee", |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1050 | prebuilts: ["prebuilt_file2"] |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1051 | } |
| 1052 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1053 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1054 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1055 | "base_apex_name": `"com.android.apogee"`, |
| 1056 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1057 | "manifest": `"apex_manifest.json"`, |
| 1058 | "prebuilts": `[":prebuilt_file2"]`, |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1059 | }), |
| 1060 | }}) |
| 1061 | } |
| 1062 | |
| 1063 | func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1064 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1065 | Description: "override_apex - override with empty list", |
| 1066 | ModuleTypeUnderTest: "override_apex", |
| 1067 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1068 | StubbedBuildDefinitions: []string{"prebuilt_file", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1069 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1070 | "system/sepolicy/apex/Android.bp": ` |
| 1071 | filegroup { |
| 1072 | name: "com.android.apogee-file_contexts", |
| 1073 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1074 | }`, |
| 1075 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1076 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1077 | prebuilt_etc { |
| 1078 | name: "prebuilt_file", |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | apex { |
| 1082 | name: "com.android.apogee", |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1083 | prebuilts: ["prebuilt_file"] |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | override_apex { |
| 1087 | name: "com.google.android.apogee", |
| 1088 | base: ":com.android.apogee", |
| 1089 | prebuilts: [], |
| 1090 | } |
| 1091 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1092 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1093 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1094 | "base_apex_name": `"com.android.apogee"`, |
| 1095 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1096 | "manifest": `"apex_manifest.json"`, |
| 1097 | "prebuilts": `[]`, |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1098 | }), |
| 1099 | }}) |
| 1100 | } |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1101 | |
| 1102 | func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1103 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1104 | Description: "override_apex - logging_parent - no override", |
| 1105 | ModuleTypeUnderTest: "override_apex", |
| 1106 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 1107 | StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1108 | Filesystem: map[string]string{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1109 | "system/sepolicy/apex/Android.bp": ` |
| 1110 | filegroup { |
| 1111 | name: "com.android.apogee-file_contexts", |
| 1112 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1113 | }`, |
| 1114 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1115 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1116 | apex { |
| 1117 | name: "com.android.apogee", |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1118 | logging_parent: "foo.bar.baz", |
| 1119 | } |
| 1120 | |
| 1121 | override_apex { |
| 1122 | name: "com.google.android.apogee", |
| 1123 | base: ":com.android.apogee", |
| 1124 | } |
| 1125 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1126 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1127 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1128 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1129 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1130 | "manifest": `"apex_manifest.json"`, |
| 1131 | "logging_parent": `"foo.bar.baz"`, |
| 1132 | }), |
| 1133 | }}) |
| 1134 | } |
| 1135 | |
| 1136 | func TestApexBundleSimple_LoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1137 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1138 | Description: "override_apex - logging_parent - override", |
| 1139 | ModuleTypeUnderTest: "override_apex", |
| 1140 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 1141 | StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1142 | Filesystem: map[string]string{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1143 | "system/sepolicy/apex/Android.bp": ` |
| 1144 | filegroup { |
| 1145 | name: "com.android.apogee-file_contexts", |
| 1146 | srcs: [ "apogee-file_contexts", ], |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1147 | }`, |
| 1148 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1149 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1150 | apex { |
| 1151 | name: "com.android.apogee", |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1152 | logging_parent: "foo.bar.baz", |
| 1153 | } |
| 1154 | |
| 1155 | override_apex { |
| 1156 | name: "com.google.android.apogee", |
| 1157 | base: ":com.android.apogee", |
| 1158 | logging_parent: "foo.bar.baz.override", |
| 1159 | } |
| 1160 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1161 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1162 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1163 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1164 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1165 | "manifest": `"apex_manifest.json"`, |
| 1166 | "logging_parent": `"foo.bar.baz.override"`, |
| 1167 | }), |
| 1168 | }}) |
| 1169 | } |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1170 | |
| 1171 | func TestBp2BuildOverrideApex_CertificateNil(t *testing.T) { |
| 1172 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1173 | Description: "override_apex - don't set default certificate", |
| 1174 | ModuleTypeUnderTest: "override_apex", |
| 1175 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1176 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1177 | StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee-file_contexts", "com.android.apogee"}, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1178 | Blueprint: ` |
| 1179 | android_app_certificate { |
| 1180 | name: "com.android.apogee.certificate", |
| 1181 | certificate: "com.android.apogee", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | filegroup { |
| 1185 | name: "com.android.apogee-file_contexts", |
| 1186 | srcs: [ |
| 1187 | "com.android.apogee-file_contexts", |
| 1188 | ], |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | apex { |
| 1192 | name: "com.android.apogee", |
| 1193 | manifest: "apogee_manifest.json", |
| 1194 | file_contexts: ":com.android.apogee-file_contexts", |
| 1195 | certificate: ":com.android.apogee.certificate", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | override_apex { |
| 1199 | name: "com.google.android.apogee", |
| 1200 | base: ":com.android.apogee", |
| 1201 | // certificate is deliberately omitted, and not converted to bazel, |
| 1202 | // because the overridden apex shouldn't be using the base apex's cert. |
| 1203 | } |
| 1204 | `, |
| 1205 | ExpectedBazelTargets: []string{ |
| 1206 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1207 | "base_apex_name": `"com.android.apogee"`, |
| 1208 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1209 | "manifest": `"apogee_manifest.json"`, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1210 | }), |
| 1211 | }}) |
| 1212 | } |
| 1213 | |
| 1214 | func TestApexCertificateIsModule(t *testing.T) { |
| 1215 | runApexTestCase(t, Bp2buildTestCase{ |
| 1216 | Description: "apex - certificate is module", |
| 1217 | ModuleTypeUnderTest: "apex", |
| 1218 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1219 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1220 | StubbedBuildDefinitions: []string{"com.android.apogee-file_contexts", "com.android.apogee.certificate"}, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1221 | Blueprint: ` |
| 1222 | android_app_certificate { |
| 1223 | name: "com.android.apogee.certificate", |
| 1224 | certificate: "com.android.apogee", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | apex { |
| 1228 | name: "com.android.apogee", |
| 1229 | manifest: "apogee_manifest.json", |
| 1230 | file_contexts: ":com.android.apogee-file_contexts", |
| 1231 | certificate: ":com.android.apogee.certificate", |
| 1232 | } |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1233 | ` + simpleModule("filegroup", "com.android.apogee-file_contexts"), |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1234 | ExpectedBazelTargets: []string{ |
| 1235 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 1236 | "certificate": `":com.android.apogee.certificate"`, |
| 1237 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1238 | "manifest": `"apogee_manifest.json"`, |
| 1239 | }), |
| 1240 | }}) |
| 1241 | } |
| 1242 | |
Vinh Tran | 55225e3 | 2022-12-20 10:38:48 -0500 | [diff] [blame] | 1243 | func TestApexWithStubLib(t *testing.T) { |
| 1244 | runApexTestCase(t, Bp2buildTestCase{ |
| 1245 | Description: "apex - static variant of stub lib should not have apex_available tag", |
| 1246 | ModuleTypeUnderTest: "apex", |
| 1247 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1248 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1249 | StubbedBuildDefinitions: []string{"myapex-file_contexts"}, |
Vinh Tran | 55225e3 | 2022-12-20 10:38:48 -0500 | [diff] [blame] | 1250 | Blueprint: ` |
| 1251 | cc_library{ |
| 1252 | name: "foo", |
| 1253 | stubs: { symbol_file: "foo.map.txt", versions: ["28", "29", "current"] }, |
| 1254 | apex_available: ["myapex"], |
| 1255 | } |
| 1256 | |
| 1257 | cc_binary{ |
| 1258 | name: "bar", |
| 1259 | static_libs: ["foo"], |
| 1260 | apex_available: ["myapex"], |
| 1261 | } |
| 1262 | |
| 1263 | apex { |
| 1264 | name: "myapex", |
| 1265 | manifest: "myapex_manifest.json", |
| 1266 | file_contexts: ":myapex-file_contexts", |
| 1267 | binaries: ["bar"], |
| 1268 | native_shared_libs: ["foo"], |
| 1269 | } |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1270 | ` + simpleModule("filegroup", "myapex-file_contexts"), |
Vinh Tran | 55225e3 | 2022-12-20 10:38:48 -0500 | [diff] [blame] | 1271 | ExpectedBazelTargets: []string{ |
| 1272 | MakeBazelTarget("cc_binary", "bar", AttrNameToString{ |
| 1273 | "local_includes": `["."]`, |
| 1274 | "deps": `[":foo_bp2build_cc_library_static"]`, |
| 1275 | "tags": `["apex_available=myapex"]`, |
| 1276 | }), |
| 1277 | MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{ |
| 1278 | "local_includes": `["."]`, |
| 1279 | }), |
| 1280 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1281 | "local_includes": `["."]`, |
| 1282 | "stubs_symbol_file": `"foo.map.txt"`, |
| 1283 | "tags": `["apex_available=myapex"]`, |
| 1284 | }), |
| 1285 | MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{ |
Spandan Das | 04f9f4c | 2023-09-13 23:59:05 +0000 | [diff] [blame] | 1286 | "api_surface": `"module-libapi"`, |
Sam Delmerico | 5f90649 | 2023-03-15 18:06:18 -0400 | [diff] [blame] | 1287 | "soname": `"foo.so"`, |
| 1288 | "source_library_label": `"//:foo"`, |
| 1289 | "symbol_file": `"foo.map.txt"`, |
Vinh Tran | 55225e3 | 2022-12-20 10:38:48 -0500 | [diff] [blame] | 1290 | "versions": `[ |
| 1291 | "28", |
| 1292 | "29", |
| 1293 | "current", |
| 1294 | ]`, |
| 1295 | }), |
| 1296 | MakeBazelTarget("apex", "myapex", AttrNameToString{ |
| 1297 | "file_contexts": `":myapex-file_contexts"`, |
| 1298 | "manifest": `"myapex_manifest.json"`, |
| 1299 | "binaries": `[":bar"]`, |
| 1300 | "native_shared_libs_32": `select({ |
| 1301 | "//build/bazel/platforms/arch:arm": [":foo"], |
| 1302 | "//build/bazel/platforms/arch:x86": [":foo"], |
| 1303 | "//conditions:default": [], |
| 1304 | })`, |
| 1305 | "native_shared_libs_64": `select({ |
| 1306 | "//build/bazel/platforms/arch:arm64": [":foo"], |
| 1307 | "//build/bazel/platforms/arch:x86_64": [":foo"], |
| 1308 | "//conditions:default": [], |
| 1309 | })`, |
| 1310 | }), |
| 1311 | }, |
| 1312 | }) |
| 1313 | } |
| 1314 | |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1315 | func TestApexCertificateIsSrc(t *testing.T) { |
| 1316 | runApexTestCase(t, Bp2buildTestCase{ |
| 1317 | Description: "apex - certificate is src", |
| 1318 | ModuleTypeUnderTest: "apex", |
| 1319 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1320 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1321 | StubbedBuildDefinitions: []string{"com.android.apogee-file_contexts"}, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1322 | Blueprint: ` |
| 1323 | apex { |
| 1324 | name: "com.android.apogee", |
| 1325 | manifest: "apogee_manifest.json", |
| 1326 | file_contexts: ":com.android.apogee-file_contexts", |
| 1327 | certificate: "com.android.apogee.certificate", |
| 1328 | } |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1329 | ` + simpleModule("filegroup", "com.android.apogee-file_contexts"), |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1330 | ExpectedBazelTargets: []string{ |
| 1331 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 1332 | "certificate_name": `"com.android.apogee.certificate"`, |
| 1333 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1334 | "manifest": `"apogee_manifest.json"`, |
| 1335 | }), |
| 1336 | }}) |
| 1337 | } |
| 1338 | |
| 1339 | func TestBp2BuildOverrideApex_CertificateIsModule(t *testing.T) { |
| 1340 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1341 | Description: "override_apex - certificate is module", |
| 1342 | ModuleTypeUnderTest: "override_apex", |
| 1343 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1344 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1345 | StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee-file_contexts", |
| 1346 | "com.android.apogee", "com.google.android.apogee.certificate"}, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1347 | Blueprint: ` |
| 1348 | android_app_certificate { |
| 1349 | name: "com.android.apogee.certificate", |
| 1350 | certificate: "com.android.apogee", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | filegroup { |
| 1354 | name: "com.android.apogee-file_contexts", |
| 1355 | srcs: [ |
| 1356 | "com.android.apogee-file_contexts", |
| 1357 | ], |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | apex { |
| 1361 | name: "com.android.apogee", |
| 1362 | manifest: "apogee_manifest.json", |
| 1363 | file_contexts: ":com.android.apogee-file_contexts", |
| 1364 | certificate: ":com.android.apogee.certificate", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1365 | } |
| 1366 | |
| 1367 | android_app_certificate { |
| 1368 | name: "com.google.android.apogee.certificate", |
| 1369 | certificate: "com.google.android.apogee", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1370 | } |
| 1371 | |
| 1372 | override_apex { |
| 1373 | name: "com.google.android.apogee", |
| 1374 | base: ":com.android.apogee", |
| 1375 | certificate: ":com.google.android.apogee.certificate", |
| 1376 | } |
| 1377 | `, |
| 1378 | ExpectedBazelTargets: []string{ |
| 1379 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1380 | "base_apex_name": `"com.android.apogee"`, |
| 1381 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1382 | "certificate": `":com.google.android.apogee.certificate"`, |
| 1383 | "manifest": `"apogee_manifest.json"`, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1384 | }), |
| 1385 | }}) |
| 1386 | } |
| 1387 | |
| 1388 | func TestBp2BuildOverrideApex_CertificateIsSrc(t *testing.T) { |
| 1389 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1390 | Description: "override_apex - certificate is src", |
| 1391 | ModuleTypeUnderTest: "override_apex", |
| 1392 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1393 | Filesystem: map[string]string{}, |
Chris Parsons | 4c81ce0 | 2023-09-21 15:30:27 +0000 | [diff] [blame] | 1394 | StubbedBuildDefinitions: []string{"com.android.apogee", "com.android.apogee.certificate", "com.android.apogee", "com.android.apogee-file_contexts"}, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1395 | Blueprint: ` |
| 1396 | android_app_certificate { |
| 1397 | name: "com.android.apogee.certificate", |
| 1398 | certificate: "com.android.apogee", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | filegroup { |
| 1402 | name: "com.android.apogee-file_contexts", |
| 1403 | srcs: [ |
| 1404 | "com.android.apogee-file_contexts", |
| 1405 | ], |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1406 | } |
| 1407 | |
| 1408 | apex { |
| 1409 | name: "com.android.apogee", |
| 1410 | manifest: "apogee_manifest.json", |
| 1411 | file_contexts: ":com.android.apogee-file_contexts", |
| 1412 | certificate: ":com.android.apogee.certificate", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | override_apex { |
| 1416 | name: "com.google.android.apogee", |
| 1417 | base: ":com.android.apogee", |
| 1418 | certificate: "com.google.android.apogee.certificate", |
| 1419 | } |
| 1420 | `, |
| 1421 | ExpectedBazelTargets: []string{ |
| 1422 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1423 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1424 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1425 | "certificate_name": `"com.google.android.apogee.certificate"`, |
| 1426 | "manifest": `"apogee_manifest.json"`, |
| 1427 | }), |
| 1428 | }}) |
| 1429 | } |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 1430 | |
| 1431 | func TestApexTestBundleSimple(t *testing.T) { |
| 1432 | runApexTestCase(t, Bp2buildTestCase{ |
| 1433 | Description: "apex_test - simple", |
| 1434 | ModuleTypeUnderTest: "apex_test", |
| 1435 | ModuleTypeUnderTestFactory: apex.TestApexBundleFactory, |
| 1436 | Filesystem: map[string]string{}, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1437 | StubbedBuildDefinitions: []string{"cc_test_1"}, |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 1438 | Blueprint: ` |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1439 | cc_test { name: "cc_test_1"} |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 1440 | |
| 1441 | apex_test { |
| 1442 | name: "test_com.android.apogee", |
| 1443 | file_contexts: "file_contexts_file", |
| 1444 | tests: ["cc_test_1"], |
| 1445 | } |
| 1446 | `, |
| 1447 | ExpectedBazelTargets: []string{ |
| 1448 | MakeBazelTarget("apex", "test_com.android.apogee", AttrNameToString{ |
Spandan Das | a43ae13 | 2023-05-08 18:33:16 +0000 | [diff] [blame] | 1449 | "file_contexts": `"file_contexts_file"`, |
| 1450 | "base_apex_name": `"com.android.apogee"`, |
| 1451 | "manifest": `"apex_manifest.json"`, |
| 1452 | "testonly": `True`, |
| 1453 | "tests": `[":cc_test_1"]`, |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 1454 | }), |
| 1455 | }}) |
| 1456 | } |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 1457 | |
| 1458 | func TestApexBundle_overridePlusProductVars(t *testing.T) { |
| 1459 | // Reproduction of b/271424349 |
| 1460 | // Tests that overriding an apex that uses product variables correctly copies the product var |
| 1461 | // selects over to the override. |
| 1462 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1463 | Description: "apex - overriding a module that uses product vars", |
| 1464 | ModuleTypeUnderTest: "override_apex", |
| 1465 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
Chris Parsons | cd20903 | 2023-09-19 01:12:48 +0000 | [diff] [blame] | 1466 | StubbedBuildDefinitions: []string{"foo-file_contexts"}, |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 1467 | Blueprint: ` |
| 1468 | soong_config_string_variable { |
| 1469 | name: "library_linking_strategy", |
| 1470 | values: [ |
| 1471 | "prefer_static", |
| 1472 | ], |
| 1473 | } |
| 1474 | |
| 1475 | soong_config_module_type { |
| 1476 | name: "library_linking_strategy_apex_defaults", |
| 1477 | module_type: "apex_defaults", |
| 1478 | config_namespace: "ANDROID", |
| 1479 | variables: ["library_linking_strategy"], |
| 1480 | properties: [ |
| 1481 | "manifest", |
| 1482 | "min_sdk_version", |
| 1483 | ], |
| 1484 | } |
| 1485 | |
| 1486 | library_linking_strategy_apex_defaults { |
| 1487 | name: "higher_min_sdk_when_prefer_static", |
| 1488 | soong_config_variables: { |
| 1489 | library_linking_strategy: { |
| 1490 | // Use the R min_sdk_version |
| 1491 | prefer_static: {}, |
| 1492 | // Override the R min_sdk_version to min_sdk_version that supports dcla |
| 1493 | conditions_default: { |
| 1494 | min_sdk_version: "31", |
| 1495 | }, |
| 1496 | }, |
| 1497 | }, |
| 1498 | } |
| 1499 | |
| 1500 | filegroup { |
| 1501 | name: "foo-file_contexts", |
| 1502 | srcs: [ |
| 1503 | "com.android.apogee-file_contexts", |
| 1504 | ], |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 1505 | } |
| 1506 | |
| 1507 | apex { |
| 1508 | name: "foo", |
| 1509 | defaults: ["higher_min_sdk_when_prefer_static"], |
| 1510 | min_sdk_version: "30", |
| 1511 | package_name: "pkg_name", |
| 1512 | file_contexts: ":foo-file_contexts", |
| 1513 | } |
| 1514 | override_apex { |
| 1515 | name: "override_foo", |
| 1516 | base: ":foo", |
| 1517 | package_name: "override_pkg_name", |
| 1518 | } |
| 1519 | `, |
| 1520 | ExpectedBazelTargets: []string{ |
| 1521 | MakeBazelTarget("apex", "foo", AttrNameToString{ |
| 1522 | "file_contexts": `":foo-file_contexts"`, |
| 1523 | "manifest": `"apex_manifest.json"`, |
| 1524 | "min_sdk_version": `select({ |
Cole Faust | 87c0c33 | 2023-07-31 12:10:12 -0700 | [diff] [blame] | 1525 | "//build/bazel/product_config/config_settings:android__library_linking_strategy__prefer_static": "30", |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 1526 | "//conditions:default": "31", |
| 1527 | })`, |
| 1528 | "package_name": `"pkg_name"`, |
| 1529 | }), MakeBazelTarget("apex", "override_foo", AttrNameToString{ |
| 1530 | "base_apex_name": `"foo"`, |
| 1531 | "file_contexts": `":foo-file_contexts"`, |
| 1532 | "manifest": `"apex_manifest.json"`, |
| 1533 | "min_sdk_version": `select({ |
Cole Faust | 87c0c33 | 2023-07-31 12:10:12 -0700 | [diff] [blame] | 1534 | "//build/bazel/product_config/config_settings:android__library_linking_strategy__prefer_static": "30", |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame] | 1535 | "//conditions:default": "31", |
| 1536 | })`, |
| 1537 | "package_name": `"override_pkg_name"`, |
| 1538 | }), |
| 1539 | }}) |
| 1540 | } |
Jingwen Chen | a8623da | 2023-03-28 13:05:02 +0000 | [diff] [blame] | 1541 | |
| 1542 | func TestApexBundleSimple_customCannedFsConfig(t *testing.T) { |
| 1543 | runApexTestCase(t, Bp2buildTestCase{ |
| 1544 | Description: "apex - custom canned_fs_config", |
| 1545 | ModuleTypeUnderTest: "apex", |
| 1546 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1547 | Filesystem: map[string]string{}, |
| 1548 | Blueprint: ` |
| 1549 | apex { |
| 1550 | name: "com.android.apogee", |
| 1551 | canned_fs_config: "custom.canned_fs_config", |
| 1552 | file_contexts: "file_contexts_file", |
| 1553 | } |
| 1554 | `, |
| 1555 | ExpectedBazelTargets: []string{ |
| 1556 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 1557 | "canned_fs_config": `"custom.canned_fs_config"`, |
| 1558 | "file_contexts": `"file_contexts_file"`, |
| 1559 | "manifest": `"apex_manifest.json"`, |
| 1560 | }), |
| 1561 | }}) |
| 1562 | } |