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