Paul Duffin | f7f65da | 2021-03-10 15:00:46 +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 sdk |
| 16 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 17 | import ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 21 | "android/soong/java" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 22 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 23 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 24 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { |
| 25 | result := android.GroupFixturePreparers( |
| 26 | prepareForSdkTestWithJava, |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 27 | java.PrepareForTestWithJavaDefaultModules, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 28 | prepareForSdkTestWithApex, |
| 29 | |
| 30 | // Some additional files needed for the art apex. |
| 31 | android.FixtureMergeMockFs(android.MockFS{ |
| 32 | "com.android.art.avbpubkey": nil, |
| 33 | "com.android.art.pem": nil, |
| 34 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 35 | }), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 36 | |
| 37 | // platform_bootclasspath that depends on the fragment. |
| 38 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", ` |
| 39 | platform_bootclasspath { |
| 40 | name: "platform-bootclasspath", |
| 41 | fragments: [ |
| 42 | { |
| 43 | apex: "com.android.art", |
| 44 | module: "mybootclasspathfragment", |
| 45 | }, |
| 46 | ], |
| 47 | } |
| 48 | `), |
Paul Duffin | 2ac45f0 | 2021-04-26 17:08:38 +0100 | [diff] [blame] | 49 | // Needed for platform_bootclasspath |
| 50 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 51 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 52 | java.FixtureConfigureBootJars("com.android.art:mybootlib"), |
| 53 | android.FixtureWithRootAndroidBp(` |
| 54 | sdk { |
| 55 | name: "mysdk", |
| 56 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | apex { |
| 60 | name: "com.android.art", |
| 61 | key: "com.android.art.key", |
| 62 | bootclasspath_fragments: [ |
| 63 | "mybootclasspathfragment", |
| 64 | ], |
| 65 | updatable: false, |
| 66 | } |
| 67 | |
| 68 | bootclasspath_fragment { |
| 69 | name: "mybootclasspathfragment", |
| 70 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame^] | 71 | contents: ["mybootlib"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 72 | apex_available: ["com.android.art"], |
| 73 | } |
| 74 | |
| 75 | apex_key { |
| 76 | name: "com.android.art.key", |
| 77 | public_key: "com.android.art.avbpubkey", |
| 78 | private_key: "com.android.art.pem", |
| 79 | } |
| 80 | |
| 81 | java_library { |
| 82 | name: "mybootlib", |
| 83 | srcs: ["Test.java"], |
| 84 | system_modules: "none", |
| 85 | sdk_version: "none", |
| 86 | compile_dex: true, |
| 87 | apex_available: ["com.android.art"], |
| 88 | } |
| 89 | `), |
| 90 | ).RunTest(t) |
| 91 | |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 92 | // A preparer to add a prebuilt apex to the test fixture. |
| 93 | prepareWithPrebuiltApex := android.GroupFixturePreparers( |
| 94 | android.FixtureAddTextFile("prebuilts/apex/Android.bp", ` |
| 95 | prebuilt_apex { |
| 96 | name: "com.android.art", |
| 97 | src: "art.apex", |
| 98 | exported_java_libs: [ |
| 99 | "mybootlib", |
| 100 | ], |
| 101 | exported_bootclasspath_fragments: [ |
| 102 | "mybootclasspathfragment", |
| 103 | ], |
| 104 | } |
| 105 | `), |
| 106 | android.FixtureAddFile("prebuilts/apex/art.apex", nil), |
| 107 | ) |
| 108 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 109 | CheckSnapshot(t, result, "mysdk", "", |
| 110 | checkUnversionedAndroidBpContents(` |
| 111 | // This is auto-generated. DO NOT EDIT. |
| 112 | |
| 113 | prebuilt_bootclasspath_fragment { |
| 114 | name: "mybootclasspathfragment", |
| 115 | prefer: false, |
| 116 | visibility: ["//visibility:public"], |
| 117 | apex_available: ["com.android.art"], |
| 118 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 119 | contents: ["mybootlib"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | java_import { |
| 123 | name: "mybootlib", |
| 124 | prefer: false, |
| 125 | visibility: ["//visibility:public"], |
| 126 | apex_available: ["com.android.art"], |
| 127 | jars: ["java/mybootlib.jar"], |
| 128 | } |
| 129 | `), |
| 130 | checkVersionedAndroidBpContents(` |
| 131 | // This is auto-generated. DO NOT EDIT. |
| 132 | |
| 133 | prebuilt_bootclasspath_fragment { |
| 134 | name: "mysdk_mybootclasspathfragment@current", |
| 135 | sdk_member_name: "mybootclasspathfragment", |
| 136 | visibility: ["//visibility:public"], |
| 137 | apex_available: ["com.android.art"], |
| 138 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 139 | contents: ["mysdk_mybootlib@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | java_import { |
| 143 | name: "mysdk_mybootlib@current", |
| 144 | sdk_member_name: "mybootlib", |
| 145 | visibility: ["//visibility:public"], |
| 146 | apex_available: ["com.android.art"], |
| 147 | jars: ["java/mybootlib.jar"], |
| 148 | } |
| 149 | |
| 150 | sdk_snapshot { |
| 151 | name: "mysdk@current", |
| 152 | visibility: ["//visibility:public"], |
| 153 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
| 154 | java_boot_libs: ["mysdk_mybootlib@current"], |
| 155 | } |
| 156 | `), |
| 157 | checkAllCopyRules(` |
| 158 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
| 159 | `), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 160 | snapshotTestPreparer(checkSnapshotWithoutSource, prepareWithPrebuiltApex), |
| 161 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, prepareWithPrebuiltApex), |
| 162 | snapshotTestPreparer(checkSnapshotPreferredWithSource, prepareWithPrebuiltApex), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 163 | ) |
| 164 | } |
| 165 | |
| 166 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 167 | result := android.GroupFixturePreparers( |
| 168 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 169 | java.PrepareForTestWithJavaDefaultModules, |
| 170 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 171 | java.FixtureWithLastReleaseApis("mysdklibrary", "mycoreplatform"), |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 172 | android.FixtureWithRootAndroidBp(` |
| 173 | sdk { |
| 174 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 175 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 176 | java_sdk_libs: ["mysdklibrary", "mycoreplatform"], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 177 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 178 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 179 | bootclasspath_fragment { |
| 180 | name: "mybootclasspathfragment", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 181 | contents: ["mybootlib"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 182 | api: { |
| 183 | stub_libs: ["mysdklibrary"], |
| 184 | }, |
| 185 | core_platform_api: { |
| 186 | stub_libs: ["mycoreplatform"], |
| 187 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | java_library { |
| 191 | name: "mybootlib", |
| 192 | srcs: ["Test.java"], |
| 193 | system_modules: "none", |
| 194 | sdk_version: "none", |
| 195 | compile_dex: true, |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 196 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 197 | |
| 198 | java_sdk_library { |
| 199 | name: "mysdklibrary", |
| 200 | srcs: ["Test.java"], |
| 201 | compile_dex: true, |
| 202 | public: {enabled: true}, |
| 203 | } |
| 204 | |
| 205 | java_sdk_library { |
| 206 | name: "mycoreplatform", |
| 207 | srcs: ["Test.java"], |
| 208 | compile_dex: true, |
| 209 | public: {enabled: true}, |
| 210 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 211 | `), |
| 212 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 213 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 214 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 215 | checkUnversionedAndroidBpContents(` |
| 216 | // This is auto-generated. DO NOT EDIT. |
| 217 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 218 | prebuilt_bootclasspath_fragment { |
| 219 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 220 | prefer: false, |
| 221 | visibility: ["//visibility:public"], |
| 222 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 223 | contents: ["mybootlib"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 224 | api: { |
| 225 | stub_libs: ["mysdklibrary"], |
| 226 | }, |
| 227 | core_platform_api: { |
| 228 | stub_libs: ["mycoreplatform"], |
| 229 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | java_import { |
| 233 | name: "mybootlib", |
| 234 | prefer: false, |
| 235 | visibility: ["//visibility:public"], |
| 236 | apex_available: ["//apex_available:platform"], |
| 237 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 238 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 239 | |
| 240 | java_sdk_library_import { |
| 241 | name: "mysdklibrary", |
| 242 | prefer: false, |
| 243 | visibility: ["//visibility:public"], |
| 244 | apex_available: ["//apex_available:platform"], |
| 245 | shared_library: true, |
| 246 | compile_dex: true, |
| 247 | public: { |
| 248 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 249 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 250 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 251 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 252 | sdk_version: "current", |
| 253 | }, |
| 254 | } |
| 255 | |
| 256 | java_sdk_library_import { |
| 257 | name: "mycoreplatform", |
| 258 | prefer: false, |
| 259 | visibility: ["//visibility:public"], |
| 260 | apex_available: ["//apex_available:platform"], |
| 261 | shared_library: true, |
| 262 | compile_dex: true, |
| 263 | public: { |
| 264 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 265 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 266 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 267 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 268 | sdk_version: "current", |
| 269 | }, |
| 270 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 271 | `), |
| 272 | checkVersionedAndroidBpContents(` |
| 273 | // This is auto-generated. DO NOT EDIT. |
| 274 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 275 | prebuilt_bootclasspath_fragment { |
| 276 | name: "mysdk_mybootclasspathfragment@current", |
| 277 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 278 | visibility: ["//visibility:public"], |
| 279 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 280 | contents: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 281 | api: { |
| 282 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 283 | }, |
| 284 | core_platform_api: { |
| 285 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 286 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | java_import { |
| 290 | name: "mysdk_mybootlib@current", |
| 291 | sdk_member_name: "mybootlib", |
| 292 | visibility: ["//visibility:public"], |
| 293 | apex_available: ["//apex_available:platform"], |
| 294 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 297 | java_sdk_library_import { |
| 298 | name: "mysdk_mysdklibrary@current", |
| 299 | sdk_member_name: "mysdklibrary", |
| 300 | visibility: ["//visibility:public"], |
| 301 | apex_available: ["//apex_available:platform"], |
| 302 | shared_library: true, |
| 303 | compile_dex: true, |
| 304 | public: { |
| 305 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 306 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 307 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 308 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 309 | sdk_version: "current", |
| 310 | }, |
| 311 | } |
| 312 | |
| 313 | java_sdk_library_import { |
| 314 | name: "mysdk_mycoreplatform@current", |
| 315 | sdk_member_name: "mycoreplatform", |
| 316 | visibility: ["//visibility:public"], |
| 317 | apex_available: ["//apex_available:platform"], |
| 318 | shared_library: true, |
| 319 | compile_dex: true, |
| 320 | public: { |
| 321 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 322 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 323 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 324 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 325 | sdk_version: "current", |
| 326 | }, |
| 327 | } |
| 328 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 329 | sdk_snapshot { |
| 330 | name: "mysdk@current", |
| 331 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 332 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 333 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 334 | java_sdk_libs: [ |
| 335 | "mysdk_mysdklibrary@current", |
| 336 | "mysdk_mycoreplatform@current", |
| 337 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 338 | } |
| 339 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 340 | checkAllCopyRules(` |
| 341 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 342 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 343 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 344 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 345 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 346 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 347 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 348 | `)) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 349 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 350 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 351 | // Test that bootclasspath_fragment works with sdk. |
| 352 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 353 | android.GroupFixturePreparers( |
| 354 | prepareForSdkTestWithApex, |
| 355 | prepareForSdkTestWithJava, |
| 356 | android.FixtureWithRootAndroidBp(` |
| 357 | sdk { |
| 358 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 359 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 362 | bootclasspath_fragment { |
| 363 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 364 | image_name: "art", |
| 365 | apex_available: ["myapex"], |
| 366 | } |
| 367 | |
| 368 | sdk_snapshot { |
| 369 | name: "mysdk@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 370 | bootclasspath_fragments: ["mybootclasspathfragment_mysdk_1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 373 | prebuilt_bootclasspath_fragment { |
| 374 | name: "mybootclasspathfragment_mysdk_1", |
| 375 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 376 | prefer: false, |
| 377 | visibility: ["//visibility:public"], |
| 378 | apex_available: [ |
| 379 | "myapex", |
| 380 | ], |
| 381 | image_name: "art", |
| 382 | } |
| 383 | `), |
| 384 | ).RunTest(t) |
| 385 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 386 | |
| 387 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 388 | result := android.GroupFixturePreparers( |
| 389 | prepareForSdkTestWithJava, |
| 390 | android.MockFS{ |
| 391 | "my-blocked.txt": nil, |
| 392 | "my-max-target-o-low-priority.txt": nil, |
| 393 | "my-max-target-p.txt": nil, |
| 394 | "my-max-target-q.txt": nil, |
| 395 | "my-max-target-r-low-priority.txt": nil, |
| 396 | "my-removed.txt": nil, |
| 397 | "my-unsupported-packages.txt": nil, |
| 398 | "my-unsupported.txt": nil, |
| 399 | }.AddToFixture(), |
| 400 | android.FixtureWithRootAndroidBp(` |
| 401 | sdk { |
| 402 | name: "mysdk", |
| 403 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | bootclasspath_fragment { |
| 407 | name: "mybootclasspathfragment", |
| 408 | contents: ["mybootlib"], |
| 409 | hidden_api: { |
| 410 | unsupported: [ |
| 411 | "my-unsupported.txt", |
| 412 | ], |
| 413 | removed: [ |
| 414 | "my-removed.txt", |
| 415 | ], |
| 416 | max_target_r_low_priority: [ |
| 417 | "my-max-target-r-low-priority.txt", |
| 418 | ], |
| 419 | max_target_q: [ |
| 420 | "my-max-target-q.txt", |
| 421 | ], |
| 422 | max_target_p: [ |
| 423 | "my-max-target-p.txt", |
| 424 | ], |
| 425 | max_target_o_low_priority: [ |
| 426 | "my-max-target-o-low-priority.txt", |
| 427 | ], |
| 428 | blocked: [ |
| 429 | "my-blocked.txt", |
| 430 | ], |
| 431 | unsupported_packages: [ |
| 432 | "my-unsupported-packages.txt", |
| 433 | ], |
| 434 | }, |
| 435 | } |
| 436 | |
| 437 | java_library { |
| 438 | name: "mybootlib", |
| 439 | srcs: ["Test.java"], |
| 440 | system_modules: "none", |
| 441 | sdk_version: "none", |
| 442 | compile_dex: true, |
| 443 | } |
| 444 | `), |
| 445 | ).RunTest(t) |
| 446 | |
| 447 | CheckSnapshot(t, result, "mysdk", "", |
| 448 | checkUnversionedAndroidBpContents(` |
| 449 | // This is auto-generated. DO NOT EDIT. |
| 450 | |
| 451 | prebuilt_bootclasspath_fragment { |
| 452 | name: "mybootclasspathfragment", |
| 453 | prefer: false, |
| 454 | visibility: ["//visibility:public"], |
| 455 | apex_available: ["//apex_available:platform"], |
| 456 | contents: ["mybootlib"], |
| 457 | hidden_api: { |
| 458 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 459 | removed: ["hiddenapi/my-removed.txt"], |
| 460 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 461 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 462 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 463 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 464 | blocked: ["hiddenapi/my-blocked.txt"], |
| 465 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
| 466 | }, |
| 467 | } |
| 468 | |
| 469 | java_import { |
| 470 | name: "mybootlib", |
| 471 | prefer: false, |
| 472 | visibility: ["//visibility:public"], |
| 473 | apex_available: ["//apex_available:platform"], |
| 474 | jars: ["java/mybootlib.jar"], |
| 475 | } |
| 476 | `), |
| 477 | checkAllCopyRules(` |
| 478 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 479 | my-removed.txt -> hiddenapi/my-removed.txt |
| 480 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 481 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 482 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 483 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 484 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 485 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
| 486 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
| 487 | `), |
| 488 | ) |
| 489 | } |