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