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