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) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 45 | } |
| 46 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 47 | func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) { |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 48 | t.Helper() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 49 | RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | func registerOverrideApexModuleTypes(ctx android.RegistrationContext) { |
| 53 | // CC module types needed as they can be APEX dependencies |
| 54 | cc.RegisterCCBuildComponents(ctx) |
| 55 | |
| 56 | ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory) |
| 57 | ctx.RegisterModuleType("cc_binary", cc.BinaryFactory) |
| 58 | ctx.RegisterModuleType("cc_library", cc.LibraryFactory) |
| 59 | ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory) |
| 60 | ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory) |
| 61 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
| 62 | ctx.RegisterModuleType("apex", apex.BundleFactory) |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 63 | ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 66 | func TestApexBundleSimple(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 67 | runApexTestCase(t, Bp2buildTestCase{ |
| 68 | Description: "apex - example with all props, file_context is a module in same Android.bp", |
| 69 | ModuleTypeUnderTest: "apex", |
| 70 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 71 | Filesystem: map[string]string{}, |
| 72 | Blueprint: ` |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 73 | apex_key { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 74 | name: "com.android.apogee.key", |
| 75 | public_key: "com.android.apogee.avbpubkey", |
| 76 | private_key: "com.android.apogee.pem", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 77 | bazel_module: { bp2build_available: false }, |
| 78 | } |
| 79 | |
| 80 | android_app_certificate { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 81 | name: "com.android.apogee.certificate", |
| 82 | certificate: "com.android.apogee", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 83 | bazel_module: { bp2build_available: false }, |
| 84 | } |
| 85 | |
| 86 | cc_library { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 87 | name: "native_shared_lib_1", |
| 88 | bazel_module: { bp2build_available: false }, |
| 89 | } |
| 90 | |
| 91 | cc_library { |
| 92 | name: "native_shared_lib_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 93 | bazel_module: { bp2build_available: false }, |
| 94 | } |
| 95 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 96 | prebuilt_etc { |
| 97 | name: "prebuilt_1", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 98 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 99 | } |
| 100 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 101 | prebuilt_etc { |
| 102 | name: "prebuilt_2", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 103 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 104 | } |
| 105 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 106 | filegroup { |
| 107 | name: "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 108 | srcs: [ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 109 | "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 110 | ], |
| 111 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 112 | } |
| 113 | |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 114 | cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } } |
| 115 | sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } } |
| 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", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 121 | file_contexts: ":com.android.apogee-file_contexts", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 122 | min_sdk_version: "29", |
| 123 | key: "com.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 124 | certificate: ":com.android.apogee.certificate", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 125 | updatable: false, |
| 126 | installable: false, |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 127 | compressible: false, |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 128 | native_shared_libs: [ |
| 129 | "native_shared_lib_1", |
| 130 | "native_shared_lib_2", |
| 131 | ], |
| 132 | binaries: [ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 133 | "cc_binary_1", |
| 134 | "sh_binary_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 135 | ], |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 136 | prebuilts: [ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 137 | "prebuilt_1", |
| 138 | "prebuilt_2", |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 139 | ], |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 140 | package_name: "com.android.apogee.test.package", |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 141 | logging_parent: "logging.parent", |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 142 | } |
| 143 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 144 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 145 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 146 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
| 147 | "binaries": `[ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 148 | ":cc_binary_1", |
| 149 | ":sh_binary_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 150 | ]`, |
| 151 | "certificate": `":com.android.apogee.certificate"`, |
| 152 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 153 | "installable": "False", |
| 154 | "key": `":com.android.apogee.key"`, |
| 155 | "manifest": `"apogee_manifest.json"`, |
| 156 | "min_sdk_version": `"29"`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 157 | "native_shared_libs_32": `select({ |
| 158 | "//build/bazel/platforms/arch:arm": [ |
| 159 | ":native_shared_lib_1", |
| 160 | ":native_shared_lib_2", |
| 161 | ], |
| 162 | "//build/bazel/platforms/arch:x86": [ |
| 163 | ":native_shared_lib_1", |
| 164 | ":native_shared_lib_2", |
| 165 | ], |
| 166 | "//conditions:default": [], |
| 167 | })`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 168 | "native_shared_libs_64": `select({ |
| 169 | "//build/bazel/platforms/arch:arm64": [ |
| 170 | ":native_shared_lib_1", |
| 171 | ":native_shared_lib_2", |
| 172 | ], |
| 173 | "//build/bazel/platforms/arch:x86_64": [ |
| 174 | ":native_shared_lib_1", |
| 175 | ":native_shared_lib_2", |
| 176 | ], |
| 177 | "//conditions:default": [], |
| 178 | })`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 179 | "prebuilts": `[ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 180 | ":prebuilt_1", |
| 181 | ":prebuilt_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 182 | ]`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 183 | "updatable": "False", |
| 184 | "compressible": "False", |
| 185 | "package_name": `"com.android.apogee.test.package"`, |
| 186 | "logging_parent": `"logging.parent"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 187 | }), |
| 188 | }}) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 189 | } |
| 190 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 191 | func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 192 | runApexTestCase(t, Bp2buildTestCase{ |
| 193 | Description: "apex - file contexts is a module in another Android.bp", |
| 194 | ModuleTypeUnderTest: "apex", |
| 195 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 196 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 197 | "a/b/Android.bp": ` |
| 198 | filegroup { |
| 199 | name: "com.android.apogee-file_contexts", |
| 200 | srcs: [ |
| 201 | "com.android.apogee-file_contexts", |
| 202 | ], |
| 203 | bazel_module: { bp2build_available: false }, |
| 204 | } |
| 205 | `, |
| 206 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 207 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 208 | apex { |
| 209 | name: "com.android.apogee", |
| 210 | file_contexts: ":com.android.apogee-file_contexts", |
| 211 | } |
| 212 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 213 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 214 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 215 | "file_contexts": `"//a/b:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 216 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 217 | }), |
| 218 | }}) |
| 219 | } |
| 220 | |
| 221 | func TestApexBundleSimple_fileContextsIsFile(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 222 | runApexTestCase(t, Bp2buildTestCase{ |
| 223 | Description: "apex - file contexts is a file", |
| 224 | ModuleTypeUnderTest: "apex", |
| 225 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 226 | Filesystem: map[string]string{}, |
| 227 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 228 | apex { |
| 229 | name: "com.android.apogee", |
| 230 | file_contexts: "file_contexts_file", |
| 231 | } |
| 232 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 233 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 234 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 235 | "file_contexts": `"file_contexts_file"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 236 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 237 | }), |
| 238 | }}) |
| 239 | } |
| 240 | |
| 241 | func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 242 | runApexTestCase(t, Bp2buildTestCase{ |
| 243 | Description: "apex - file contexts is not specified", |
| 244 | ModuleTypeUnderTest: "apex", |
| 245 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 246 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 247 | "system/sepolicy/apex/Android.bp": ` |
| 248 | filegroup { |
| 249 | name: "com.android.apogee-file_contexts", |
| 250 | srcs: [ |
| 251 | "com.android.apogee-file_contexts", |
| 252 | ], |
| 253 | bazel_module: { bp2build_available: false }, |
| 254 | } |
| 255 | `, |
| 256 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 257 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 258 | apex { |
| 259 | name: "com.android.apogee", |
| 260 | } |
| 261 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 262 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 263 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 264 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 265 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 266 | }), |
| 267 | }}) |
| 268 | } |
| 269 | |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 270 | func TestApexBundleCompileMultilibBoth(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 271 | runApexTestCase(t, Bp2buildTestCase{ |
| 272 | Description: "apex - example with compile_multilib=both", |
| 273 | ModuleTypeUnderTest: "apex", |
| 274 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 275 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 276 | "system/sepolicy/apex/Android.bp": ` |
| 277 | filegroup { |
| 278 | name: "com.android.apogee-file_contexts", |
| 279 | srcs: [ "apogee-file_contexts", ], |
| 280 | bazel_module: { bp2build_available: false }, |
| 281 | } |
| 282 | `, |
| 283 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 284 | Blueprint: createMultilibBlueprint(`compile_multilib: "both",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 285 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 286 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 287 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 288 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 289 | ":native_shared_lib_for_both", |
| 290 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 291 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 292 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 293 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 294 | "//conditions:default": [], |
| 295 | })`, |
| 296 | "native_shared_libs_64": `select({ |
| 297 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 298 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 299 | ":native_shared_lib_for_both", |
| 300 | ":native_shared_lib_for_lib64", |
| 301 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 302 | ], |
| 303 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 304 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 305 | ":native_shared_lib_for_both", |
| 306 | ":native_shared_lib_for_lib64", |
| 307 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 308 | ], |
| 309 | "//conditions:default": [], |
| 310 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 311 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 312 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 313 | }), |
| 314 | }}) |
| 315 | } |
| 316 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 317 | func TestApexBundleCompileMultilibFirstAndDefaultValue(t *testing.T) { |
| 318 | expectedBazelTargets := []string{ |
| 319 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 320 | "native_shared_libs_32": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 321 | "//build/bazel/platforms/arch:arm": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 322 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 323 | ":native_shared_lib_for_both", |
| 324 | ":native_shared_lib_for_lib32", |
| 325 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 326 | ], |
| 327 | "//build/bazel/platforms/arch:x86": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 328 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 329 | ":native_shared_lib_for_both", |
| 330 | ":native_shared_lib_for_lib32", |
| 331 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 332 | ], |
| 333 | "//conditions:default": [], |
| 334 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 335 | "native_shared_libs_64": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 336 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 337 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 338 | ":native_shared_lib_for_both", |
| 339 | ":native_shared_lib_for_lib64", |
| 340 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 341 | ], |
| 342 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 343 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 344 | ":native_shared_lib_for_both", |
| 345 | ":native_shared_lib_for_lib64", |
| 346 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 347 | ], |
| 348 | "//conditions:default": [], |
| 349 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 350 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 351 | "manifest": `"apex_manifest.json"`, |
| 352 | }), |
| 353 | } |
| 354 | |
| 355 | // "first" is the default value of compile_multilib prop so `compile_multilib_: "first"` and unset compile_multilib |
| 356 | // should result to the same bp2build output |
| 357 | compileMultiLibPropValues := []string{`compile_multilib: "first",`, ""} |
| 358 | for _, compileMultiLibProp := range compileMultiLibPropValues { |
| 359 | descriptionSuffix := compileMultiLibProp |
| 360 | if descriptionSuffix == "" { |
| 361 | descriptionSuffix = "compile_multilib unset" |
| 362 | } |
| 363 | runApexTestCase(t, Bp2buildTestCase{ |
| 364 | Description: "apex - example with " + compileMultiLibProp, |
| 365 | ModuleTypeUnderTest: "apex", |
| 366 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 367 | Filesystem: map[string]string{ |
| 368 | "system/sepolicy/apex/Android.bp": ` |
| 369 | filegroup { |
| 370 | name: "com.android.apogee-file_contexts", |
| 371 | srcs: [ "apogee-file_contexts", ], |
| 372 | bazel_module: { bp2build_available: false }, |
| 373 | } |
| 374 | `, |
| 375 | }, |
| 376 | Blueprint: createMultilibBlueprint(compileMultiLibProp), |
| 377 | ExpectedBazelTargets: expectedBazelTargets, |
| 378 | }) |
| 379 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | func TestApexBundleCompileMultilib32(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 383 | runApexTestCase(t, Bp2buildTestCase{ |
| 384 | Description: "apex - example with compile_multilib=32", |
| 385 | ModuleTypeUnderTest: "apex", |
| 386 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 387 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 388 | "system/sepolicy/apex/Android.bp": ` |
| 389 | filegroup { |
| 390 | name: "com.android.apogee-file_contexts", |
| 391 | srcs: [ "apogee-file_contexts", ], |
| 392 | bazel_module: { bp2build_available: false }, |
| 393 | } |
| 394 | `, |
| 395 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 396 | Blueprint: createMultilibBlueprint(`compile_multilib: "32",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 397 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 398 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 399 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 400 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 401 | ":native_shared_lib_for_both", |
| 402 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 403 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 404 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 405 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 406 | "//conditions:default": [], |
| 407 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 408 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 409 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 410 | }), |
| 411 | }}) |
| 412 | } |
| 413 | |
| 414 | func TestApexBundleCompileMultilib64(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 415 | runApexTestCase(t, Bp2buildTestCase{ |
| 416 | Description: "apex - example with compile_multilib=64", |
| 417 | ModuleTypeUnderTest: "apex", |
| 418 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 419 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 420 | "system/sepolicy/apex/Android.bp": ` |
| 421 | filegroup { |
| 422 | name: "com.android.apogee-file_contexts", |
| 423 | srcs: [ "apogee-file_contexts", ], |
| 424 | bazel_module: { bp2build_available: false }, |
| 425 | } |
| 426 | `, |
| 427 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 428 | Blueprint: createMultilibBlueprint(`compile_multilib: "64",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 429 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 430 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 431 | "native_shared_libs_64": `select({ |
| 432 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 433 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 434 | ":native_shared_lib_for_both", |
| 435 | ":native_shared_lib_for_lib64", |
| 436 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 437 | ], |
| 438 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 439 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 440 | ":native_shared_lib_for_both", |
| 441 | ":native_shared_lib_for_lib64", |
| 442 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 443 | ], |
| 444 | "//conditions:default": [], |
| 445 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 446 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 447 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 448 | }), |
| 449 | }}) |
| 450 | } |
| 451 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 452 | func createMultilibBlueprint(compile_multilib string) string { |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 453 | return fmt.Sprintf(` |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 454 | cc_library { |
| 455 | name: "native_shared_lib_for_both", |
| 456 | bazel_module: { bp2build_available: false }, |
| 457 | } |
| 458 | |
| 459 | cc_library { |
| 460 | name: "native_shared_lib_for_first", |
| 461 | bazel_module: { bp2build_available: false }, |
| 462 | } |
| 463 | |
| 464 | cc_library { |
| 465 | name: "native_shared_lib_for_lib32", |
| 466 | bazel_module: { bp2build_available: false }, |
| 467 | } |
| 468 | |
| 469 | cc_library { |
| 470 | name: "native_shared_lib_for_lib64", |
| 471 | bazel_module: { bp2build_available: false }, |
| 472 | } |
| 473 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 474 | cc_library { |
| 475 | name: "unnested_native_shared_lib", |
| 476 | bazel_module: { bp2build_available: false }, |
| 477 | } |
| 478 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 479 | apex { |
| 480 | name: "com.android.apogee", |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 481 | %s |
| 482 | native_shared_libs: ["unnested_native_shared_lib"], |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 483 | multilib: { |
| 484 | both: { |
| 485 | native_shared_libs: [ |
| 486 | "native_shared_lib_for_both", |
| 487 | ], |
| 488 | }, |
| 489 | first: { |
| 490 | native_shared_libs: [ |
| 491 | "native_shared_lib_for_first", |
| 492 | ], |
| 493 | }, |
| 494 | lib32: { |
| 495 | native_shared_libs: [ |
| 496 | "native_shared_lib_for_lib32", |
| 497 | ], |
| 498 | }, |
| 499 | lib64: { |
| 500 | native_shared_libs: [ |
| 501 | "native_shared_lib_for_lib64", |
| 502 | ], |
| 503 | }, |
| 504 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 505 | }`, compile_multilib) |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 508 | func TestApexBundleDefaultPropertyValues(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 509 | runApexTestCase(t, Bp2buildTestCase{ |
| 510 | Description: "apex - default property values", |
| 511 | ModuleTypeUnderTest: "apex", |
| 512 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 513 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 514 | "system/sepolicy/apex/Android.bp": ` |
| 515 | filegroup { |
| 516 | name: "com.android.apogee-file_contexts", |
| 517 | srcs: [ "apogee-file_contexts", ], |
| 518 | bazel_module: { bp2build_available: false }, |
| 519 | } |
| 520 | `, |
| 521 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 522 | Blueprint: ` |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 523 | apex { |
| 524 | name: "com.android.apogee", |
| 525 | manifest: "apogee_manifest.json", |
| 526 | } |
| 527 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 528 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 529 | "manifest": `"apogee_manifest.json"`, |
| 530 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 531 | }), |
| 532 | }}) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 533 | } |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 534 | |
| 535 | func TestApexBundleHasBazelModuleProps(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 536 | runApexTestCase(t, Bp2buildTestCase{ |
| 537 | Description: "apex - has bazel module props", |
| 538 | ModuleTypeUnderTest: "apex", |
| 539 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 540 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 541 | "system/sepolicy/apex/Android.bp": ` |
| 542 | filegroup { |
| 543 | name: "apogee-file_contexts", |
| 544 | srcs: [ "apogee-file_contexts", ], |
| 545 | bazel_module: { bp2build_available: false }, |
| 546 | } |
| 547 | `, |
| 548 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 549 | Blueprint: ` |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 550 | apex { |
| 551 | name: "apogee", |
| 552 | manifest: "manifest.json", |
| 553 | bazel_module: { bp2build_available: true }, |
| 554 | } |
| 555 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 556 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 557 | "manifest": `"manifest.json"`, |
| 558 | "file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 559 | }), |
| 560 | }}) |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 561 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 562 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 563 | func TestBp2BuildOverrideApex(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 564 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 565 | Description: "override_apex", |
| 566 | ModuleTypeUnderTest: "override_apex", |
| 567 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 568 | Filesystem: map[string]string{}, |
| 569 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 570 | apex_key { |
| 571 | name: "com.android.apogee.key", |
| 572 | public_key: "com.android.apogee.avbpubkey", |
| 573 | private_key: "com.android.apogee.pem", |
| 574 | bazel_module: { bp2build_available: false }, |
| 575 | } |
| 576 | |
| 577 | android_app_certificate { |
| 578 | name: "com.android.apogee.certificate", |
| 579 | certificate: "com.android.apogee", |
| 580 | bazel_module: { bp2build_available: false }, |
| 581 | } |
| 582 | |
| 583 | cc_library { |
| 584 | name: "native_shared_lib_1", |
| 585 | bazel_module: { bp2build_available: false }, |
| 586 | } |
| 587 | |
| 588 | cc_library { |
| 589 | name: "native_shared_lib_2", |
| 590 | bazel_module: { bp2build_available: false }, |
| 591 | } |
| 592 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 593 | prebuilt_etc { |
| 594 | name: "prebuilt_1", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 595 | bazel_module: { bp2build_available: false }, |
| 596 | } |
| 597 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 598 | prebuilt_etc { |
| 599 | name: "prebuilt_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 600 | bazel_module: { bp2build_available: false }, |
| 601 | } |
| 602 | |
| 603 | filegroup { |
| 604 | name: "com.android.apogee-file_contexts", |
| 605 | srcs: [ |
| 606 | "com.android.apogee-file_contexts", |
| 607 | ], |
| 608 | bazel_module: { bp2build_available: false }, |
| 609 | } |
| 610 | |
| 611 | cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } } |
| 612 | sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } } |
| 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 | ], |
| 637 | bazel_module: { bp2build_available: false }, |
| 638 | } |
| 639 | |
| 640 | apex_key { |
| 641 | name: "com.google.android.apogee.key", |
| 642 | public_key: "com.google.android.apogee.avbpubkey", |
| 643 | private_key: "com.google.android.apogee.pem", |
| 644 | bazel_module: { bp2build_available: false }, |
| 645 | } |
| 646 | |
| 647 | android_app_certificate { |
| 648 | name: "com.google.android.apogee.certificate", |
| 649 | certificate: "com.google.android.apogee", |
| 650 | bazel_module: { bp2build_available: false }, |
| 651 | } |
| 652 | |
| 653 | override_apex { |
| 654 | name: "com.google.android.apogee", |
| 655 | base: ":com.android.apogee", |
| 656 | key: "com.google.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 657 | certificate: ":com.google.android.apogee.certificate", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 658 | prebuilts: [], |
| 659 | compressible: true, |
| 660 | } |
| 661 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 662 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 663 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 664 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
| 665 | "binaries": `[ |
| 666 | ":cc_binary_1", |
| 667 | ":sh_binary_2", |
| 668 | ]`, |
| 669 | "certificate": `":com.google.android.apogee.certificate"`, |
| 670 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 671 | "installable": "False", |
| 672 | "key": `":com.google.android.apogee.key"`, |
| 673 | "manifest": `"apogee_manifest.json"`, |
| 674 | "min_sdk_version": `"29"`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame^] | 675 | "native_shared_libs_32": `select({ |
| 676 | "//build/bazel/platforms/arch:arm": [ |
| 677 | ":native_shared_lib_1", |
| 678 | ":native_shared_lib_2", |
| 679 | ], |
| 680 | "//build/bazel/platforms/arch:x86": [ |
| 681 | ":native_shared_lib_1", |
| 682 | ":native_shared_lib_2", |
| 683 | ], |
| 684 | "//conditions:default": [], |
| 685 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 686 | "native_shared_libs_64": `select({ |
| 687 | "//build/bazel/platforms/arch:arm64": [ |
| 688 | ":native_shared_lib_1", |
| 689 | ":native_shared_lib_2", |
| 690 | ], |
| 691 | "//build/bazel/platforms/arch:x86_64": [ |
| 692 | ":native_shared_lib_1", |
| 693 | ":native_shared_lib_2", |
| 694 | ], |
| 695 | "//conditions:default": [], |
| 696 | })`, |
| 697 | "prebuilts": `[]`, |
| 698 | "updatable": "False", |
| 699 | "compressible": "True", |
| 700 | }), |
| 701 | }}) |
| 702 | } |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 703 | |
| 704 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 705 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 706 | Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp", |
| 707 | ModuleTypeUnderTest: "override_apex", |
| 708 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 709 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 710 | "system/sepolicy/apex/Android.bp": ` |
| 711 | filegroup { |
| 712 | name: "com.android.apogee-file_contexts", |
| 713 | srcs: [ "apogee-file_contexts", ], |
| 714 | bazel_module: { bp2build_available: false }, |
| 715 | }`, |
| 716 | "a/b/Android.bp": ` |
| 717 | apex { |
| 718 | name: "com.android.apogee", |
| 719 | bazel_module: { bp2build_available: false }, |
| 720 | } |
| 721 | `, |
| 722 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 723 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 724 | override_apex { |
| 725 | name: "com.google.android.apogee", |
| 726 | base: ":com.android.apogee", |
| 727 | } |
| 728 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 729 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 730 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 731 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 732 | "manifest": `"//a/b:apex_manifest.json"`, |
| 733 | }), |
| 734 | }}) |
| 735 | } |
| 736 | |
| 737 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 738 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 739 | Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp", |
| 740 | ModuleTypeUnderTest: "override_apex", |
| 741 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 742 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 743 | "system/sepolicy/apex/Android.bp": ` |
| 744 | filegroup { |
| 745 | name: "com.android.apogee-file_contexts", |
| 746 | srcs: [ "apogee-file_contexts", ], |
| 747 | bazel_module: { bp2build_available: false }, |
| 748 | }`, |
| 749 | "a/b/Android.bp": ` |
| 750 | apex { |
| 751 | name: "com.android.apogee", |
| 752 | manifest: "apogee_manifest.json", |
| 753 | bazel_module: { bp2build_available: false }, |
| 754 | } |
| 755 | `, |
| 756 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 757 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 758 | override_apex { |
| 759 | name: "com.google.android.apogee", |
| 760 | base: ":com.android.apogee", |
| 761 | } |
| 762 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 763 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 764 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 765 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 766 | "manifest": `"//a/b:apogee_manifest.json"`, |
| 767 | }), |
| 768 | }}) |
| 769 | } |
| 770 | |
| 771 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 772 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 773 | Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp", |
| 774 | ModuleTypeUnderTest: "override_apex", |
| 775 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 776 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 777 | "system/sepolicy/apex/Android.bp": ` |
| 778 | filegroup { |
| 779 | name: "com.android.apogee-file_contexts", |
| 780 | srcs: [ "apogee-file_contexts", ], |
| 781 | bazel_module: { bp2build_available: false }, |
| 782 | }`, |
| 783 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 784 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 785 | apex { |
| 786 | name: "com.android.apogee", |
| 787 | bazel_module: { bp2build_available: false }, |
| 788 | } |
| 789 | |
| 790 | override_apex { |
| 791 | name: "com.google.android.apogee", |
| 792 | base: ":com.android.apogee", |
| 793 | } |
| 794 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 795 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 796 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 797 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 798 | "manifest": `"apex_manifest.json"`, |
| 799 | }), |
| 800 | }}) |
| 801 | } |
| 802 | |
| 803 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 804 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 805 | Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp", |
| 806 | ModuleTypeUnderTest: "override_apex", |
| 807 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 808 | Filesystem: map[string]string{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 809 | "system/sepolicy/apex/Android.bp": ` |
| 810 | filegroup { |
| 811 | name: "com.android.apogee-file_contexts", |
| 812 | srcs: [ "apogee-file_contexts", ], |
| 813 | bazel_module: { bp2build_available: false }, |
| 814 | }`, |
| 815 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 816 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 817 | apex { |
| 818 | name: "com.android.apogee", |
| 819 | manifest: "apogee_manifest.json", |
| 820 | bazel_module: { bp2build_available: false }, |
| 821 | } |
| 822 | |
| 823 | override_apex { |
| 824 | name: "com.google.android.apogee", |
| 825 | base: ":com.android.apogee", |
| 826 | } |
| 827 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 828 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 829 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 830 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 831 | "manifest": `"apogee_manifest.json"`, |
| 832 | }), |
| 833 | }}) |
| 834 | } |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 835 | |
| 836 | func TestApexBundleSimple_packageNameOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 837 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 838 | Description: "override_apex - override package name", |
| 839 | ModuleTypeUnderTest: "override_apex", |
| 840 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 841 | Filesystem: map[string]string{ |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 842 | "system/sepolicy/apex/Android.bp": ` |
| 843 | filegroup { |
| 844 | name: "com.android.apogee-file_contexts", |
| 845 | srcs: [ "apogee-file_contexts", ], |
| 846 | bazel_module: { bp2build_available: false }, |
| 847 | }`, |
| 848 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 849 | Blueprint: ` |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 850 | apex { |
| 851 | name: "com.android.apogee", |
| 852 | bazel_module: { bp2build_available: false }, |
| 853 | } |
| 854 | |
| 855 | override_apex { |
| 856 | name: "com.google.android.apogee", |
| 857 | base: ":com.android.apogee", |
| 858 | package_name: "com.google.android.apogee", |
| 859 | } |
| 860 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 861 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 862 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 863 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 864 | "manifest": `"apex_manifest.json"`, |
| 865 | "package_name": `"com.google.android.apogee"`, |
| 866 | }), |
| 867 | }}) |
| 868 | } |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 869 | |
| 870 | func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 871 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 872 | Description: "override_apex - no override", |
| 873 | ModuleTypeUnderTest: "override_apex", |
| 874 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 875 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 876 | "system/sepolicy/apex/Android.bp": ` |
| 877 | filegroup { |
| 878 | name: "com.android.apogee-file_contexts", |
| 879 | srcs: [ "apogee-file_contexts", ], |
| 880 | bazel_module: { bp2build_available: false }, |
| 881 | }`, |
| 882 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 883 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 884 | prebuilt_etc { |
| 885 | name: "prebuilt_file", |
| 886 | bazel_module: { bp2build_available: false }, |
| 887 | } |
| 888 | |
| 889 | apex { |
| 890 | name: "com.android.apogee", |
| 891 | bazel_module: { bp2build_available: false }, |
| 892 | prebuilts: ["prebuilt_file"] |
| 893 | } |
| 894 | |
| 895 | override_apex { |
| 896 | name: "com.google.android.apogee", |
| 897 | base: ":com.android.apogee", |
| 898 | } |
| 899 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 900 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 901 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 902 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 903 | "manifest": `"apex_manifest.json"`, |
| 904 | "prebuilts": `[":prebuilt_file"]`, |
| 905 | }), |
| 906 | }}) |
| 907 | } |
| 908 | |
| 909 | func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 910 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 911 | Description: "override_apex - ooverride", |
| 912 | ModuleTypeUnderTest: "override_apex", |
| 913 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 914 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 915 | "system/sepolicy/apex/Android.bp": ` |
| 916 | filegroup { |
| 917 | name: "com.android.apogee-file_contexts", |
| 918 | srcs: [ "apogee-file_contexts", ], |
| 919 | bazel_module: { bp2build_available: false }, |
| 920 | }`, |
| 921 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 922 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 923 | prebuilt_etc { |
| 924 | name: "prebuilt_file", |
| 925 | bazel_module: { bp2build_available: false }, |
| 926 | } |
| 927 | |
| 928 | prebuilt_etc { |
| 929 | name: "prebuilt_file2", |
| 930 | bazel_module: { bp2build_available: false }, |
| 931 | } |
| 932 | |
| 933 | apex { |
| 934 | name: "com.android.apogee", |
| 935 | bazel_module: { bp2build_available: false }, |
| 936 | prebuilts: ["prebuilt_file"] |
| 937 | } |
| 938 | |
| 939 | override_apex { |
| 940 | name: "com.google.android.apogee", |
| 941 | base: ":com.android.apogee", |
| 942 | prebuilts: ["prebuilt_file2"] |
| 943 | } |
| 944 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 945 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 946 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 947 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 948 | "manifest": `"apex_manifest.json"`, |
| 949 | "prebuilts": `[":prebuilt_file2"]`, |
| 950 | }), |
| 951 | }}) |
| 952 | } |
| 953 | |
| 954 | func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 955 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 956 | Description: "override_apex - override with empty list", |
| 957 | ModuleTypeUnderTest: "override_apex", |
| 958 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 959 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 960 | "system/sepolicy/apex/Android.bp": ` |
| 961 | filegroup { |
| 962 | name: "com.android.apogee-file_contexts", |
| 963 | srcs: [ "apogee-file_contexts", ], |
| 964 | bazel_module: { bp2build_available: false }, |
| 965 | }`, |
| 966 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 967 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 968 | prebuilt_etc { |
| 969 | name: "prebuilt_file", |
| 970 | bazel_module: { bp2build_available: false }, |
| 971 | } |
| 972 | |
| 973 | apex { |
| 974 | name: "com.android.apogee", |
| 975 | bazel_module: { bp2build_available: false }, |
| 976 | prebuilts: ["prebuilt_file"] |
| 977 | } |
| 978 | |
| 979 | override_apex { |
| 980 | name: "com.google.android.apogee", |
| 981 | base: ":com.android.apogee", |
| 982 | prebuilts: [], |
| 983 | } |
| 984 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 985 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 986 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 987 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 988 | "manifest": `"apex_manifest.json"`, |
| 989 | "prebuilts": `[]`, |
| 990 | }), |
| 991 | }}) |
| 992 | } |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 993 | |
| 994 | func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 995 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 996 | Description: "override_apex - logging_parent - no override", |
| 997 | ModuleTypeUnderTest: "override_apex", |
| 998 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 999 | Filesystem: map[string]string{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1000 | "system/sepolicy/apex/Android.bp": ` |
| 1001 | filegroup { |
| 1002 | name: "com.android.apogee-file_contexts", |
| 1003 | srcs: [ "apogee-file_contexts", ], |
| 1004 | bazel_module: { bp2build_available: false }, |
| 1005 | }`, |
| 1006 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1007 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1008 | apex { |
| 1009 | name: "com.android.apogee", |
| 1010 | bazel_module: { bp2build_available: false }, |
| 1011 | logging_parent: "foo.bar.baz", |
| 1012 | } |
| 1013 | |
| 1014 | override_apex { |
| 1015 | name: "com.google.android.apogee", |
| 1016 | base: ":com.android.apogee", |
| 1017 | } |
| 1018 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1019 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1020 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1021 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1022 | "manifest": `"apex_manifest.json"`, |
| 1023 | "logging_parent": `"foo.bar.baz"`, |
| 1024 | }), |
| 1025 | }}) |
| 1026 | } |
| 1027 | |
| 1028 | func TestApexBundleSimple_LoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1029 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1030 | Description: "override_apex - logging_parent - override", |
| 1031 | ModuleTypeUnderTest: "override_apex", |
| 1032 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1033 | Filesystem: map[string]string{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1034 | "system/sepolicy/apex/Android.bp": ` |
| 1035 | filegroup { |
| 1036 | name: "com.android.apogee-file_contexts", |
| 1037 | srcs: [ "apogee-file_contexts", ], |
| 1038 | bazel_module: { bp2build_available: false }, |
| 1039 | }`, |
| 1040 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1041 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1042 | apex { |
| 1043 | name: "com.android.apogee", |
| 1044 | bazel_module: { bp2build_available: false }, |
| 1045 | logging_parent: "foo.bar.baz", |
| 1046 | } |
| 1047 | |
| 1048 | override_apex { |
| 1049 | name: "com.google.android.apogee", |
| 1050 | base: ":com.android.apogee", |
| 1051 | logging_parent: "foo.bar.baz.override", |
| 1052 | } |
| 1053 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1054 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1055 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1056 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 1057 | "manifest": `"apex_manifest.json"`, |
| 1058 | "logging_parent": `"foo.bar.baz.override"`, |
| 1059 | }), |
| 1060 | }}) |
| 1061 | } |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1062 | |
| 1063 | func TestBp2BuildOverrideApex_CertificateNil(t *testing.T) { |
| 1064 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1065 | Description: "override_apex - don't set default certificate", |
| 1066 | ModuleTypeUnderTest: "override_apex", |
| 1067 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1068 | Filesystem: map[string]string{}, |
| 1069 | Blueprint: ` |
| 1070 | android_app_certificate { |
| 1071 | name: "com.android.apogee.certificate", |
| 1072 | certificate: "com.android.apogee", |
| 1073 | bazel_module: { bp2build_available: false }, |
| 1074 | } |
| 1075 | |
| 1076 | filegroup { |
| 1077 | name: "com.android.apogee-file_contexts", |
| 1078 | srcs: [ |
| 1079 | "com.android.apogee-file_contexts", |
| 1080 | ], |
| 1081 | bazel_module: { bp2build_available: false }, |
| 1082 | } |
| 1083 | |
| 1084 | apex { |
| 1085 | name: "com.android.apogee", |
| 1086 | manifest: "apogee_manifest.json", |
| 1087 | file_contexts: ":com.android.apogee-file_contexts", |
| 1088 | certificate: ":com.android.apogee.certificate", |
| 1089 | bazel_module: { bp2build_available: false }, |
| 1090 | } |
| 1091 | |
| 1092 | override_apex { |
| 1093 | name: "com.google.android.apogee", |
| 1094 | base: ":com.android.apogee", |
| 1095 | // certificate is deliberately omitted, and not converted to bazel, |
| 1096 | // because the overridden apex shouldn't be using the base apex's cert. |
| 1097 | } |
| 1098 | `, |
| 1099 | ExpectedBazelTargets: []string{ |
| 1100 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
| 1101 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1102 | "manifest": `"apogee_manifest.json"`, |
| 1103 | }), |
| 1104 | }}) |
| 1105 | } |
| 1106 | |
| 1107 | func TestApexCertificateIsModule(t *testing.T) { |
| 1108 | runApexTestCase(t, Bp2buildTestCase{ |
| 1109 | Description: "apex - certificate is module", |
| 1110 | ModuleTypeUnderTest: "apex", |
| 1111 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1112 | Filesystem: map[string]string{}, |
| 1113 | Blueprint: ` |
| 1114 | android_app_certificate { |
| 1115 | name: "com.android.apogee.certificate", |
| 1116 | certificate: "com.android.apogee", |
| 1117 | bazel_module: { bp2build_available: false }, |
| 1118 | } |
| 1119 | |
| 1120 | apex { |
| 1121 | name: "com.android.apogee", |
| 1122 | manifest: "apogee_manifest.json", |
| 1123 | file_contexts: ":com.android.apogee-file_contexts", |
| 1124 | certificate: ":com.android.apogee.certificate", |
| 1125 | } |
| 1126 | ` + simpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"), |
| 1127 | ExpectedBazelTargets: []string{ |
| 1128 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 1129 | "certificate": `":com.android.apogee.certificate"`, |
| 1130 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1131 | "manifest": `"apogee_manifest.json"`, |
| 1132 | }), |
| 1133 | }}) |
| 1134 | } |
| 1135 | |
| 1136 | func TestApexCertificateIsSrc(t *testing.T) { |
| 1137 | runApexTestCase(t, Bp2buildTestCase{ |
| 1138 | Description: "apex - certificate is src", |
| 1139 | ModuleTypeUnderTest: "apex", |
| 1140 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 1141 | Filesystem: map[string]string{}, |
| 1142 | Blueprint: ` |
| 1143 | apex { |
| 1144 | name: "com.android.apogee", |
| 1145 | manifest: "apogee_manifest.json", |
| 1146 | file_contexts: ":com.android.apogee-file_contexts", |
| 1147 | certificate: "com.android.apogee.certificate", |
| 1148 | } |
| 1149 | ` + simpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"), |
| 1150 | ExpectedBazelTargets: []string{ |
| 1151 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 1152 | "certificate_name": `"com.android.apogee.certificate"`, |
| 1153 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1154 | "manifest": `"apogee_manifest.json"`, |
| 1155 | }), |
| 1156 | }}) |
| 1157 | } |
| 1158 | |
| 1159 | func TestBp2BuildOverrideApex_CertificateIsModule(t *testing.T) { |
| 1160 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1161 | Description: "override_apex - certificate is module", |
| 1162 | ModuleTypeUnderTest: "override_apex", |
| 1163 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1164 | Filesystem: map[string]string{}, |
| 1165 | Blueprint: ` |
| 1166 | android_app_certificate { |
| 1167 | name: "com.android.apogee.certificate", |
| 1168 | certificate: "com.android.apogee", |
| 1169 | bazel_module: { bp2build_available: false }, |
| 1170 | } |
| 1171 | |
| 1172 | filegroup { |
| 1173 | name: "com.android.apogee-file_contexts", |
| 1174 | srcs: [ |
| 1175 | "com.android.apogee-file_contexts", |
| 1176 | ], |
| 1177 | bazel_module: { bp2build_available: false }, |
| 1178 | } |
| 1179 | |
| 1180 | apex { |
| 1181 | name: "com.android.apogee", |
| 1182 | manifest: "apogee_manifest.json", |
| 1183 | file_contexts: ":com.android.apogee-file_contexts", |
| 1184 | certificate: ":com.android.apogee.certificate", |
| 1185 | bazel_module: { bp2build_available: false }, |
| 1186 | } |
| 1187 | |
| 1188 | android_app_certificate { |
| 1189 | name: "com.google.android.apogee.certificate", |
| 1190 | certificate: "com.google.android.apogee", |
| 1191 | bazel_module: { bp2build_available: false }, |
| 1192 | } |
| 1193 | |
| 1194 | override_apex { |
| 1195 | name: "com.google.android.apogee", |
| 1196 | base: ":com.android.apogee", |
| 1197 | certificate: ":com.google.android.apogee.certificate", |
| 1198 | } |
| 1199 | `, |
| 1200 | ExpectedBazelTargets: []string{ |
| 1201 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
| 1202 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1203 | "certificate": `":com.google.android.apogee.certificate"`, |
| 1204 | "manifest": `"apogee_manifest.json"`, |
| 1205 | }), |
| 1206 | }}) |
| 1207 | } |
| 1208 | |
| 1209 | func TestBp2BuildOverrideApex_CertificateIsSrc(t *testing.T) { |
| 1210 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1211 | Description: "override_apex - certificate is src", |
| 1212 | ModuleTypeUnderTest: "override_apex", |
| 1213 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1214 | Filesystem: map[string]string{}, |
| 1215 | Blueprint: ` |
| 1216 | android_app_certificate { |
| 1217 | name: "com.android.apogee.certificate", |
| 1218 | certificate: "com.android.apogee", |
| 1219 | bazel_module: { bp2build_available: false }, |
| 1220 | } |
| 1221 | |
| 1222 | filegroup { |
| 1223 | name: "com.android.apogee-file_contexts", |
| 1224 | srcs: [ |
| 1225 | "com.android.apogee-file_contexts", |
| 1226 | ], |
| 1227 | bazel_module: { bp2build_available: false }, |
| 1228 | } |
| 1229 | |
| 1230 | apex { |
| 1231 | name: "com.android.apogee", |
| 1232 | manifest: "apogee_manifest.json", |
| 1233 | file_contexts: ":com.android.apogee-file_contexts", |
| 1234 | certificate: ":com.android.apogee.certificate", |
| 1235 | bazel_module: { bp2build_available: false }, |
| 1236 | } |
| 1237 | |
| 1238 | override_apex { |
| 1239 | name: "com.google.android.apogee", |
| 1240 | base: ":com.android.apogee", |
| 1241 | certificate: "com.google.android.apogee.certificate", |
| 1242 | } |
| 1243 | `, |
| 1244 | ExpectedBazelTargets: []string{ |
| 1245 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
| 1246 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1247 | "certificate_name": `"com.google.android.apogee.certificate"`, |
| 1248 | "manifest": `"apogee_manifest.json"`, |
| 1249 | }), |
| 1250 | }}) |
| 1251 | } |