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