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" |
Jiakai Zhang | 7d3c9e0 | 2021-12-13 17:19:05 +0000 | [diff] [blame] | 19 | "path" |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 20 | "sort" |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 21 | "strings" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 22 | "testing" |
| 23 | |
| 24 | "android/soong/android" |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 25 | "android/soong/dexpreopt" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 26 | "android/soong/java" |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 27 | |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 28 | "github.com/google/blueprint/proptools" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 29 | ) |
| 30 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 31 | // Contains tests for bootclasspath_fragment logic from java/bootclasspath_fragment.go as the ART |
| 32 | // bootclasspath_fragment requires modules from the ART apex. |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 33 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 34 | var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers( |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 35 | java.PrepareForTestWithDexpreopt, |
| 36 | PrepareForTestWithApexBuildComponents, |
| 37 | ) |
| 38 | |
| 39 | // Some additional files needed for the art apex. |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 40 | var prepareForTestWithArtApex = android.GroupFixturePreparers( |
| 41 | android.FixtureMergeMockFs(android.MockFS{ |
| 42 | "com.android.art.avbpubkey": nil, |
| 43 | "com.android.art.pem": nil, |
| 44 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 45 | }), |
| 46 | dexpreopt.FixtureSetBootImageProfiles("art/build/boot/boot-image-profile.txt"), |
| 47 | ) |
Paul Duffin | 52bfaa4 | 2021-03-23 23:40:12 +0000 | [diff] [blame] | 48 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 49 | func TestBootclasspathFragments_FragmentDependency(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 50 | t.Parallel() |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 51 | result := android.GroupFixturePreparers( |
| 52 | prepareForTestWithBootclasspathFragment, |
| 53 | // Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 54 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 55 | java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"), |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 56 | prepareForTestWithArtApex, |
Colin Cross | a66b463 | 2024-08-08 15:50:47 -0700 | [diff] [blame] | 57 | android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 58 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 59 | java.FixtureWithLastReleaseApis("foo", "baz"), |
| 60 | ).RunTestWithBp(t, ` |
| 61 | java_sdk_library { |
| 62 | name: "foo", |
| 63 | srcs: ["b.java"], |
| 64 | shared_library: false, |
| 65 | public: { |
| 66 | enabled: true, |
| 67 | }, |
| 68 | system: { |
| 69 | enabled: true, |
| 70 | }, |
| 71 | } |
| 72 | |
| 73 | java_library { |
| 74 | name: "bar", |
| 75 | srcs: ["b.java"], |
| 76 | installable: true, |
| 77 | } |
| 78 | |
| 79 | apex { |
| 80 | name: "com.android.art", |
| 81 | key: "com.android.art.key", |
| 82 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 83 | updatable: false, |
| 84 | } |
| 85 | |
| 86 | apex_key { |
| 87 | name: "com.android.art.key", |
| 88 | public_key: "com.android.art.avbpubkey", |
| 89 | private_key: "com.android.art.pem", |
| 90 | } |
| 91 | |
| 92 | java_sdk_library { |
| 93 | name: "baz", |
| 94 | apex_available: [ |
| 95 | "com.android.art", |
| 96 | ], |
| 97 | srcs: ["b.java"], |
| 98 | shared_library: false, |
| 99 | public: { |
| 100 | enabled: true, |
| 101 | }, |
| 102 | system: { |
| 103 | enabled: true, |
| 104 | }, |
| 105 | test: { |
| 106 | enabled: true, |
| 107 | }, |
Jihoon Kang | 85bc193 | 2024-07-01 17:04:46 +0000 | [diff] [blame] | 108 | sdk_version: "core_current", |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | java_library { |
| 112 | name: "quuz", |
| 113 | apex_available: [ |
| 114 | "com.android.art", |
| 115 | ], |
| 116 | srcs: ["b.java"], |
| 117 | compile_dex: true, |
| 118 | } |
| 119 | |
| 120 | bootclasspath_fragment { |
| 121 | name: "art-bootclasspath-fragment", |
| 122 | image_name: "art", |
| 123 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 124 | contents: ["baz", "quuz"], |
| 125 | apex_available: [ |
| 126 | "com.android.art", |
| 127 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 128 | hidden_api: { |
| 129 | split_packages: ["*"], |
| 130 | }, |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | bootclasspath_fragment { |
| 134 | name: "other-bootclasspath-fragment", |
| 135 | contents: ["foo", "bar"], |
| 136 | fragments: [ |
| 137 | { |
| 138 | apex: "com.android.art", |
| 139 | module: "art-bootclasspath-fragment", |
| 140 | }, |
| 141 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 142 | hidden_api: { |
| 143 | split_packages: ["*"], |
| 144 | }, |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 145 | } |
| 146 | `, |
| 147 | ) |
| 148 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 149 | checkAPIScopeStubs := func(message string, info java.HiddenAPIInfo, apiScope *java.HiddenAPIScope, expectedPaths ...string) { |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 150 | t.Helper() |
Paul Duffin | 280a31a | 2021-06-27 20:28:29 +0100 | [diff] [blame] | 151 | paths := info.TransitiveStubDexJarsByScope.StubDexJarsForScope(apiScope) |
| 152 | android.AssertPathsRelativeToTopEquals(t, fmt.Sprintf("%s %s", message, apiScope), expectedPaths, paths) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | // Check stub dex paths exported by art. |
| 156 | artFragment := result.Module("art-bootclasspath-fragment", "android_common") |
Yu Liu | 663e450 | 2024-08-12 18:23:59 +0000 | [diff] [blame] | 157 | artInfo, _ := android.OtherModuleProvider(result, artFragment, java.HiddenAPIInfoProvider) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 158 | |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 159 | bazPublicStubs := "out/soong/.intermediates/baz.stubs.exportable/android_common/dex/baz.stubs.exportable.jar" |
| 160 | bazSystemStubs := "out/soong/.intermediates/baz.stubs.exportable.system/android_common/dex/baz.stubs.exportable.system.jar" |
| 161 | bazTestStubs := "out/soong/.intermediates/baz.stubs.exportable.test/android_common/dex/baz.stubs.exportable.test.jar" |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 162 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 163 | checkAPIScopeStubs("art", artInfo, java.PublicHiddenAPIScope, bazPublicStubs) |
| 164 | checkAPIScopeStubs("art", artInfo, java.SystemHiddenAPIScope, bazSystemStubs) |
| 165 | checkAPIScopeStubs("art", artInfo, java.TestHiddenAPIScope, bazTestStubs) |
| 166 | checkAPIScopeStubs("art", artInfo, java.CorePlatformHiddenAPIScope) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 167 | |
| 168 | // Check stub dex paths exported by other. |
| 169 | otherFragment := result.Module("other-bootclasspath-fragment", "android_common") |
Yu Liu | 663e450 | 2024-08-12 18:23:59 +0000 | [diff] [blame] | 170 | otherInfo, _ := android.OtherModuleProvider(result, otherFragment, java.HiddenAPIInfoProvider) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 171 | |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 172 | fooPublicStubs := "out/soong/.intermediates/foo.stubs.exportable/android_common/dex/foo.stubs.exportable.jar" |
| 173 | fooSystemStubs := "out/soong/.intermediates/foo.stubs.exportable.system/android_common/dex/foo.stubs.exportable.system.jar" |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 174 | |
Paul Duffin | 31fad80 | 2021-06-18 18:14:25 +0100 | [diff] [blame] | 175 | checkAPIScopeStubs("other", otherInfo, java.PublicHiddenAPIScope, bazPublicStubs, fooPublicStubs) |
| 176 | checkAPIScopeStubs("other", otherInfo, java.SystemHiddenAPIScope, bazSystemStubs, fooSystemStubs) |
| 177 | checkAPIScopeStubs("other", otherInfo, java.TestHiddenAPIScope, bazTestStubs, fooSystemStubs) |
| 178 | checkAPIScopeStubs("other", otherInfo, java.CorePlatformHiddenAPIScope) |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 179 | } |
| 180 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 181 | func TestBootclasspathFragmentInArtApex(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 182 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 183 | commonPreparer := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 184 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 185 | prepareForTestWithArtApex, |
| 186 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 187 | android.FixtureWithRootAndroidBp(` |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 188 | apex { |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 189 | name: "com.android.art", |
| 190 | key: "com.android.art.key", |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 191 | bootclasspath_fragments: [ |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 192 | "art-bootclasspath-fragment", |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 193 | ], |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 194 | // bar (like foo) should be transitively included in this apex because it is part of the |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 195 | // art-bootclasspath-fragment bootclasspath_fragment. |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 196 | updatable: false, |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Spandan Das | 7fd531f | 2024-06-05 19:27:18 +0000 | [diff] [blame] | 199 | override_apex { |
| 200 | name: "com.mycompany.android.art", |
| 201 | base: "com.android.art", |
| 202 | min_sdk_version: "33", // mycompany overrides the min_sdk_version |
| 203 | } |
| 204 | |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 205 | apex_key { |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 206 | name: "com.android.art.key", |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 207 | public_key: "testkey.avbpubkey", |
| 208 | private_key: "testkey.pem", |
| 209 | } |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 210 | `), |
| 211 | ) |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 212 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 213 | contentsInsert := func(contents []string) string { |
| 214 | insert := "" |
| 215 | if contents != nil { |
| 216 | insert = fmt.Sprintf(`contents: ["%s"],`, strings.Join(contents, `", "`)) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 217 | } |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 218 | return insert |
| 219 | } |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 220 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 221 | addSource := func(contents ...string) android.FixturePreparer { |
| 222 | text := fmt.Sprintf(` |
| 223 | bootclasspath_fragment { |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 224 | name: "art-bootclasspath-fragment", |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 225 | image_name: "art", |
| 226 | %s |
| 227 | apex_available: [ |
| 228 | "com.android.art", |
| 229 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 230 | hidden_api: { |
| 231 | split_packages: ["*"], |
| 232 | }, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 233 | } |
| 234 | `, contentsInsert(contents)) |
| 235 | |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 236 | for _, content := range contents { |
| 237 | text += fmt.Sprintf(` |
| 238 | java_library { |
| 239 | name: "%[1]s", |
| 240 | srcs: ["%[1]s.java"], |
| 241 | installable: true, |
| 242 | apex_available: [ |
| 243 | "com.android.art", |
| 244 | ], |
Colin Cross | 09dbc01 | 2024-12-18 13:45:58 -0800 | [diff] [blame] | 245 | min_sdk_version: "33", |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 246 | } |
| 247 | `, content) |
| 248 | } |
| 249 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 250 | return android.FixtureAddTextFile("art/build/boot/Android.bp", text) |
| 251 | } |
| 252 | |
| 253 | addPrebuilt := func(prefer bool, contents ...string) android.FixturePreparer { |
| 254 | text := fmt.Sprintf(` |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 255 | prebuilt_apex { |
| 256 | name: "com.android.art", |
| 257 | arch: { |
| 258 | arm64: { |
| 259 | src: "com.android.art-arm64.apex", |
| 260 | }, |
| 261 | arm: { |
| 262 | src: "com.android.art-arm.apex", |
| 263 | }, |
| 264 | }, |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 265 | exported_bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 266 | } |
| 267 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 268 | prebuilt_bootclasspath_fragment { |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 269 | name: "art-bootclasspath-fragment", |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 270 | image_name: "art", |
| 271 | %s |
| 272 | prefer: %t, |
| 273 | apex_available: [ |
| 274 | "com.android.art", |
| 275 | ], |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 276 | hidden_api: { |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 277 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 278 | metadata: "hiddenapi/metadata.csv", |
| 279 | index: "hiddenapi/index.csv", |
| 280 | stub_flags: "hiddenapi/stub-flags.csv", |
| 281 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 282 | }, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 283 | } |
| 284 | `, contentsInsert(contents), prefer) |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 285 | |
| 286 | for _, content := range contents { |
| 287 | text += fmt.Sprintf(` |
| 288 | java_import { |
| 289 | name: "%[1]s", |
| 290 | prefer: %[2]t, |
| 291 | jars: ["%[1]s.jar"], |
| 292 | apex_available: [ |
| 293 | "com.android.art", |
| 294 | ], |
| 295 | compile_dex: true, |
| 296 | } |
| 297 | `, content, prefer) |
| 298 | } |
| 299 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 300 | return android.FixtureAddTextFile("prebuilts/module_sdk/art/Android.bp", text) |
| 301 | } |
| 302 | |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 303 | t.Run("boot image files from source", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 304 | t.Parallel() |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 305 | result := android.GroupFixturePreparers( |
| 306 | commonPreparer, |
| 307 | |
| 308 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 309 | // bootclasspath_fragment's contents property. |
| 310 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
Jiakai Zhang | 556bdf8 | 2023-07-12 16:51:57 +0100 | [diff] [blame] | 311 | dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"), |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 312 | addSource("foo", "bar"), |
Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 313 | java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 314 | ).RunTest(t) |
| 315 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 316 | ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 317 | "etc/boot-image.prof", |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 318 | "etc/classpaths/bootclasspath.pb", |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 319 | "javalib/bar.jar", |
| 320 | "javalib/foo.jar", |
| 321 | }) |
| 322 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 323 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Colin Cross | 388c661 | 2025-01-28 14:00:12 -0800 | [diff] [blame] | 324 | `all_apex_contributions`, |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 325 | `art-bootclasspath-fragment`, |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 326 | `com.android.art.key`, |
Spandan Das | e21a8d4 | 2024-01-23 23:56:29 +0000 | [diff] [blame] | 327 | `dex2oatd`, |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 328 | }) |
| 329 | |
| 330 | // Make sure that the source bootclasspath_fragment copies its dex files to the predefined |
| 331 | // locations for the art image. |
Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 332 | module := result.ModuleForTests("dex_bootjars", "android_common") |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 333 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
| 334 | }) |
| 335 | |
Spandan Das | 7fd531f | 2024-06-05 19:27:18 +0000 | [diff] [blame] | 336 | t.Run("boot image files from source of override apex", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 337 | t.Parallel() |
Spandan Das | 7fd531f | 2024-06-05 19:27:18 +0000 | [diff] [blame] | 338 | result := android.GroupFixturePreparers( |
| 339 | commonPreparer, |
| 340 | |
| 341 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 342 | // bootclasspath_fragment's contents property. |
| 343 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
| 344 | dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"), |
| 345 | addSource("foo", "bar"), |
| 346 | java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), |
| 347 | ).RunTest(t) |
| 348 | |
| 349 | ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.mycompany.android.art_com.mycompany.android.art", []string{ |
| 350 | "etc/boot-image.prof", |
| 351 | "etc/classpaths/bootclasspath.pb", |
| 352 | "javalib/bar.jar", |
| 353 | "javalib/foo.jar", |
| 354 | }) |
| 355 | }) |
| 356 | |
Jiakai Zhang | bc698cd | 2023-05-08 16:28:38 +0000 | [diff] [blame] | 357 | t.Run("generate boot image profile even if dexpreopt is disabled", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 358 | t.Parallel() |
Jiakai Zhang | bc698cd | 2023-05-08 16:28:38 +0000 | [diff] [blame] | 359 | result := android.GroupFixturePreparers( |
| 360 | commonPreparer, |
| 361 | |
| 362 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 363 | // bootclasspath_fragment's contents property. |
| 364 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
| 365 | addSource("foo", "bar"), |
| 366 | java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"), |
| 367 | dexpreopt.FixtureDisableDexpreoptBootImages(true), |
| 368 | ).RunTest(t) |
| 369 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 370 | ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Jiakai Zhang | bc698cd | 2023-05-08 16:28:38 +0000 | [diff] [blame] | 371 | "etc/boot-image.prof", |
| 372 | "etc/classpaths/bootclasspath.pb", |
| 373 | "javalib/bar.jar", |
| 374 | "javalib/foo.jar", |
| 375 | }) |
| 376 | }) |
| 377 | |
Jiakai Zhang | 7d3c9e0 | 2021-12-13 17:19:05 +0000 | [diff] [blame] | 378 | t.Run("boot image disable generate profile", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 379 | t.Parallel() |
Jiakai Zhang | 7d3c9e0 | 2021-12-13 17:19:05 +0000 | [diff] [blame] | 380 | result := android.GroupFixturePreparers( |
| 381 | commonPreparer, |
| 382 | |
| 383 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 384 | // bootclasspath_fragment's contents property. |
| 385 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
| 386 | addSource("foo", "bar"), |
| 387 | dexpreopt.FixtureDisableGenerateProfile(true), |
| 388 | ).RunTest(t) |
| 389 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 390 | files := getFiles(t, result.TestContext, "com.android.art", "android_common_com.android.art") |
Jiakai Zhang | 7d3c9e0 | 2021-12-13 17:19:05 +0000 | [diff] [blame] | 391 | for _, file := range files { |
| 392 | matched, _ := path.Match("etc/boot-image.prof", file.path) |
| 393 | android.AssertBoolEquals(t, "\"etc/boot-image.prof\" should not be in the APEX", matched, false) |
| 394 | } |
| 395 | }) |
| 396 | |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 397 | t.Run("boot image files with preferred prebuilt", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 398 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 399 | result := android.GroupFixturePreparers( |
| 400 | commonPreparer, |
| 401 | |
| 402 | // Configure some libraries in the art bootclasspath_fragment that match the source |
| 403 | // bootclasspath_fragment's contents property. |
| 404 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
Jiakai Zhang | 556bdf8 | 2023-07-12 16:51:57 +0100 | [diff] [blame] | 405 | dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"), |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 406 | addSource("foo", "bar"), |
| 407 | |
| 408 | // Make sure that a preferred prebuilt with consistent contents doesn't affect the apex. |
| 409 | addPrebuilt(true, "foo", "bar"), |
Spandan Das | 52c01a1 | 2024-09-20 01:09:48 +0000 | [diff] [blame] | 410 | android.FixtureMergeMockFs(android.MockFS{ |
| 411 | "apex_contributions/Android.bp": []byte(` |
| 412 | apex_contributions { |
| 413 | name: "prebuilt_art_contributions", |
| 414 | contents: ["prebuilt_com.android.art"], |
| 415 | api_domain: "com.android.art", |
| 416 | } |
| 417 | `)}), |
| 418 | android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"), |
Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 419 | |
| 420 | java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 421 | ).RunTest(t) |
| 422 | |
Spandan Das | 52c01a1 | 2024-09-20 01:09:48 +0000 | [diff] [blame] | 423 | ensureExactDeapexedContents(t, result.TestContext, "prebuilt_com.android.art", "android_common_com.android.art", []string{ |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 424 | "etc/boot-image.prof", |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 425 | "javalib/bar.jar", |
| 426 | "javalib/foo.jar", |
| 427 | }) |
| 428 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 429 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Colin Cross | 388c661 | 2025-01-28 14:00:12 -0800 | [diff] [blame] | 430 | `all_apex_contributions`, |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 431 | `art-bootclasspath-fragment`, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 432 | `com.android.art.key`, |
Spandan Das | e21a8d4 | 2024-01-23 23:56:29 +0000 | [diff] [blame] | 433 | `dex2oatd`, |
Colin Cross | bdd344b | 2025-01-14 16:01:03 -0800 | [diff] [blame] | 434 | `prebuilt_art-bootclasspath-fragment`, |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 435 | `prebuilt_com.android.art`, |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 436 | }) |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 437 | |
| 438 | // Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined |
| 439 | // locations for the art image. |
Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 440 | module := result.ModuleForTests("dex_bootjars", "android_common") |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 441 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 442 | }) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 443 | |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 444 | t.Run("source with inconsistency between config and contents", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 445 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 446 | android.GroupFixturePreparers( |
| 447 | commonPreparer, |
| 448 | |
| 449 | // Create an inconsistency between the ArtApexJars configuration and the art source |
| 450 | // bootclasspath_fragment module's contents property. |
| 451 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 452 | addSource("foo", "bar"), |
| 453 | ). |
| 454 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 455 | RunTest(t) |
| 456 | }) |
| 457 | |
| 458 | t.Run("prebuilt with inconsistency between config and contents", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 459 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 460 | android.GroupFixturePreparers( |
| 461 | commonPreparer, |
| 462 | |
| 463 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 464 | // prebuilt_bootclasspath_fragment module's contents property. |
| 465 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 466 | addPrebuilt(false, "foo", "bar"), |
| 467 | ). |
| 468 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 469 | RunTest(t) |
| 470 | }) |
| 471 | |
| 472 | t.Run("preferred prebuilt with inconsistency between config and contents", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 473 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 474 | android.GroupFixturePreparers( |
| 475 | commonPreparer, |
| 476 | |
| 477 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 478 | // prebuilt_bootclasspath_fragment module's contents property. |
| 479 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 480 | addPrebuilt(true, "foo", "bar"), |
| 481 | |
| 482 | // Source contents property is consistent with the config. |
| 483 | addSource("foo"), |
| 484 | ). |
| 485 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)). |
| 486 | RunTest(t) |
| 487 | }) |
| 488 | |
| 489 | t.Run("source preferred and prebuilt with inconsistency between config and contents", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 490 | t.Parallel() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 491 | android.GroupFixturePreparers( |
| 492 | commonPreparer, |
| 493 | |
| 494 | // Create an inconsistency between the ArtApexJars configuration and the art |
| 495 | // prebuilt_bootclasspath_fragment module's contents property. |
| 496 | java.FixtureConfigureBootJars("com.android.art:foo"), |
| 497 | addPrebuilt(false, "foo", "bar"), |
| 498 | |
| 499 | // Source contents property is consistent with the config. |
| 500 | addSource("foo"), |
| 501 | |
| 502 | // This should pass because while the prebuilt is inconsistent with the configuration it is |
| 503 | // not actually used. |
| 504 | ).RunTest(t) |
Paul Duffin | 396229f | 2021-03-18 18:30:31 +0000 | [diff] [blame] | 505 | }) |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 508 | func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 509 | t.Parallel() |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 510 | preparers := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 511 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 512 | prepareForTestWithArtApex, |
| 513 | |
| 514 | android.FixtureMergeMockFs(android.MockFS{ |
| 515 | "com.android.art-arm64.apex": nil, |
| 516 | "com.android.art-arm.apex": nil, |
| 517 | }), |
| 518 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 519 | // Configure some libraries in the art bootclasspath_fragment. |
Paul Duffin | 60264a0 | 2021-04-12 20:02:36 +0100 | [diff] [blame] | 520 | java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), |
Jiakai Zhang | 556bdf8 | 2023-07-12 16:51:57 +0100 | [diff] [blame] | 521 | dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"), |
Jiakai Zhang | e6e90db | 2022-01-28 14:58:56 +0000 | [diff] [blame] | 522 | java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), |
Spandan Das | 52c01a1 | 2024-09-20 01:09:48 +0000 | [diff] [blame] | 523 | android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"), |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 524 | ) |
| 525 | |
| 526 | bp := ` |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 527 | prebuilt_apex { |
| 528 | name: "com.android.art", |
| 529 | arch: { |
| 530 | arm64: { |
| 531 | src: "com.android.art-arm64.apex", |
| 532 | }, |
| 533 | arm: { |
| 534 | src: "com.android.art-arm.apex", |
| 535 | }, |
| 536 | }, |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 537 | exported_bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | java_import { |
| 541 | name: "foo", |
| 542 | jars: ["foo.jar"], |
| 543 | apex_available: [ |
| 544 | "com.android.art", |
| 545 | ], |
| 546 | } |
| 547 | |
| 548 | java_import { |
| 549 | name: "bar", |
| 550 | jars: ["bar.jar"], |
| 551 | apex_available: [ |
| 552 | "com.android.art", |
| 553 | ], |
| 554 | } |
| 555 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 556 | prebuilt_bootclasspath_fragment { |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 557 | name: "art-bootclasspath-fragment", |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 558 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame] | 559 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 560 | contents: ["foo", "bar"], |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 561 | apex_available: [ |
| 562 | "com.android.art", |
| 563 | ], |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 564 | hidden_api: { |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 565 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 566 | metadata: "hiddenapi/metadata.csv", |
| 567 | index: "hiddenapi/index.csv", |
| 568 | stub_flags: "hiddenapi/stub-flags.csv", |
| 569 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 54e4197 | 2021-07-19 13:23:40 +0100 | [diff] [blame] | 570 | }, |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 571 | } |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 572 | |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 573 | // A prebuilt apex with the same apex_name that shouldn't interfere when it isn't enabled. |
| 574 | prebuilt_apex { |
| 575 | name: "com.mycompany.android.art", |
| 576 | apex_name: "com.android.art", |
| 577 | %s |
| 578 | src: "com.mycompany.android.art.apex", |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 579 | exported_bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 580 | } |
Spandan Das | 52c01a1 | 2024-09-20 01:09:48 +0000 | [diff] [blame] | 581 | |
| 582 | apex_contributions { |
| 583 | name: "prebuilt_art_contributions", |
| 584 | contents: ["prebuilt_com.android.art"], |
| 585 | api_domain: "com.android.art", |
| 586 | } |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 587 | ` |
| 588 | |
| 589 | t.Run("disabled alternative APEX", func(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 590 | t.Parallel() |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 591 | result := preparers.RunTestWithBp(t, fmt.Sprintf(bp, "enabled: false,")) |
| 592 | |
| 593 | java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{ |
Spandan Das | 85bd462 | 2024-08-01 00:51:20 +0000 | [diff] [blame] | 594 | `all_apex_contributions`, |
Spandan Das | 2069c3f | 2023-12-06 19:40:24 +0000 | [diff] [blame] | 595 | `dex2oatd`, |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 596 | `prebuilt_art-bootclasspath-fragment`, |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 597 | }) |
| 598 | |
Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 599 | java.CheckModuleDependencies(t, result.TestContext, "art-bootclasspath-fragment", "android_common_com.android.art", []string{ |
Spandan Das | 85bd462 | 2024-08-01 00:51:20 +0000 | [diff] [blame] | 600 | `all_apex_contributions`, |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 601 | `dex2oatd`, |
| 602 | `prebuilt_bar`, |
| 603 | `prebuilt_foo`, |
| 604 | }) |
| 605 | |
Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 606 | module := result.ModuleForTests("dex_bootjars", "android_common") |
Martin Stjernholm | 43c44b0 | 2021-06-30 16:35:07 +0100 | [diff] [blame] | 607 | checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 608 | }) |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | // checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the |
| 612 | // predefined locations of boot dex jars used as inputs for the ART boot image. |
| 613 | func checkCopiesToPredefinedLocationForArt(t *testing.T, config android.Config, module android.TestingModule, modules ...string) { |
| 614 | t.Helper() |
| 615 | bootJarLocations := []string{} |
| 616 | for _, output := range module.AllOutputs() { |
| 617 | output = android.StringRelativeToTop(config, output) |
Jeongik Cha | 4753b39 | 2023-04-19 23:25:41 +0900 | [diff] [blame] | 618 | if strings.HasPrefix(output, "out/soong/dexpreopt_arm64/dex_artjars_input/") { |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 619 | bootJarLocations = append(bootJarLocations, output) |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | sort.Strings(bootJarLocations) |
| 624 | expected := []string{} |
| 625 | for _, m := range modules { |
Jeongik Cha | 4753b39 | 2023-04-19 23:25:41 +0900 | [diff] [blame] | 626 | expected = append(expected, fmt.Sprintf("out/soong/dexpreopt_arm64/dex_artjars_input/%s.jar", m)) |
Paul Duffin | ce918b0 | 2021-06-07 14:33:47 +0100 | [diff] [blame] | 627 | } |
| 628 | sort.Strings(expected) |
| 629 | |
| 630 | android.AssertArrayString(t, "copies to predefined locations for art", expected, bootJarLocations) |
Paul Duffin | 9ea71c0 | 2021-03-23 22:53:07 +0000 | [diff] [blame] | 631 | } |
| 632 | |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 633 | func TestBootclasspathFragmentContentsNoName(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 634 | t.Parallel() |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 635 | result := android.GroupFixturePreparers( |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 636 | prepareForTestWithBootclasspathFragment, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 637 | prepareForTestWithMyapex, |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 638 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 639 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 640 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 641 | // is disabled. |
| 642 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 643 | |
| 644 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 645 | java.FixtureWithLastReleaseApis("foo"), |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 646 | ).RunTestWithBp(t, ` |
| 647 | apex { |
| 648 | name: "myapex", |
| 649 | key: "myapex.key", |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 650 | bootclasspath_fragments: [ |
| 651 | "mybootclasspathfragment", |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 652 | ], |
| 653 | updatable: false, |
| 654 | } |
| 655 | |
| 656 | apex_key { |
| 657 | name: "myapex.key", |
| 658 | public_key: "testkey.avbpubkey", |
| 659 | private_key: "testkey.pem", |
| 660 | } |
| 661 | |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 662 | java_sdk_library { |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 663 | name: "foo", |
| 664 | srcs: ["b.java"], |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 665 | shared_library: false, |
| 666 | public: {enabled: true}, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 667 | apex_available: [ |
| 668 | "myapex", |
| 669 | ], |
| 670 | } |
| 671 | |
| 672 | java_library { |
| 673 | name: "bar", |
| 674 | srcs: ["b.java"], |
| 675 | installable: true, |
| 676 | apex_available: [ |
| 677 | "myapex", |
| 678 | ], |
| 679 | } |
| 680 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 681 | bootclasspath_fragment { |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 682 | name: "mybootclasspathfragment", |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 683 | contents: [ |
| 684 | "foo", |
| 685 | "bar", |
| 686 | ], |
| 687 | apex_available: [ |
| 688 | "myapex", |
| 689 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 690 | hidden_api: { |
| 691 | split_packages: ["*"], |
| 692 | }, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 693 | } |
| 694 | `) |
| 695 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 696 | ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex", []string{ |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 697 | // This does not include art, oat or vdex files as they are only included for the art boot |
| 698 | // image. |
satayev | 227e745 | 2021-05-20 21:35:06 +0100 | [diff] [blame] | 699 | "etc/classpaths/bootclasspath.pb", |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 700 | "javalib/bar.jar", |
| 701 | "javalib/foo.jar", |
| 702 | }) |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 703 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 704 | java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{ |
Colin Cross | 388c661 | 2025-01-28 14:00:12 -0800 | [diff] [blame] | 705 | `all_apex_contributions`, |
Spandan Das | e21a8d4 | 2024-01-23 23:56:29 +0000 | [diff] [blame] | 706 | `dex2oatd`, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 707 | `myapex.key`, |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 708 | `mybootclasspathfragment`, |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 709 | }) |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 710 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 711 | apex := result.ModuleForTests("myapex", "android_common_myapex") |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 712 | apexRule := apex.Rule("apexRule") |
| 713 | copyCommands := apexRule.Args["copy_commands"] |
| 714 | |
| 715 | // Make sure that the fragment provides the hidden API encoded dex jars to the APEX. |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 716 | fragment := result.Module("mybootclasspathfragment", "android_common_myapex") |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 717 | |
Yu Liu | 663e450 | 2024-08-12 18:23:59 +0000 | [diff] [blame] | 718 | info, _ := android.OtherModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider) |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 719 | |
| 720 | checkFragmentExportedDexJar := func(name string, expectedDexJar string) { |
| 721 | module := result.Module(name, "android_common_apex10000") |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 722 | dexJar, err := info.DexBootJarPathForContentModule(module) |
| 723 | if err != nil { |
| 724 | t.Error(err) |
| 725 | } |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 726 | android.AssertPathRelativeToTopEquals(t, name+" dex", expectedDexJar, dexJar) |
| 727 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 728 | expectedCopyCommand := fmt.Sprintf("&& cp -f %s out/soong/.intermediates/myapex/android_common_myapex/image.apex/javalib/%s.jar", expectedDexJar, name) |
Paul Duffin | f2fa0b5 | 2021-05-14 18:21:45 +0100 | [diff] [blame] | 729 | android.AssertStringDoesContain(t, name+" apex copy command", copyCommands, expectedCopyCommand) |
| 730 | } |
| 731 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 732 | checkFragmentExportedDexJar("foo", "out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/hiddenapi-modular/encoded/foo.jar") |
| 733 | checkFragmentExportedDexJar("bar", "out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/hiddenapi-modular/encoded/bar.jar") |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 736 | func getDexJarPath(result *android.TestResult, name string) string { |
| 737 | module := result.Module(name, "android_common") |
Spandan Das | 59a4a2b | 2024-01-09 21:35:56 +0000 | [diff] [blame] | 738 | return module.(java.UsesLibraryDependency).DexJarBuildPath(moduleErrorfTestCtx{}).Path().RelativeToTop().String() |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | // TestBootclasspathFragment_HiddenAPIList checks to make sure that the correct parameters are |
| 742 | // passed to the hiddenapi list tool. |
| 743 | func TestBootclasspathFragment_HiddenAPIList(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 744 | t.Parallel() |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 745 | result := android.GroupFixturePreparers( |
| 746 | prepareForTestWithBootclasspathFragment, |
| 747 | prepareForTestWithArtApex, |
| 748 | prepareForTestWithMyapex, |
| 749 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
| 750 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 751 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 752 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 753 | // is disabled. |
| 754 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 755 | |
| 756 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 757 | java.FixtureWithLastReleaseApis("foo", "quuz"), |
Colin Cross | a66b463 | 2024-08-08 15:50:47 -0700 | [diff] [blame] | 758 | android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 759 | ).RunTestWithBp(t, ` |
| 760 | apex { |
| 761 | name: "com.android.art", |
| 762 | key: "com.android.art.key", |
| 763 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 764 | updatable: false, |
| 765 | } |
| 766 | |
| 767 | apex_key { |
| 768 | name: "com.android.art.key", |
| 769 | public_key: "com.android.art.avbpubkey", |
| 770 | private_key: "com.android.art.pem", |
| 771 | } |
| 772 | |
| 773 | java_library { |
| 774 | name: "baz", |
| 775 | apex_available: [ |
| 776 | "com.android.art", |
| 777 | ], |
| 778 | srcs: ["b.java"], |
| 779 | compile_dex: true, |
Jihoon Kang | 85bc193 | 2024-07-01 17:04:46 +0000 | [diff] [blame] | 780 | sdk_version: "core_current", |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 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 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 804 | hidden_api: { |
| 805 | split_packages: ["*"], |
| 806 | }, |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | apex { |
| 810 | name: "myapex", |
| 811 | key: "myapex.key", |
| 812 | bootclasspath_fragments: [ |
| 813 | "mybootclasspathfragment", |
| 814 | ], |
| 815 | updatable: false, |
| 816 | } |
| 817 | |
| 818 | apex_key { |
| 819 | name: "myapex.key", |
| 820 | public_key: "testkey.avbpubkey", |
| 821 | private_key: "testkey.pem", |
| 822 | } |
| 823 | |
| 824 | java_sdk_library { |
| 825 | name: "foo", |
| 826 | srcs: ["b.java"], |
| 827 | shared_library: false, |
| 828 | public: {enabled: true}, |
| 829 | apex_available: [ |
| 830 | "myapex", |
| 831 | ], |
| 832 | } |
| 833 | |
| 834 | java_library { |
| 835 | name: "bar", |
| 836 | srcs: ["b.java"], |
| 837 | installable: true, |
| 838 | apex_available: [ |
| 839 | "myapex", |
| 840 | ], |
| 841 | } |
| 842 | |
| 843 | bootclasspath_fragment { |
| 844 | name: "mybootclasspathfragment", |
| 845 | contents: [ |
| 846 | "foo", |
| 847 | "bar", |
| 848 | ], |
| 849 | apex_available: [ |
| 850 | "myapex", |
| 851 | ], |
| 852 | fragments: [ |
| 853 | { |
| 854 | apex: "com.android.art", |
| 855 | module: "art-bootclasspath-fragment", |
| 856 | }, |
| 857 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 858 | hidden_api: { |
| 859 | split_packages: ["*"], |
| 860 | }, |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 861 | } |
| 862 | `) |
| 863 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 864 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{ |
Spandan Das | 1679192 | 2024-09-06 00:49:31 +0000 | [diff] [blame] | 865 | "all_apex_contributions", |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 866 | "bar", |
Colin Cross | d649580 | 2025-01-14 15:50:48 -0800 | [diff] [blame] | 867 | "com.android.art", |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 868 | "dex2oatd", |
| 869 | "foo", |
| 870 | }) |
| 871 | |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 872 | fooStubs := getDexJarPath(result, "foo.stubs.exportable") |
| 873 | quuzPublicStubs := getDexJarPath(result, "quuz.stubs.exportable") |
| 874 | quuzSystemStubs := getDexJarPath(result, "quuz.stubs.exportable.system") |
| 875 | quuzTestStubs := getDexJarPath(result, "quuz.stubs.exportable.test") |
| 876 | quuzModuleLibStubs := getDexJarPath(result, "quuz.stubs.exportable.module_lib") |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 877 | |
| 878 | // Make sure that the fragment uses the quuz stub dex jars when generating the hidden API flags. |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 879 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex") |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 880 | |
| 881 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 882 | command := rule.RuleParams.Command |
| 883 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 884 | |
| 885 | // Make sure that the quuz stubs are available for resolving references from the implementation |
| 886 | // boot dex jars provided by this module. |
Paul Duffin | b51db2e | 2021-06-21 14:08:08 +0100 | [diff] [blame] | 887 | android.AssertStringDoesContain(t, "quuz widest", command, "--dependency-stub-dex="+quuzModuleLibStubs) |
Paul Duffin | 48b6741 | 2021-06-23 16:13:50 +0100 | [diff] [blame] | 888 | |
| 889 | // Make sure that the quuz stubs are available for resolving references from the different API |
| 890 | // stubs provided by this module. |
| 891 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+quuzPublicStubs+":"+fooStubs) |
| 892 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+quuzSystemStubs+":"+fooStubs) |
| 893 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+quuzTestStubs+":"+fooStubs) |
| 894 | } |
| 895 | |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 896 | // TestBootclasspathFragment_AndroidNonUpdatable checks to make sure that setting |
| 897 | // additional_stubs: ["android-non-updatable"] causes the source android-non-updatable modules to be |
| 898 | // added to the hiddenapi list tool. |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 899 | func TestBootclasspathFragment_AndroidNonUpdatable_FromSource(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 900 | t.Parallel() |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 901 | result := android.GroupFixturePreparers( |
| 902 | prepareForTestWithBootclasspathFragment, |
| 903 | prepareForTestWithArtApex, |
| 904 | prepareForTestWithMyapex, |
| 905 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 906 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 907 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 908 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 909 | // is disabled. |
| 910 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 911 | android.FixtureModifyConfig(func(config android.Config) { |
| 912 | config.SetBuildFromTextStub(false) |
| 913 | }), |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 914 | |
| 915 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 916 | java.FixtureWithLastReleaseApis("foo", "android-non-updatable"), |
| 917 | ).RunTestWithBp(t, ` |
| 918 | java_sdk_library { |
| 919 | name: "android-non-updatable", |
| 920 | srcs: ["b.java"], |
| 921 | compile_dex: true, |
| 922 | public: { |
| 923 | enabled: true, |
| 924 | }, |
| 925 | system: { |
| 926 | enabled: true, |
| 927 | }, |
| 928 | test: { |
| 929 | enabled: true, |
| 930 | }, |
| 931 | module_lib: { |
| 932 | enabled: true, |
| 933 | }, |
| 934 | } |
| 935 | |
| 936 | apex { |
| 937 | name: "com.android.art", |
| 938 | key: "com.android.art.key", |
| 939 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 940 | updatable: false, |
| 941 | } |
| 942 | |
| 943 | apex_key { |
| 944 | name: "com.android.art.key", |
| 945 | public_key: "com.android.art.avbpubkey", |
| 946 | private_key: "com.android.art.pem", |
| 947 | } |
| 948 | |
| 949 | java_library { |
| 950 | name: "baz", |
| 951 | apex_available: [ |
| 952 | "com.android.art", |
| 953 | ], |
| 954 | srcs: ["b.java"], |
| 955 | compile_dex: true, |
Jihoon Kang | 85bc193 | 2024-07-01 17:04:46 +0000 | [diff] [blame] | 956 | sdk_version: "core_current", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | java_library { |
| 960 | name: "quuz", |
| 961 | apex_available: [ |
| 962 | "com.android.art", |
| 963 | ], |
| 964 | srcs: ["b.java"], |
| 965 | compile_dex: true, |
| 966 | } |
| 967 | |
| 968 | bootclasspath_fragment { |
| 969 | name: "art-bootclasspath-fragment", |
| 970 | image_name: "art", |
| 971 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 972 | contents: ["baz", "quuz"], |
| 973 | apex_available: [ |
| 974 | "com.android.art", |
| 975 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 976 | hidden_api: { |
| 977 | split_packages: ["*"], |
| 978 | }, |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | apex { |
| 982 | name: "myapex", |
| 983 | key: "myapex.key", |
| 984 | bootclasspath_fragments: [ |
| 985 | "mybootclasspathfragment", |
| 986 | ], |
| 987 | updatable: false, |
| 988 | } |
| 989 | |
| 990 | apex_key { |
| 991 | name: "myapex.key", |
| 992 | public_key: "testkey.avbpubkey", |
| 993 | private_key: "testkey.pem", |
| 994 | } |
| 995 | |
| 996 | java_sdk_library { |
| 997 | name: "foo", |
| 998 | srcs: ["b.java"], |
| 999 | shared_library: false, |
| 1000 | public: {enabled: true}, |
| 1001 | apex_available: [ |
| 1002 | "myapex", |
| 1003 | ], |
| 1004 | } |
| 1005 | |
| 1006 | java_library { |
| 1007 | name: "bar", |
| 1008 | srcs: ["b.java"], |
| 1009 | installable: true, |
| 1010 | apex_available: [ |
| 1011 | "myapex", |
| 1012 | ], |
| 1013 | } |
| 1014 | |
| 1015 | bootclasspath_fragment { |
| 1016 | name: "mybootclasspathfragment", |
| 1017 | contents: [ |
| 1018 | "foo", |
| 1019 | "bar", |
| 1020 | ], |
| 1021 | apex_available: [ |
| 1022 | "myapex", |
| 1023 | ], |
| 1024 | additional_stubs: ["android-non-updatable"], |
| 1025 | fragments: [ |
| 1026 | { |
| 1027 | apex: "com.android.art", |
| 1028 | module: "art-bootclasspath-fragment", |
| 1029 | }, |
| 1030 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 1031 | hidden_api: { |
| 1032 | split_packages: ["*"], |
| 1033 | }, |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1034 | } |
| 1035 | `) |
| 1036 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1037 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{ |
Spandan Das | 1679192 | 2024-09-06 00:49:31 +0000 | [diff] [blame] | 1038 | "all_apex_contributions", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1039 | "android-non-updatable.stubs", |
| 1040 | "android-non-updatable.stubs.module_lib", |
| 1041 | "android-non-updatable.stubs.system", |
| 1042 | "android-non-updatable.stubs.test", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1043 | "bar", |
Colin Cross | d649580 | 2025-01-14 15:50:48 -0800 | [diff] [blame] | 1044 | "com.android.art", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1045 | "dex2oatd", |
| 1046 | "foo", |
| 1047 | }) |
| 1048 | |
| 1049 | nonUpdatablePublicStubs := getDexJarPath(result, "android-non-updatable.stubs") |
| 1050 | nonUpdatableSystemStubs := getDexJarPath(result, "android-non-updatable.stubs.system") |
| 1051 | nonUpdatableTestStubs := getDexJarPath(result, "android-non-updatable.stubs.test") |
| 1052 | nonUpdatableModuleLibStubs := getDexJarPath(result, "android-non-updatable.stubs.module_lib") |
| 1053 | |
| 1054 | // Make sure that the fragment uses the android-non-updatable modules when generating the hidden |
| 1055 | // API flags. |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1056 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex") |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1057 | |
| 1058 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 1059 | command := rule.RuleParams.Command |
| 1060 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 1061 | |
| 1062 | // Make sure that the module_lib non-updatable stubs are available for resolving references from |
| 1063 | // the implementation boot dex jars provided by this module. |
| 1064 | android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs) |
| 1065 | |
| 1066 | // Make sure that the appropriate non-updatable stubs are available for resolving references from |
| 1067 | // the different API stubs provided by this module. |
| 1068 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs) |
| 1069 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs) |
| 1070 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs) |
| 1071 | } |
| 1072 | |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1073 | func TestBootclasspathFragment_AndroidNonUpdatable_FromText(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 1074 | t.Parallel() |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1075 | result := android.GroupFixturePreparers( |
| 1076 | prepareForTestWithBootclasspathFragment, |
| 1077 | prepareForTestWithArtApex, |
| 1078 | prepareForTestWithMyapex, |
| 1079 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
| 1080 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 1081 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
| 1082 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 1083 | // is disabled. |
| 1084 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 1085 | android.FixtureModifyConfig(func(config android.Config) { |
| 1086 | config.SetBuildFromTextStub(true) |
| 1087 | }), |
| 1088 | |
| 1089 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 1090 | java.FixtureWithLastReleaseApis("foo", "android-non-updatable"), |
| 1091 | ).RunTestWithBp(t, ` |
| 1092 | java_sdk_library { |
| 1093 | name: "android-non-updatable", |
| 1094 | srcs: ["b.java"], |
| 1095 | compile_dex: true, |
| 1096 | public: { |
| 1097 | enabled: true, |
| 1098 | }, |
| 1099 | system: { |
| 1100 | enabled: true, |
| 1101 | }, |
| 1102 | test: { |
| 1103 | enabled: true, |
| 1104 | }, |
| 1105 | module_lib: { |
| 1106 | enabled: true, |
| 1107 | }, |
| 1108 | } |
| 1109 | |
| 1110 | apex { |
| 1111 | name: "com.android.art", |
| 1112 | key: "com.android.art.key", |
| 1113 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
| 1114 | updatable: false, |
| 1115 | } |
| 1116 | |
| 1117 | apex_key { |
| 1118 | name: "com.android.art.key", |
| 1119 | public_key: "com.android.art.avbpubkey", |
| 1120 | private_key: "com.android.art.pem", |
| 1121 | } |
| 1122 | |
| 1123 | java_library { |
| 1124 | name: "baz", |
| 1125 | apex_available: [ |
| 1126 | "com.android.art", |
| 1127 | ], |
| 1128 | srcs: ["b.java"], |
| 1129 | compile_dex: true, |
Jihoon Kang | 85bc193 | 2024-07-01 17:04:46 +0000 | [diff] [blame] | 1130 | sdk_version: "core_current", |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | java_library { |
| 1134 | name: "quuz", |
| 1135 | apex_available: [ |
| 1136 | "com.android.art", |
| 1137 | ], |
| 1138 | srcs: ["b.java"], |
| 1139 | compile_dex: true, |
| 1140 | } |
| 1141 | |
| 1142 | bootclasspath_fragment { |
| 1143 | name: "art-bootclasspath-fragment", |
| 1144 | image_name: "art", |
| 1145 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 1146 | contents: ["baz", "quuz"], |
| 1147 | apex_available: [ |
| 1148 | "com.android.art", |
| 1149 | ], |
| 1150 | hidden_api: { |
| 1151 | split_packages: ["*"], |
| 1152 | }, |
| 1153 | } |
| 1154 | |
| 1155 | apex { |
| 1156 | name: "myapex", |
| 1157 | key: "myapex.key", |
| 1158 | bootclasspath_fragments: [ |
| 1159 | "mybootclasspathfragment", |
| 1160 | ], |
| 1161 | updatable: false, |
| 1162 | } |
| 1163 | |
| 1164 | apex_key { |
| 1165 | name: "myapex.key", |
| 1166 | public_key: "testkey.avbpubkey", |
| 1167 | private_key: "testkey.pem", |
| 1168 | } |
| 1169 | |
| 1170 | java_sdk_library { |
| 1171 | name: "foo", |
| 1172 | srcs: ["b.java"], |
| 1173 | shared_library: false, |
| 1174 | public: {enabled: true}, |
| 1175 | apex_available: [ |
| 1176 | "myapex", |
| 1177 | ], |
| 1178 | } |
| 1179 | |
| 1180 | java_library { |
| 1181 | name: "bar", |
| 1182 | srcs: ["b.java"], |
| 1183 | installable: true, |
| 1184 | apex_available: [ |
| 1185 | "myapex", |
| 1186 | ], |
| 1187 | } |
| 1188 | |
| 1189 | bootclasspath_fragment { |
| 1190 | name: "mybootclasspathfragment", |
| 1191 | contents: [ |
| 1192 | "foo", |
| 1193 | "bar", |
| 1194 | ], |
| 1195 | apex_available: [ |
| 1196 | "myapex", |
| 1197 | ], |
| 1198 | additional_stubs: ["android-non-updatable"], |
| 1199 | fragments: [ |
| 1200 | { |
| 1201 | apex: "com.android.art", |
| 1202 | module: "art-bootclasspath-fragment", |
| 1203 | }, |
| 1204 | ], |
| 1205 | hidden_api: { |
| 1206 | split_packages: ["*"], |
| 1207 | }, |
| 1208 | } |
| 1209 | `) |
| 1210 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1211 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{ |
Spandan Das | 1679192 | 2024-09-06 00:49:31 +0000 | [diff] [blame] | 1212 | "all_apex_contributions", |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1213 | "android-non-updatable.stubs", |
| 1214 | "android-non-updatable.stubs.system", |
| 1215 | "android-non-updatable.stubs.test", |
| 1216 | "android-non-updatable.stubs.test_module_lib", |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1217 | "bar", |
Colin Cross | d649580 | 2025-01-14 15:50:48 -0800 | [diff] [blame] | 1218 | "com.android.art", |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1219 | "dex2oatd", |
| 1220 | "foo", |
| 1221 | }) |
| 1222 | |
| 1223 | nonUpdatableTestModuleLibStubs := getDexJarPath(result, "android-non-updatable.stubs.test_module_lib") |
| 1224 | |
| 1225 | // Make sure that the fragment uses the android-non-updatable modules when generating the hidden |
| 1226 | // API flags. |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1227 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex") |
Jihoon Kang | cc9e218 | 2023-10-16 23:13:33 +0000 | [diff] [blame] | 1228 | |
| 1229 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 1230 | command := rule.RuleParams.Command |
| 1231 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 1232 | |
| 1233 | // Make sure that the test_module_lib non-updatable stubs are available for resolving references from |
| 1234 | // the implementation boot dex jars provided by this module. |
| 1235 | android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableTestModuleLibStubs) |
| 1236 | } |
| 1237 | |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1238 | // TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks checks to make sure that |
| 1239 | // setting additional_stubs: ["android-non-updatable"] causes the prebuilt android-non-updatable |
| 1240 | // modules to be added to the hiddenapi list tool. |
| 1241 | func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 1242 | t.Parallel() |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1243 | result := android.GroupFixturePreparers( |
| 1244 | prepareForTestWithBootclasspathFragment, |
Jiakai Zhang | b95998b | 2023-05-11 16:39:27 +0100 | [diff] [blame] | 1245 | java.PrepareForTestWithDexpreopt, |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1246 | prepareForTestWithArtApex, |
| 1247 | prepareForTestWithMyapex, |
| 1248 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 1249 | java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), |
| 1250 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1251 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 1252 | // is disabled. |
| 1253 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 1254 | |
| 1255 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 1256 | variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) |
| 1257 | }), |
| 1258 | |
| 1259 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 1260 | java.FixtureWithPrebuiltApis(map[string][]string{ |
| 1261 | "current": {"android-non-updatable"}, |
| 1262 | "30": {"foo"}, |
| 1263 | }), |
| 1264 | ).RunTestWithBp(t, ` |
| 1265 | apex { |
| 1266 | name: "com.android.art", |
| 1267 | key: "com.android.art.key", |
| 1268 | bootclasspath_fragments: ["art-bootclasspath-fragment"], |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1269 | updatable: false, |
| 1270 | } |
| 1271 | |
| 1272 | apex_key { |
| 1273 | name: "com.android.art.key", |
| 1274 | public_key: "com.android.art.avbpubkey", |
| 1275 | private_key: "com.android.art.pem", |
| 1276 | } |
| 1277 | |
| 1278 | java_library { |
| 1279 | name: "baz", |
| 1280 | apex_available: [ |
| 1281 | "com.android.art", |
| 1282 | ], |
| 1283 | srcs: ["b.java"], |
| 1284 | compile_dex: true, |
Jihoon Kang | 85bc193 | 2024-07-01 17:04:46 +0000 | [diff] [blame] | 1285 | sdk_version: "core_current", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1286 | } |
| 1287 | |
| 1288 | java_library { |
| 1289 | name: "quuz", |
| 1290 | apex_available: [ |
| 1291 | "com.android.art", |
| 1292 | ], |
| 1293 | srcs: ["b.java"], |
| 1294 | compile_dex: true, |
| 1295 | } |
| 1296 | |
| 1297 | bootclasspath_fragment { |
| 1298 | name: "art-bootclasspath-fragment", |
| 1299 | image_name: "art", |
| 1300 | // Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above. |
| 1301 | contents: ["baz", "quuz"], |
| 1302 | apex_available: [ |
| 1303 | "com.android.art", |
| 1304 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 1305 | hidden_api: { |
| 1306 | split_packages: ["*"], |
| 1307 | }, |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | apex { |
| 1311 | name: "myapex", |
| 1312 | key: "myapex.key", |
| 1313 | bootclasspath_fragments: [ |
| 1314 | "mybootclasspathfragment", |
| 1315 | ], |
| 1316 | updatable: false, |
| 1317 | } |
| 1318 | |
| 1319 | apex_key { |
| 1320 | name: "myapex.key", |
| 1321 | public_key: "testkey.avbpubkey", |
| 1322 | private_key: "testkey.pem", |
| 1323 | } |
| 1324 | |
| 1325 | java_sdk_library { |
| 1326 | name: "foo", |
| 1327 | srcs: ["b.java"], |
| 1328 | shared_library: false, |
| 1329 | public: {enabled: true}, |
| 1330 | apex_available: [ |
| 1331 | "myapex", |
| 1332 | ], |
| 1333 | } |
| 1334 | |
| 1335 | java_library { |
| 1336 | name: "bar", |
| 1337 | srcs: ["b.java"], |
| 1338 | installable: true, |
| 1339 | apex_available: [ |
| 1340 | "myapex", |
| 1341 | ], |
| 1342 | } |
| 1343 | |
| 1344 | bootclasspath_fragment { |
| 1345 | name: "mybootclasspathfragment", |
| 1346 | contents: [ |
| 1347 | "foo", |
| 1348 | "bar", |
| 1349 | ], |
| 1350 | apex_available: [ |
| 1351 | "myapex", |
| 1352 | ], |
| 1353 | additional_stubs: ["android-non-updatable"], |
| 1354 | fragments: [ |
| 1355 | { |
| 1356 | apex: "com.android.art", |
| 1357 | module: "art-bootclasspath-fragment", |
| 1358 | }, |
| 1359 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 1360 | hidden_api: { |
| 1361 | split_packages: ["*"], |
| 1362 | }, |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1363 | } |
| 1364 | `) |
| 1365 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1366 | java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{ |
Spandan Das | 1679192 | 2024-09-06 00:49:31 +0000 | [diff] [blame] | 1367 | "all_apex_contributions", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1368 | "bar", |
Colin Cross | d649580 | 2025-01-14 15:50:48 -0800 | [diff] [blame] | 1369 | "com.android.art", |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1370 | "dex2oatd", |
| 1371 | "foo", |
| 1372 | "prebuilt_sdk_module-lib_current_android-non-updatable", |
| 1373 | "prebuilt_sdk_public_current_android-non-updatable", |
| 1374 | "prebuilt_sdk_system_current_android-non-updatable", |
| 1375 | "prebuilt_sdk_test_current_android-non-updatable", |
| 1376 | }) |
| 1377 | |
| 1378 | nonUpdatablePublicStubs := getDexJarPath(result, "sdk_public_current_android-non-updatable") |
| 1379 | nonUpdatableSystemStubs := getDexJarPath(result, "sdk_system_current_android-non-updatable") |
| 1380 | nonUpdatableTestStubs := getDexJarPath(result, "sdk_test_current_android-non-updatable") |
| 1381 | nonUpdatableModuleLibStubs := getDexJarPath(result, "sdk_module-lib_current_android-non-updatable") |
| 1382 | |
| 1383 | // Make sure that the fragment uses the android-non-updatable modules when generating the hidden |
| 1384 | // API flags. |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1385 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex") |
Paul Duffin | 5cca7c4 | 2021-05-26 10:16:01 +0100 | [diff] [blame] | 1386 | |
| 1387 | rule := fragment.Rule("modularHiddenAPIStubFlagsFile") |
| 1388 | command := rule.RuleParams.Command |
| 1389 | android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list") |
| 1390 | |
| 1391 | // Make sure that the module_lib non-updatable stubs are available for resolving references from |
| 1392 | // the implementation boot dex jars provided by this module. |
| 1393 | android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs) |
| 1394 | |
| 1395 | // Make sure that the appropriate non-updatable stubs are available for resolving references from |
| 1396 | // the different API stubs provided by this module. |
| 1397 | android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs) |
| 1398 | android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs) |
| 1399 | android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs) |
| 1400 | } |
| 1401 | |
Spandan Das | fcea0a8 | 2024-06-12 18:22:46 +0000 | [diff] [blame] | 1402 | func TestBootclasspathFragmentProtoContainsMinSdkVersion(t *testing.T) { |
Colin Cross | a2fdb61 | 2024-10-11 12:52:56 -0700 | [diff] [blame] | 1403 | t.Parallel() |
Spandan Das | fcea0a8 | 2024-06-12 18:22:46 +0000 | [diff] [blame] | 1404 | result := android.GroupFixturePreparers( |
| 1405 | prepareForTestWithBootclasspathFragment, |
| 1406 | prepareForTestWithMyapex, |
| 1407 | // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. |
| 1408 | java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), |
| 1409 | // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding |
| 1410 | // is disabled. |
| 1411 | android.FixtureAddTextFile("frameworks/base/Android.bp", ""), |
| 1412 | |
| 1413 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 1414 | java.FixtureWithLastReleaseApis("foo", "bar"), |
| 1415 | ).RunTestWithBp(t, ` |
| 1416 | apex { |
| 1417 | name: "myapex", |
| 1418 | key: "myapex.key", |
| 1419 | bootclasspath_fragments: [ |
| 1420 | "mybootclasspathfragment", |
| 1421 | ], |
| 1422 | updatable: false, |
| 1423 | } |
| 1424 | |
| 1425 | apex_key { |
| 1426 | name: "myapex.key", |
| 1427 | public_key: "testkey.avbpubkey", |
| 1428 | private_key: "testkey.pem", |
| 1429 | } |
| 1430 | |
| 1431 | java_sdk_library { |
| 1432 | name: "foo", |
| 1433 | srcs: ["b.java"], |
| 1434 | shared_library: false, |
| 1435 | public: {enabled: true}, |
| 1436 | apex_available: [ |
| 1437 | "myapex", |
| 1438 | ], |
| 1439 | min_sdk_version: "33", |
| 1440 | } |
| 1441 | |
| 1442 | java_sdk_library { |
| 1443 | name: "bar", |
| 1444 | srcs: ["b.java"], |
| 1445 | shared_library: false, |
| 1446 | public: {enabled: true}, |
| 1447 | apex_available: [ |
| 1448 | "myapex", |
| 1449 | ], |
| 1450 | min_sdk_version: "34", |
| 1451 | } |
| 1452 | |
| 1453 | bootclasspath_fragment { |
| 1454 | name: "mybootclasspathfragment", |
| 1455 | contents: [ |
| 1456 | "foo", |
| 1457 | "bar", |
| 1458 | ], |
| 1459 | apex_available: [ |
| 1460 | "myapex", |
| 1461 | ], |
| 1462 | hidden_api: { |
| 1463 | split_packages: ["*"], |
| 1464 | }, |
| 1465 | } |
| 1466 | `) |
| 1467 | |
Colin Cross | e5c7d7c | 2024-12-18 17:08:07 -0800 | [diff] [blame] | 1468 | fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex") |
Spandan Das | fcea0a8 | 2024-06-12 18:22:46 +0000 | [diff] [blame] | 1469 | classPathProtoContent := android.ContentFromFileRuleForTests(t, result.TestContext, fragment.Output("bootclasspath.pb.textproto")) |
| 1470 | // foo |
| 1471 | ensureContains(t, classPathProtoContent, `jars { |
| 1472 | path: "/apex/myapex/javalib/foo.jar" |
| 1473 | classpath: BOOTCLASSPATH |
| 1474 | min_sdk_version: "33" |
| 1475 | max_sdk_version: "" |
| 1476 | } |
| 1477 | `) |
| 1478 | // bar |
| 1479 | ensureContains(t, classPathProtoContent, `jars { |
| 1480 | path: "/apex/myapex/javalib/bar.jar" |
| 1481 | classpath: BOOTCLASSPATH |
| 1482 | min_sdk_version: "34" |
| 1483 | max_sdk_version: "" |
| 1484 | } |
| 1485 | `) |
| 1486 | } |
| 1487 | |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 1488 | // TODO(b/177892522) - add test for host apex. |