Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 1 | // Copyright (C) 2021 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package apex |
| 16 | |
| 17 | import ( |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 18 | "fmt" |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 19 | "sort" |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 20 | "strings" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 21 | "testing" |
| 22 | |
| 23 | "android/soong/android" |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame^] | 24 | "android/soong/dexpreopt" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 25 | "android/soong/java" |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 26 | |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 27 | "github.com/google/blueprint/proptools" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 28 | ) |
| 29 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 30 | // Contains tests for bootclasspath_fragment logic from java/bootclasspath_fragment.go as the ART |
| 31 | // bootclasspath_fragment requires modules from the ART apex. |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 32 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 33 | var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers( |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 34 | java.PrepareForTestWithDexpreopt, |
| 35 | PrepareForTestWithApexBuildComponents, |
| 36 | ) |
| 37 | |
| 38 | // Some additional files needed for the art apex. |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame^] | 39 | var prepareForTestWithArtApex = android.GroupFixturePreparers( |
| 40 | android.FixtureMergeMockFs(android.MockFS{ |
| 41 | "com.android.art.avbpubkey": nil, |
| 42 | "com.android.art.pem": nil, |
| 43 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 44 | }), |
| 45 | dexpreopt.FixtureSetBootImageProfiles("art/build/boot/boot-image-profile.txt"), |
| 46 | ) |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 47 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 48 | func TestBootclasspathFragments(t *testing.T) { |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 49 | result := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 50 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 51 | // Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath. |
Paul Duffin | 60264a0 | 2021-04-12 20:02:36 +0100 | [diff] [blame] | 52 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo", "platform:bar"), |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 53 | prepareForTestWithArtApex, |
| 54 | |
| 55 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 56 | java.FixtureWithLastReleaseApis("foo"), |
Paul Duffin | 34d433a | 2021-03-09 14:13:25 +0000 | [diff] [blame] | 57 | ).RunTestWithBp(t, ` |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 58 | java_sdk_library { |
| 59 | name: "foo", |
| 60 | srcs: ["b.java"], |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | java_library { |
| 64 | name: "bar", |
| 65 | srcs: ["b.java"], |
| 66 | installable: true, |
| 67 | } |
| 68 | |
| 69 | apex { |
| 70 | name: "com.android.art", |
| 71 | key: "com.android.art.key", |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 72 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 73 | java_libs: [ |
| 74 | "baz", |
| 75 | "quuz", |
| 76 | ], |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 77 | updatable: false, |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | apex_key { |
| 81 | name: "com.android.art.key", |
| 82 | public_key: "com.android.art.avbpubkey", |
| 83 | private_key: "com.android.art.pem", |
| 84 | } |
| 85 | |
| 86 | java_library { |
| 87 | name: "baz", |
| 88 | apex_available: [ |
| 89 | "com.android.art", |
| 90 | ], |
| 91 | srcs: ["b.java"], |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 92 | compile_dex: true, |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | java_library { |
| 96 | name: "quuz", |
| 97 | apex_available: [ |
| 98 | "com.android.art", |
| 99 | ], |
| 100 | srcs: ["b.java"], |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 101 | compile_dex: true, |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 102 | } |
Paul Duffin | 5bbfef8 | 2021-01-30 12:57:26 +0000 | [diff] [blame] | 103 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 104 | bootclasspath_fragment { |
| 105 | name: "art-bootclasspath-fragment", |
Paul Duffin | 5bbfef8 | 2021-01-30 12:57:26 +0000 | [diff] [blame] | 106 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame] | 107 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 108 | contents: ["baz", "quuz"], |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 109 | apex_available: [ |
| 110 | "com.android.art", |
| 111 | ], |
Paul Duffin | 5bbfef8 | 2021-01-30 12:57:26 +0000 | [diff] [blame] | 112 | } |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 113 | `, |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 114 | ) |
| 115 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 116 | // Make sure that the art-bootclasspath-fragment is using the correct configuration. |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 117 | checkBootclasspathFragment(t, result, "art-bootclasspath-fragment", "android_common_apex10000", |
| 118 | "com.android.art:baz,com.android.art:quuz", ` |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 119 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.art |
| 120 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.oat |
| 121 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.vdex |
| 122 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.art |
| 123 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.oat |
| 124 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm/boot-quuz.vdex |
| 125 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.art |
| 126 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.oat |
| 127 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.vdex |
| 128 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.art |
| 129 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.oat |
| 130 | test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot-quuz.vdex |
| 131 | `) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 134 | func TestBootclasspathFragments_FragmentDependency(t *testing.T) { |
| 135 | result := android.GroupFixturePreparers( |
| 136 | prepareForTestWithBootclasspathFragment, |
| 137 | // Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 138 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 139 | java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"), |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 140 | prepareForTestWithArtApex, |
| 141 | |
| 142 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 143 | java.FixtureWithLastReleaseApis("foo", "baz"), |
| 144 | ).RunTestWithBp(t, ` |
| 145 | java_sdk_library { |
| 146 | name: "foo", |
| 147 | srcs: ["b.java"], |
| 148 | shared_library: false, |
| 149 | public: { |
| 150 | enabled: true, |
| 151 | }, |
| 152 | system: { |
| 153 | enabled: true, |
| 154 | }, |
| 155 | } |
| 156 | |
| 157 | java_library { |
| 158 | name: "bar", |
| 159 | srcs: ["b.java"], |
| 160 | installable: true, |
| 161 | } |
| 162 | |
| 163 | apex { |
| 164 | name: "com.android.art", |
| 165 | key: "com.android.art.key", |
| 166 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 167 | updatable: false, |
| 168 | } |
| 169 | |
| 170 | apex_key { |
| 171 | name: "com.android.art.key", |
| 172 | public_key: "com.android.art.avbpubkey", |
| 173 | private_key: "com.android.art.pem", |
| 174 | } |
| 175 | |
| 176 | java_sdk_library { |
| 177 | name: "baz", |
| 178 | apex_available: [ |
| 179 | "com.android.art", |
| 180 | ], |
| 181 | srcs: ["b.java"], |
| 182 | shared_library: false, |
| 183 | public: { |
| 184 | enabled: true, |
| 185 | }, |
| 186 | system: { |
| 187 | enabled: true, |
| 188 | }, |
| 189 | test: { |
| 190 | enabled: true, |
| 191 | }, |
| 192 | } |
| 193 | |
| 194 | java_library { |
| 195 | name: "quuz", |
| 196 | apex_available: [ |
| 197 | "com.android.art", |
| 198 | ], |
| 199 | srcs: ["b.java"], |
| 200 | compile_dex: true, |
| 201 | } |
| 202 | |
| 203 | bootclasspath_fragment { |
| 204 | name: "art-bootclasspath-fragment", |
| 205 | image_name: "art", |
| 206 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 207 | contents: ["baz", "quuz"], |
| 208 | apex_available: [ |
| 209 | "com.android.art", |
| 210 | ], |
| 211 | } |
| 212 | |
| 213 | bootclasspath_fragment { |
| 214 | name: "other-bootclasspath-fragment", |
| 215 | contents: ["foo", "bar"], |
| 216 | fragments: [ |
| 217 | { |
| 218 | apex: "com.android.art", |
| 219 | module: "art-bootclasspath-fragment", |
| 220 | }, |
| 221 | ], |
| 222 | } |
| 223 | `, |
| 224 | ) |
| 225 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 226 | checkAPIScopeStubs := func(message string, info java.HiddenAPIInfo, apiScope *java.HiddenAPIScope, expectedPaths ...string) { |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 227 | t.Helper() |
Paul Duffin | 280a31a | 2021-06-27 20:28:29 +0100 | [diff] [blame] | 228 | paths := info.TransitiveStubDexJarsByScope.StubDexJarsForScope(apiScope) |
| 229 | android.AssertPathsRelativeToTopEquals(t, fmt.Sprintf("%s %s", message, apiScope), expectedPaths, paths) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | // Check stub dex paths exported by art. |
| 233 | artFragment := result.Module("art-bootclasspath-fragment", "android_common") |
| 234 | artInfo := result.ModuleProvider(artFragment, java.HiddenAPIInfoProvider).(java.HiddenAPIInfo) |
| 235 | |
| 236 | bazPublicStubs := "out/soong/.intermediates/baz.stubs/android_common/dex/baz.stubs.jar" |
| 237 | bazSystemStubs := "out/soong/.intermediates/baz.stubs.system/android_common/dex/baz.stubs.system.jar" |
| 238 | bazTestStubs := "out/soong/.intermediates/baz.stubs.test/android_common/dex/baz.stubs.test.jar" |
| 239 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 240 | checkAPIScopeStubs("art", artInfo, java.PublicHiddenAPIScope, bazPublicStubs) |
| 241 | checkAPIScopeStubs("art", artInfo, java.SystemHiddenAPIScope, bazSystemStubs) |
| 242 | checkAPIScopeStubs("art", artInfo, java.TestHiddenAPIScope, bazTestStubs) |
| 243 | checkAPIScopeStubs("art", artInfo, java.CorePlatformHiddenAPIScope) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 244 | |
| 245 | // Check stub dex paths exported by other. |
| 246 | otherFragment := result.Module("other-bootclasspath-fragment", "android_common") |
| 247 | otherInfo := result.ModuleProvider(otherFragment, java.HiddenAPIInfoProvider).(java.HiddenAPIInfo) |
| 248 | |
| 249 | fooPublicStubs := "out/soong/.intermediates/foo.stubs/android_common/dex/foo.stubs.jar" |
| 250 | fooSystemStubs := "out/soong/.intermediates/foo.stubs.system/android_common/dex/foo.stubs.system.jar" |
| 251 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 252 | checkAPIScopeStubs("other", otherInfo, java.PublicHiddenAPIScope, bazPublicStubs, fooPublicStubs) |
| 253 | checkAPIScopeStubs("other", otherInfo, java.SystemHiddenAPIScope, bazSystemStubs, fooSystemStubs) |
| 254 | checkAPIScopeStubs("other", otherInfo, java.TestHiddenAPIScope, bazTestStubs, fooSystemStubs) |
| 255 | checkAPIScopeStubs("other", otherInfo, java.CorePlatformHiddenAPIScope) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 256 | } |
| 257 | |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 258 | func checkBootclasspathFragment(t *testing.T, result *android.TestResult, moduleName, variantName string, expectedConfiguredModules string, expectedBootclasspathFragmentFiles string) { |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 259 | t.Helper() |
| 260 | |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 261 | bootclasspathFragment := result.ModuleForTests(moduleName, variantName).Module().(*java.BootclasspathFragmentModule) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 262 | |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 263 | bootclasspathFragmentInfo := result.ModuleProvider(bootclasspathFragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) |
| 264 | modules := bootclasspathFragmentInfo.Modules() |
Paul Duffin | 34d433a | 2021-03-09 14:13:25 +0000 | [diff] [blame] | 265 | android.AssertStringEquals(t, "invalid modules for "+moduleName, expectedConfiguredModules, modules.String()) |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 266 | |
| 267 | // Get a list of all the paths in the boot image sorted by arch type. |
| 268 | allPaths := []string{} |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 269 | bootImageFilesByArchType := bootclasspathFragmentInfo.AndroidBootImageFilesByArchType() |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 270 | for _, archType := range android.ArchTypeList() { |
| 271 | if paths, ok := bootImageFilesByArchType[archType]; ok { |
| 272 | for _, path := range paths { |
| 273 | allPaths = append(allPaths, android.NormalizePathForTesting(path)) |
| 274 | } |
| 275 | } |
| 276 | } |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 277 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 278 | android.AssertTrimmedStringEquals(t, "invalid paths for "+moduleName, expectedBootclasspathFragmentFiles, strings.Join(allPaths, "\n")) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 279 | } |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 280 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 281 | func TestBootclasspathFragmentInArtApex(t *testing.T) { |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 282 | commonPreparer := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 283 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 284 | prepareForTestWithArtApex, |
| 285 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 286 | android.FixtureWithRootAndroidBp(` |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 287 | apex { |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 288 | name: "com.android.art", |
| 289 | key: "com.android.art.key", |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 290 | bootclasspath_fragments: [ |
| 291 | "mybootclasspathfragment", |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 292 | ], |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 293 | // bar (like foo) should be transitively included in this apex because it is part of the |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 294 | // mybootclasspathfragment bootclasspath_fragment. However, it is kept here to ensure that the |
| 295 | // apex dedups the files correctly. |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 296 | java_libs: [ |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 297 | "bar", |
| 298 | ], |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 299 | updatable: false, |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | apex_key { |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 303 | name: "com.android.art.key", |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 304 | public_key: "testkey.avbpubkey", |
| 305 | private_key: "testkey.pem", |
| 306 | } |
| 307 | |
| 308 | java_library { |
| 309 | name: "foo", |
| 310 | srcs: ["b.java"], |
| 311 | installable: true, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 312 | apex_available: [ |
| 313 | "com.android.art", |
| 314 | ], |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | java_library { |
| 318 | name: "bar", |
| 319 | srcs: ["b.java"], |
| 320 | installable: true, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 321 | apex_available: [ |
| 322 | "com.android.art", |
| 323 | ], |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 326 | java_import { |
| 327 | name: "foo", |
| 328 | jars: ["foo.jar"], |
| 329 | apex_available: [ |
| 330 | "com.android.art", |
| 331 | ], |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 332 | compile_dex: true, |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | java_import { |
| 336 | name: "bar", |
| 337 | jars: ["bar.jar"], |
| 338 | apex_available: [ |
| 339 | "com.android.art", |
| 340 | ], |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 341 | compile_dex: true, |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 342 | } |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 343 | `), |
| 344 | ) |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 345 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 346 | contentsInsert := func(contents []string) string { |
| 347 | insert := "" |
| 348 | if contents != nil { |
| 349 | insert = fmt.Sprintf(`contents: ["%s"],`, strings.Join(contents, `", "`)) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 350 | } |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 351 | return insert |
| 352 | } |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 353 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 354 | addSource := func(contents ...string) android.FixturePreparer { |
| 355 | text := fmt.Sprintf(` |
| 356 | bootclasspath_fragment { |
| 357 | name: "mybootclasspathfragment", |
| 358 | image_name: "art", |
| 359 | %s |
| 360 | apex_available: [ |
| 361 | "com.android.art", |
| 362 | ], |
| 363 | } |
| 364 | `, contentsInsert(contents)) |
| 365 | |
| 366 | return android.FixtureAddTextFile("art/build/boot/Android.bp", text) |
| 367 | } |
| 368 | |
| 369 | addPrebuilt := func(prefer bool, contents ...string) android.FixturePreparer { |
| 370 | text := fmt.Sprintf(` |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 371 | prebuilt_apex { |
| 372 | name: "com.android.art", |
| 373 | arch: { |
| 374 | arm64: { |
| 375 | src: "com.android.art-arm64.apex", |
| 376 | }, |
| 377 | arm: { |
| 378 | src: "com.android.art-arm.apex", |
| 379 | }, |
| 380 | }, |
| 381 | exported_bootclasspath_fragments: ["mybootclasspathfragment"], |
| 382 | } |
| 383 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 384 | prebuilt_bootclasspath_fragment { |
| 385 | name: "mybootclasspathfragment", |
| 386 | image_name: "art", |
| 387 | %s |
| 388 | prefer: %t, |
| 389 | apex_available: [ |
| 390 | "com.android.art", |
| 391 | ], |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 392 | hidden_api: { |
| 393 | annotation_flags: "mybootclasspathfragment/annotation-flags.csv", |
| 394 | metadata: "mybootclasspathfragment/metadata.csv", |
| 395 | index: "mybootclasspathfragment/index.csv", |
| 396 | stub_flags: "mybootclasspathfragment/stub-flags.csv", |
| 397 | all_flags: "mybootclasspathfragment/all-flags.csv", |
| 398 | }, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 399 | } |
| 400 | `, contentsInsert(contents), prefer) |
| 401 | return android.FixtureAddTextFile("prebuilts/module_sdk/art/Android.bp", text) |
| 402 | } |
| 403 | |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 404 | t.Run("boot image files from source", func(t *testing.T) { |
| 405 | result := android.GroupFixturePreparers( |
| 406 | commonPreparer, |
| 407 | |
| 408 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 409 | // bootclasspath_fragment's contents property. |
| 410 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
| 411 | addSource("foo", "bar"), |
| 412 | ).RunTest(t) |
| 413 | |
| 414 | ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame^] | 415 | "etc/boot-image.prof", |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 416 | "etc/classpaths/bootclasspath.pb", |
| 417 | "javalib/arm/boot.art", |
| 418 | "javalib/arm/boot.oat", |
| 419 | "javalib/arm/boot.vdex", |
| 420 | "javalib/arm/boot-bar.art", |
| 421 | "javalib/arm/boot-bar.oat", |
| 422 | "javalib/arm/boot-bar.vdex", |
| 423 | "javalib/arm64/boot.art", |
| 424 | "javalib/arm64/boot.oat", |
| 425 | "javalib/arm64/boot.vdex", |
| 426 | "javalib/arm64/boot-bar.art", |
| 427 | "javalib/arm64/boot-bar.oat", |
| 428 | "javalib/arm64/boot-bar.vdex", |
| 429 | "javalib/bar.jar", |
| 430 | "javalib/foo.jar", |
| 431 | }) |
| 432 | |
| 433 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ |
| 434 | `bar`, |
| 435 | `com.android.art.key`, |
| 436 | `mybootclasspathfragment`, |
| 437 | }) |
| 438 | |
| 439 | // Make sure that the source bootclasspath_fragment copies its dex files to the predefined |
| 440 | // locations for the art image. |
| 441 | module := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000") |
| 442 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
| 443 | }) |
| 444 | |
| 445 | t.Run("boot image files with preferred prebuilt", func(t *testing.T) { |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 446 | result := android.GroupFixturePreparers( |
| 447 | commonPreparer, |
| 448 | |
| 449 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 450 | // bootclasspath_fragment's contents property. |
| 451 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
| 452 | addSource("foo", "bar"), |
| 453 | |
| 454 | // Make sure that a preferred prebuilt with consistent contents doesn't affect the apex. |
| 455 | addPrebuilt(true, "foo", "bar"), |
| 456 | ).RunTest(t) |
| 457 | |
| 458 | ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame^] | 459 | "etc/boot-image.prof", |
satayev | 227e745 | 2021-05-20 21:35:06 +0100 | [diff] [blame] | 460 | "etc/classpaths/bootclasspath.pb", |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 461 | "javalib/arm/boot.art", |
| 462 | "javalib/arm/boot.oat", |
| 463 | "javalib/arm/boot.vdex", |
| 464 | "javalib/arm/boot-bar.art", |
| 465 | "javalib/arm/boot-bar.oat", |
| 466 | "javalib/arm/boot-bar.vdex", |
| 467 | "javalib/arm64/boot.art", |
| 468 | "javalib/arm64/boot.oat", |
| 469 | "javalib/arm64/boot.vdex", |
| 470 | "javalib/arm64/boot-bar.art", |
| 471 | "javalib/arm64/boot-bar.oat", |
| 472 | "javalib/arm64/boot-bar.vdex", |
| 473 | "javalib/bar.jar", |
| 474 | "javalib/foo.jar", |
| 475 | }) |
| 476 | |
| 477 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ |
| 478 | `bar`, |
| 479 | `com.android.art.key`, |
| 480 | `mybootclasspathfragment`, |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 481 | `prebuilt_com.android.art`, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 482 | }) |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 483 | |
| 484 | // Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined |
| 485 | // locations for the art image. |
| 486 | module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art") |
| 487 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 488 | }) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 489 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 490 | t.Run("source with inconsistency between config and contents", func(t *testing.T) { |
| 491 | android.GroupFixturePreparers( |
| 492 | commonPreparer, |
| 493 | |
| 494 | // Create an inconsistency between the ArtApexJars configuration and the art source |
| 495 | // bootclasspath_fragment module's contents property. |
| 496 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 497 | addSource("foo", "bar"), |
| 498 | ). |
| 499 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 500 | RunTest(t) |
| 501 | }) |
| 502 | |
| 503 | t.Run("prebuilt with inconsistency between config and contents", func(t *testing.T) { |
| 504 | android.GroupFixturePreparers( |
| 505 | commonPreparer, |
| 506 | |
| 507 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 508 | // prebuilt_bootclasspath_fragment module's contents property. |
| 509 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 510 | addPrebuilt(false, "foo", "bar"), |
| 511 | ). |
| 512 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 513 | RunTest(t) |
| 514 | }) |
| 515 | |
| 516 | t.Run("preferred prebuilt with inconsistency between config and contents", func(t *testing.T) { |
| 517 | android.GroupFixturePreparers( |
| 518 | commonPreparer, |
| 519 | |
| 520 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 521 | // prebuilt_bootclasspath_fragment module's contents property. |
| 522 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 523 | addPrebuilt(true, "foo", "bar"), |
| 524 | |
| 525 | // Source contents property is consistent with the config. |
| 526 | addSource("foo"), |
| 527 | ). |
| 528 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 529 | RunTest(t) |
| 530 | }) |
| 531 | |
| 532 | t.Run("source preferred and prebuilt with inconsistency between config and contents", func(t *testing.T) { |
| 533 | android.GroupFixturePreparers( |
| 534 | commonPreparer, |
| 535 | |
| 536 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 537 | // prebuilt_bootclasspath_fragment module's contents property. |
| 538 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 539 | addPrebuilt(false, "foo", "bar"), |
| 540 | |
| 541 | // Source contents property is consistent with the config. |
| 542 | addSource("foo"), |
| 543 | |
| 544 | // This should pass because while the prebuilt is inconsistent with the configuration it is |
| 545 | // not actually used. |
| 546 | ).RunTest(t) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 547 | }) |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 550 | func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) { |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 551 | result := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 552 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 553 | prepareForTestWithArtApex, |
| 554 | |
| 555 | android.FixtureMergeMockFs(android.MockFS{ |
| 556 | "com.android.art-arm64.apex": nil, |
| 557 | "com.android.art-arm.apex": nil, |
| 558 | }), |
| 559 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 560 | // Configure some libraries in the art bootclasspath_fragment. |
Paul Duffin | 60264a0 | 2021-04-12 20:02:36 +0100 | [diff] [blame] | 561 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 562 | ).RunTestWithBp(t, ` |
| 563 | prebuilt_apex { |
| 564 | name: "com.android.art", |
| 565 | arch: { |
| 566 | arm64: { |
| 567 | src: "com.android.art-arm64.apex", |
| 568 | }, |
| 569 | arm: { |
| 570 | src: "com.android.art-arm.apex", |
| 571 | }, |
| 572 | }, |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 573 | exported_bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | java_import { |
| 577 | name: "foo", |
| 578 | jars: ["foo.jar"], |
| 579 | apex_available: [ |
| 580 | "com.android.art", |
| 581 | ], |
| 582 | } |
| 583 | |
| 584 | java_import { |
| 585 | name: "bar", |
| 586 | jars: ["bar.jar"], |
| 587 | apex_available: [ |
| 588 | "com.android.art", |
| 589 | ], |
| 590 | } |
| 591 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 592 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 593 | name: "mybootclasspathfragment", |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 594 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame] | 595 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 596 | contents: ["foo", "bar"], |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 597 | apex_available: [ |
| 598 | "com.android.art", |
| 599 | ], |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 600 | hidden_api: { |
| 601 | annotation_flags: "mybootclasspathfragment/annotation-flags.csv", |
| 602 | metadata: "mybootclasspathfragment/metadata.csv", |
| 603 | index: "mybootclasspathfragment/index.csv", |
| 604 | stub_flags: "mybootclasspathfragment/stub-flags.csv", |
| 605 | all_flags: "mybootclasspathfragment/all-flags.csv", |
| 606 | }, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 607 | } |
| 608 | `) |
| 609 | |
Paul Duffin | 6717d88 | 2021-06-15 19:09:41 +0100 | [diff] [blame] | 610 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 611 | `com.android.art.apex.selector`, |
Paul Duffin | e521881 | 2021-06-07 13:28:19 +0100 | [diff] [blame] | 612 | `prebuilt_mybootclasspathfragment`, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 613 | }) |
| 614 | |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 615 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_com.android.art", []string{ |
Paul Duffin | 5466a36 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 616 | `com.android.art.deapexer`, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 617 | `dex2oatd`, |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 618 | `prebuilt_bar`, |
| 619 | `prebuilt_foo`, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 620 | }) |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 621 | |
| 622 | module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art") |
| 623 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
| 624 | } |
| 625 | |
| 626 | // checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the |
| 627 | // predefined locations of boot dex jars used as inputs for the ART boot image. |
| 628 | func checkCopiesToPredefinedLocationForArt(t *testing.T, config android.Config, module android.TestingModule, modules ...string) { |
| 629 | t.Helper() |
| 630 | bootJarLocations := []string{} |
| 631 | for _, output := range module.AllOutputs() { |
| 632 | output = android.StringRelativeToTop(config, output) |
| 633 | if strings.HasPrefix(output, "out/soong/test_device/dex_artjars_input/") { |
| 634 | bootJarLocations = append(bootJarLocations, output) |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | sort.Strings(bootJarLocations) |
| 639 | expected := []string{} |
| 640 | for _, m := range modules { |
| 641 | expected = append(expected, fmt.Sprintf("out/soong/test_device/dex_artjars_input/%s.jar", m)) |
| 642 | } |
| 643 | sort.Strings(expected) |
| 644 | |
| 645 | android.AssertArrayString(t, "copies to predefined locations for art", expected, bootJarLocations) |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 646 | } |
| 647 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 648 | func TestBootclasspathFragmentContentsNoName(t *testing.T) { |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 649 | result := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 650 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 651 | prepareForTestWithMyapex, |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 652 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 653 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 654 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 655 | // is disabled. |
| 656 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 657 | |
| 658 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 659 | java.FixtureWithLastReleaseApis("foo"), |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 660 | ).RunTestWithBp(t, ` |
| 661 | apex { |
| 662 | name: "myapex", |
| 663 | key: "myapex.key", |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 664 | bootclasspath_fragments: [ |
| 665 | "mybootclasspathfragment", |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 666 | ], |
| 667 | updatable: false, |
| 668 | } |
| 669 | |
| 670 | apex_key { |
| 671 | name: "myapex.key", |
| 672 | public_key: "testkey.avbpubkey", |
| 673 | private_key: "testkey.pem", |
| 674 | } |
| 675 | |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 676 | java_sdk_library { |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 677 | name: "foo", |
| 678 | srcs: ["b.java"], |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 679 | shared_library: false, |
| 680 | public: {enabled: true}, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 681 | apex_available: [ |
| 682 | "myapex", |
| 683 | ], |
| 684 | } |
| 685 | |
| 686 | java_library { |
| 687 | name: "bar", |
| 688 | srcs: ["b.java"], |
| 689 | installable: true, |
| 690 | apex_available: [ |
| 691 | "myapex", |
| 692 | ], |
| 693 | } |
| 694 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 695 | bootclasspath_fragment { |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 696 | name: "mybootclasspathfragment", |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 697 | contents: [ |
| 698 | "foo", |
| 699 | "bar", |
| 700 | ], |
| 701 | apex_available: [ |
| 702 | "myapex", |
| 703 | ], |
| 704 | } |
| 705 | `) |
| 706 | |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 707 | ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ |
| 708 | // This does not include art, oat or vdex files as they are only included for the art boot |
| 709 | // image. |
satayev | 227e745 | 2021-05-20 21:35:06 +0100 | [diff] [blame] | 710 | "etc/classpaths/bootclasspath.pb", |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 711 | "javalib/bar.jar", |
| 712 | "javalib/foo.jar", |
| 713 | }) |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 714 | |
| 715 | java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ |
| 716 | `myapex.key`, |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 717 | `mybootclasspathfragment`, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 718 | }) |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 719 | |
| 720 | apex := result.ModuleForTests("myapex", "android_common_myapex_image") |
| 721 | apexRule := apex.Rule("apexRule") |
| 722 | copyCommands := apexRule.Args["copy_commands"] |
| 723 | |
| 724 | // Make sure that the fragment provides the hidden API encoded dex jars to the APEX. |
| 725 | fragment := result.Module("mybootclasspathfragment", "android_common_apex10000") |
| 726 | |
| 727 | info := result.ModuleProvider(fragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) |
| 728 | |
| 729 | checkFragmentExportedDexJar := func(name string, expectedDexJar string) { |
| 730 | module := result.Module(name, "android_common_apex10000") |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 731 | dexJar, err := info.DexBootJarPathForContentModule(module) |
| 732 | if err != nil { |
| 733 | t.Error(err) |
| 734 | } |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 735 | android.AssertPathRelativeToTopEquals(t, name+" dex", expectedDexJar, dexJar) |
| 736 | |
| 737 | expectedCopyCommand := fmt.Sprintf("&& cp -f %s out/soong/.intermediates/myapex/android_common_myapex_image/image.apex/javalib/%s.jar", expectedDexJar, name) |
| 738 | android.AssertStringDoesContain(t, name+" apex copy command", copyCommands, expectedCopyCommand) |
| 739 | } |
| 740 | |
Paul Duffin | 54c98f5 | 2021-05-15 08:54:30 +0100 | [diff] [blame] | 741 | checkFragmentExportedDexJar("foo", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/foo.jar") |
| 742 | checkFragmentExportedDexJar("bar", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/bar.jar") |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 743 | } |
| 744 | |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 745 | func getDexJarPath(result *android.TestResult, name string) string { |
| 746 | module := result.Module(name, "android_common") |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 747 | return module.(java.UsesLibraryDependency).DexJarBuildPath().Path().RelativeToTop().String() |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | // TestBootclasspathFragment_HiddenAPIList checks to make sure that the correct parameters are |
| 751 | // passed to the hiddenapi list tool. |
| 752 | func TestBootclasspathFragment_HiddenAPIList(t *testing.T) { |
| 753 | result := android.GroupFixturePreparers( |
| 754 | prepareForTestWithBootclasspathFragment, |
| 755 | prepareForTestWithArtApex, |
| 756 | prepareForTestWithMyapex, |
| 757 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
| 758 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 759 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 760 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 761 | // is disabled. |
| 762 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 763 | |
| 764 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 765 | java.FixtureWithLastReleaseApis("foo", "quuz"), |
| 766 | ).RunTestWithBp(t, ` |
| 767 | apex { |
| 768 | name: "com.android.art", |
| 769 | key: "com.android.art.key", |
| 770 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 771 | updatable: false, |
| 772 | } |
| 773 | |
| 774 | apex_key { |
| 775 | name: "com.android.art.key", |
| 776 | public_key: "com.android.art.avbpubkey", |
| 777 | private_key: "com.android.art.pem", |
| 778 | } |
| 779 | |
| 780 | java_library { |
| 781 | name: "baz", |
| 782 | apex_available: [ |
| 783 | "com.android.art", |
| 784 | ], |
| 785 | srcs: ["b.java"], |
| 786 | compile_dex: true, |
| 787 | } |
| 788 | |
| 789 | java_sdk_library { |
| 790 | name: "quuz", |
| 791 | apex_available: [ |
| 792 | "com.android.art", |
| 793 | ], |
| 794 | srcs: ["b.java"], |
| 795 | compile_dex: true, |
| 796 | public: {enabled: true}, |
| 797 | system: {enabled: true}, |
| 798 | test: {enabled: true}, |
| 799 | module_lib: {enabled: true}, |
| 800 | } |
| 801 | |
| 802 | bootclasspath_fragment { |
| 803 | name: "art-bootclasspath-fragment", |
| 804 | image_name: "art", |
| 805 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 806 | contents: ["baz", "quuz"], |
| 807 | apex_available: [ |
| 808 | "com.android.art", |
| 809 | ], |
| 810 | } |
| 811 | |
| 812 | apex { |
| 813 | name: "myapex", |
| 814 | key: "myapex.key", |
| 815 | bootclasspath_fragments: [ |
| 816 | "mybootclasspathfragment", |
| 817 | ], |
| 818 | updatable: false, |
| 819 | } |
| 820 | |
| 821 | apex_key { |
| 822 | name: "myapex.key", |
| 823 | public_key: "testkey.avbpubkey", |
| 824 | private_key: "testkey.pem", |
| 825 | } |
| 826 | |
| 827 | java_sdk_library { |
| 828 | name: "foo", |
| 829 | srcs: ["b.java"], |
| 830 | shared_library: false, |
| 831 | public: {enabled: true}, |
| 832 | apex_available: [ |
| 833 | "myapex", |
| 834 | ], |
| 835 | } |
| 836 | |
| 837 | java_library { |
| 838 | name: "bar", |
| 839 | srcs: ["b.java"], |
| 840 | installable: true, |
| 841 | apex_available: [ |
| 842 | "myapex", |
| 843 | ], |
| 844 | } |
| 845 | |
| 846 | bootclasspath_fragment { |
| 847 | name: "mybootclasspathfragment", |
| 848 | contents: [ |
| 849 | "foo", |
| 850 | "bar", |
| 851 | ], |
| 852 | apex_available: [ |
| 853 | "myapex", |
| 854 | ], |
| 855 | fragments: [ |
| 856 | { |
| 857 | apex: "com.android.art", |
| 858 | module: "art-bootclasspath-fragment", |
| 859 | }, |
| 860 | ], |
| 861 | } |
| 862 | `) |
| 863 | |
| 864 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ |
| 865 | "art-bootclasspath-fragment", |
| 866 | "bar", |
| 867 | "dex2oatd", |
| 868 | "foo", |
| 869 | }) |
| 870 | |
| 871 | fooStubs := getDexJarPath(result, "foo.stubs") |
| 872 | quuzPublicStubs := getDexJarPath(result, "quuz.stubs") |
| 873 | quuzSystemStubs := getDexJarPath(result, "quuz.stubs.system") |
| 874 | quuzTestStubs := getDexJarPath(result, "quuz.stubs.test") |
Paul Duffin | b51db2e | 2021-06-21 14:08:08 +0100 | [diff] [blame] | 875 | quuzModuleLibStubs := getDexJarPath(result, "quuz.stubs.module_lib") |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 876 | |
| 877 | // Make sure that the fragment uses the quuz stub dex jars when generating the hidden API flags. |
| 878 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000") |
| 879 | |
| 880 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 881 | command := rule.RuleParams.Command |
| 882 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 883 | |
| 884 | // Make sure that the quuz stubs are available for resolving references from the implementation |
| 885 | // boot dex jars provided by this module. |
Paul Duffin | b51db2e | 2021-06-21 14:08:08 +0100 | [diff] [blame] | 886 | android.AssertStringDoesContain(t, "quuz widest", command, "--dependency-stub-dex="+quuzModuleLibStubs) |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 887 | |
| 888 | // Make sure that the quuz stubs are available for resolving references from the different API |
| 889 | // stubs provided by this module. |
| 890 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+quuzPublicStubs+":"+fooStubs) |
| 891 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+quuzSystemStubs+":"+fooStubs) |
| 892 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+quuzTestStubs+":"+fooStubs) |
| 893 | } |
| 894 | |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 895 | // TestBootclasspathFragment_AndroidNonUpdatable checks to make sure that setting |
| 896 | // additional_stubs: ["android-non-updatable"] causes the source android-non-updatable modules to be |
| 897 | // added to the hiddenapi list tool. |
| 898 | func TestBootclasspathFragment_AndroidNonUpdatable(t *testing.T) { |
| 899 | result := android.GroupFixturePreparers( |
| 900 | prepareForTestWithBootclasspathFragment, |
| 901 | prepareForTestWithArtApex, |
| 902 | prepareForTestWithMyapex, |
| 903 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 904 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 905 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 906 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 907 | // is disabled. |
| 908 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 909 | |
| 910 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 911 | java.FixtureWithLastReleaseApis("foo", "android-non-updatable"), |
| 912 | ).RunTestWithBp(t, ` |
| 913 | java_sdk_library { |
| 914 | name: "android-non-updatable", |
| 915 | srcs: ["b.java"], |
| 916 | compile_dex: true, |
| 917 | public: { |
| 918 | enabled: true, |
| 919 | }, |
| 920 | system: { |
| 921 | enabled: true, |
| 922 | }, |
| 923 | test: { |
| 924 | enabled: true, |
| 925 | }, |
| 926 | module_lib: { |
| 927 | enabled: true, |
| 928 | }, |
| 929 | } |
| 930 | |
| 931 | apex { |
| 932 | name: "com.android.art", |
| 933 | key: "com.android.art.key", |
| 934 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 935 | java_libs: [ |
| 936 | "baz", |
| 937 | "quuz", |
| 938 | ], |
| 939 | updatable: false, |
| 940 | } |
| 941 | |
| 942 | apex_key { |
| 943 | name: "com.android.art.key", |
| 944 | public_key: "com.android.art.avbpubkey", |
| 945 | private_key: "com.android.art.pem", |
| 946 | } |
| 947 | |
| 948 | java_library { |
| 949 | name: "baz", |
| 950 | apex_available: [ |
| 951 | "com.android.art", |
| 952 | ], |
| 953 | srcs: ["b.java"], |
| 954 | compile_dex: true, |
| 955 | } |
| 956 | |
| 957 | java_library { |
| 958 | name: "quuz", |
| 959 | apex_available: [ |
| 960 | "com.android.art", |
| 961 | ], |
| 962 | srcs: ["b.java"], |
| 963 | compile_dex: true, |
| 964 | } |
| 965 | |
| 966 | bootclasspath_fragment { |
| 967 | name: "art-bootclasspath-fragment", |
| 968 | image_name: "art", |
| 969 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 970 | contents: ["baz", "quuz"], |
| 971 | apex_available: [ |
| 972 | "com.android.art", |
| 973 | ], |
| 974 | } |
| 975 | |
| 976 | apex { |
| 977 | name: "myapex", |
| 978 | key: "myapex.key", |
| 979 | bootclasspath_fragments: [ |
| 980 | "mybootclasspathfragment", |
| 981 | ], |
| 982 | updatable: false, |
| 983 | } |
| 984 | |
| 985 | apex_key { |
| 986 | name: "myapex.key", |
| 987 | public_key: "testkey.avbpubkey", |
| 988 | private_key: "testkey.pem", |
| 989 | } |
| 990 | |
| 991 | java_sdk_library { |
| 992 | name: "foo", |
| 993 | srcs: ["b.java"], |
| 994 | shared_library: false, |
| 995 | public: {enabled: true}, |
| 996 | apex_available: [ |
| 997 | "myapex", |
| 998 | ], |
| 999 | } |
| 1000 | |
| 1001 | java_library { |
| 1002 | name: "bar", |
| 1003 | srcs: ["b.java"], |
| 1004 | installable: true, |
| 1005 | apex_available: [ |
| 1006 | "myapex", |
| 1007 | ], |
| 1008 | } |
| 1009 | |
| 1010 | bootclasspath_fragment { |
| 1011 | name: "mybootclasspathfragment", |
| 1012 | contents: [ |
| 1013 | "foo", |
| 1014 | "bar", |
| 1015 | ], |
| 1016 | apex_available: [ |
| 1017 | "myapex", |
| 1018 | ], |
| 1019 | additional_stubs: ["android-non-updatable"], |
| 1020 | fragments: [ |
| 1021 | { |
| 1022 | apex: "com.android.art", |
| 1023 | module: "art-bootclasspath-fragment", |
| 1024 | }, |
| 1025 | ], |
| 1026 | } |
| 1027 | `) |
| 1028 | |
| 1029 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ |
| 1030 | "android-non-updatable.stubs", |
| 1031 | "android-non-updatable.stubs.module_lib", |
| 1032 | "android-non-updatable.stubs.system", |
| 1033 | "android-non-updatable.stubs.test", |
| 1034 | "art-bootclasspath-fragment", |
| 1035 | "bar", |
| 1036 | "dex2oatd", |
| 1037 | "foo", |
| 1038 | }) |
| 1039 | |
| 1040 | nonUpdatablePublicStubs := getDexJarPath(result, "android-non-updatable.stubs") |
| 1041 | nonUpdatableSystemStubs := getDexJarPath(result, "android-non-updatable.stubs.system") |
| 1042 | nonUpdatableTestStubs := getDexJarPath(result, "android-non-updatable.stubs.test") |
| 1043 | nonUpdatableModuleLibStubs := getDexJarPath(result, "android-non-updatable.stubs.module_lib") |
| 1044 | |
| 1045 | // Make sure that the fragment uses the android-non-updatable modules when generating the hidden |
| 1046 | // API flags. |
| 1047 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000") |
| 1048 | |
| 1049 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 1050 | command := rule.RuleParams.Command |
| 1051 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 1052 | |
| 1053 | // Make sure that the module_lib non-updatable stubs are available for resolving references from |
| 1054 | // the implementation boot dex jars provided by this module. |
| 1055 | android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs) |
| 1056 | |
| 1057 | // Make sure that the appropriate non-updatable stubs are available for resolving references from |
| 1058 | // the different API stubs provided by this module. |
| 1059 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs) |
| 1060 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs) |
| 1061 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs) |
| 1062 | } |
| 1063 | |
| 1064 | // TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks checks to make sure that |
| 1065 | // setting additional_stubs: ["android-non-updatable"] causes the prebuilt android-non-updatable |
| 1066 | // modules to be added to the hiddenapi list tool. |
| 1067 | func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *testing.T) { |
| 1068 | result := android.GroupFixturePreparers( |
| 1069 | prepareForTestWithBootclasspathFragment, |
| 1070 | java.PrepareForTestWithJavaDefaultModules, |
| 1071 | prepareForTestWithArtApex, |
| 1072 | prepareForTestWithMyapex, |
| 1073 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 1074 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 1075 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1076 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 1077 | // is disabled. |
| 1078 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 1079 | |
| 1080 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 1081 | variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) |
| 1082 | }), |
| 1083 | |
| 1084 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 1085 | java.FixtureWithPrebuiltApis(map[string][]string{ |
| 1086 | "current": {"android-non-updatable"}, |
| 1087 | "30": {"foo"}, |
| 1088 | }), |
| 1089 | ).RunTestWithBp(t, ` |
| 1090 | apex { |
| 1091 | name: "com.android.art", |
| 1092 | key: "com.android.art.key", |
| 1093 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 1094 | java_libs: [ |
| 1095 | "baz", |
| 1096 | "quuz", |
| 1097 | ], |
| 1098 | updatable: false, |
| 1099 | } |
| 1100 | |
| 1101 | apex_key { |
| 1102 | name: "com.android.art.key", |
| 1103 | public_key: "com.android.art.avbpubkey", |
| 1104 | private_key: "com.android.art.pem", |
| 1105 | } |
| 1106 | |
| 1107 | java_library { |
| 1108 | name: "baz", |
| 1109 | apex_available: [ |
| 1110 | "com.android.art", |
| 1111 | ], |
| 1112 | srcs: ["b.java"], |
| 1113 | compile_dex: true, |
| 1114 | } |
| 1115 | |
| 1116 | java_library { |
| 1117 | name: "quuz", |
| 1118 | apex_available: [ |
| 1119 | "com.android.art", |
| 1120 | ], |
| 1121 | srcs: ["b.java"], |
| 1122 | compile_dex: true, |
| 1123 | } |
| 1124 | |
| 1125 | bootclasspath_fragment { |
| 1126 | name: "art-bootclasspath-fragment", |
| 1127 | image_name: "art", |
| 1128 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 1129 | contents: ["baz", "quuz"], |
| 1130 | apex_available: [ |
| 1131 | "com.android.art", |
| 1132 | ], |
| 1133 | } |
| 1134 | |
| 1135 | apex { |
| 1136 | name: "myapex", |
| 1137 | key: "myapex.key", |
| 1138 | bootclasspath_fragments: [ |
| 1139 | "mybootclasspathfragment", |
| 1140 | ], |
| 1141 | updatable: false, |
| 1142 | } |
| 1143 | |
| 1144 | apex_key { |
| 1145 | name: "myapex.key", |
| 1146 | public_key: "testkey.avbpubkey", |
| 1147 | private_key: "testkey.pem", |
| 1148 | } |
| 1149 | |
| 1150 | java_sdk_library { |
| 1151 | name: "foo", |
| 1152 | srcs: ["b.java"], |
| 1153 | shared_library: false, |
| 1154 | public: {enabled: true}, |
| 1155 | apex_available: [ |
| 1156 | "myapex", |
| 1157 | ], |
| 1158 | } |
| 1159 | |
| 1160 | java_library { |
| 1161 | name: "bar", |
| 1162 | srcs: ["b.java"], |
| 1163 | installable: true, |
| 1164 | apex_available: [ |
| 1165 | "myapex", |
| 1166 | ], |
| 1167 | } |
| 1168 | |
| 1169 | bootclasspath_fragment { |
| 1170 | name: "mybootclasspathfragment", |
| 1171 | contents: [ |
| 1172 | "foo", |
| 1173 | "bar", |
| 1174 | ], |
| 1175 | apex_available: [ |
| 1176 | "myapex", |
| 1177 | ], |
| 1178 | additional_stubs: ["android-non-updatable"], |
| 1179 | fragments: [ |
| 1180 | { |
| 1181 | apex: "com.android.art", |
| 1182 | module: "art-bootclasspath-fragment", |
| 1183 | }, |
| 1184 | ], |
| 1185 | } |
| 1186 | `) |
| 1187 | |
| 1188 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ |
| 1189 | "art-bootclasspath-fragment", |
| 1190 | "bar", |
| 1191 | "dex2oatd", |
| 1192 | "foo", |
| 1193 | "prebuilt_sdk_module-lib_current_android-non-updatable", |
| 1194 | "prebuilt_sdk_public_current_android-non-updatable", |
| 1195 | "prebuilt_sdk_system_current_android-non-updatable", |
| 1196 | "prebuilt_sdk_test_current_android-non-updatable", |
| 1197 | }) |
| 1198 | |
| 1199 | nonUpdatablePublicStubs := getDexJarPath(result, "sdk_public_current_android-non-updatable") |
| 1200 | nonUpdatableSystemStubs := getDexJarPath(result, "sdk_system_current_android-non-updatable") |
| 1201 | nonUpdatableTestStubs := getDexJarPath(result, "sdk_test_current_android-non-updatable") |
| 1202 | nonUpdatableModuleLibStubs := getDexJarPath(result, "sdk_module-lib_current_android-non-updatable") |
| 1203 | |
| 1204 | // Make sure that the fragment uses the android-non-updatable modules when generating the hidden |
| 1205 | // API flags. |
| 1206 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000") |
| 1207 | |
| 1208 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 1209 | command := rule.RuleParams.Command |
| 1210 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 1211 | |
| 1212 | // Make sure that the module_lib non-updatable stubs are available for resolving references from |
| 1213 | // the implementation boot dex jars provided by this module. |
| 1214 | android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs) |
| 1215 | |
| 1216 | // Make sure that the appropriate non-updatable stubs are available for resolving references from |
| 1217 | // the different API stubs provided by this module. |
| 1218 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs) |
| 1219 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs) |
| 1220 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs) |
| 1221 | } |
| 1222 | |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 1223 | // TODO(b/177892522) - add test for host apex. |