blob: 2dacdb55cf74a455d0857fb242968385c355323e [file] [log] [blame]
Paul Duffinf7f65da2021-03-10 15:00:46 +00001// 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
15package sdk
16
Paul Duffin4a1d4512021-03-18 10:12:26 +000017import (
Paul Duffin7c475152021-06-09 16:17:58 +010018 "fmt"
19 "path/filepath"
Paul Duffin4a1d4512021-03-18 10:12:26 +000020 "testing"
21
22 "android/soong/android"
Paul Duffina57835e2021-04-19 13:23:06 +010023 "android/soong/java"
Paul Duffin4a1d4512021-03-18 10:12:26 +000024)
Paul Duffinf7f65da2021-03-10 15:00:46 +000025
Paul Duffin7c475152021-06-09 16:17:58 +010026// fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that
27// references the bootclasspath fragment.
28func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer {
29 return android.GroupFixturePreparers(
30 // Add a platform_bootclasspath module.
31 android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(`
32 platform_bootclasspath {
33 name: "platform-bootclasspath",
34 fragments: [
35 {
36 apex: "%s",
37 module: "%s",
38 },
39 ],
40 }
41 `, apex, fragment)),
42 android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil),
Jiakai Zhang49b1eb62021-11-26 18:09:27 +000043 android.FixtureAddFile("frameworks/base/config/boot-image-profile.txt", nil),
Paul Duffinc8ead412021-06-07 19:28:15 +010044 android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil),
Paul Duffin7c475152021-06-09 16:17:58 +010045 )
46}
47
48// fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment.
49func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer {
50 apexFile := fmt.Sprintf("%s.apex", apex)
51 dir := "prebuilts/apex"
52 return android.GroupFixturePreparers(
53 // A preparer to add a prebuilt apex to the test fixture.
54 android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(`
55 prebuilt_apex {
56 name: "%s",
57 src: "%s",
58 exported_bootclasspath_fragments: [
59 "%s",
60 ],
61 }
62 `, apex, apexFile, fragment)),
63 android.FixtureAddFile(filepath.Join(dir, apexFile), nil),
64 )
65}
66
Paul Duffina57835e2021-04-19 13:23:06 +010067func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
68 result := android.GroupFixturePreparers(
69 prepareForSdkTestWithJava,
Paul Duffin023dba02021-04-22 01:45:29 +010070 java.PrepareForTestWithJavaDefaultModules,
Paul Duffina57835e2021-04-19 13:23:06 +010071 prepareForSdkTestWithApex,
72
73 // Some additional files needed for the art apex.
74 android.FixtureMergeMockFs(android.MockFS{
75 "com.android.art.avbpubkey": nil,
76 "com.android.art.pem": nil,
77 "system/sepolicy/apex/com.android.art-file_contexts": nil,
78 }),
Paul Duffin023dba02021-04-22 01:45:29 +010079
Paul Duffin7c475152021-06-09 16:17:58 +010080 // Add a platform_bootclasspath that depends on the fragment.
81 fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"),
Paul Duffin023dba02021-04-22 01:45:29 +010082
Paul Duffina57835e2021-04-19 13:23:06 +010083 java.FixtureConfigureBootJars("com.android.art:mybootlib"),
84 android.FixtureWithRootAndroidBp(`
85 sdk {
86 name: "mysdk",
87 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffina57835e2021-04-19 13:23:06 +010088 }
89
90 apex {
91 name: "com.android.art",
92 key: "com.android.art.key",
93 bootclasspath_fragments: [
94 "mybootclasspathfragment",
95 ],
96 updatable: false,
97 }
98
99 bootclasspath_fragment {
100 name: "mybootclasspathfragment",
101 image_name: "art",
Paul Duffinf23bc472021-04-27 12:42:20 +0100102 contents: ["mybootlib"],
Paul Duffina57835e2021-04-19 13:23:06 +0100103 apex_available: ["com.android.art"],
104 }
105
106 apex_key {
107 name: "com.android.art.key",
108 public_key: "com.android.art.avbpubkey",
109 private_key: "com.android.art.pem",
110 }
111
112 java_library {
113 name: "mybootlib",
114 srcs: ["Test.java"],
115 system_modules: "none",
116 sdk_version: "none",
117 compile_dex: true,
118 apex_available: ["com.android.art"],
119 }
120 `),
121 ).RunTest(t)
122
Paul Duffin7c475152021-06-09 16:17:58 +0100123 // A preparer to update the test fixture used when processing an unpackage snapshot.
124 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
Paul Duffin023dba02021-04-22 01:45:29 +0100125
Paul Duffina57835e2021-04-19 13:23:06 +0100126 CheckSnapshot(t, result, "mysdk", "",
127 checkUnversionedAndroidBpContents(`
128// This is auto-generated. DO NOT EDIT.
129
130prebuilt_bootclasspath_fragment {
131 name: "mybootclasspathfragment",
132 prefer: false,
133 visibility: ["//visibility:public"],
134 apex_available: ["com.android.art"],
135 image_name: "art",
Paul Duffin2dc665b2021-04-23 16:58:51 +0100136 contents: ["mybootlib"],
Paul Duffinda286f42021-06-29 11:59:23 +0100137 hidden_api: {
Paul Duffinda286f42021-06-29 11:59:23 +0100138 annotation_flags: "hiddenapi/annotation-flags.csv",
139 metadata: "hiddenapi/metadata.csv",
140 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100141 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100142 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
143 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffinda286f42021-06-29 11:59:23 +0100144 },
Paul Duffina57835e2021-04-19 13:23:06 +0100145}
146
147java_import {
148 name: "mybootlib",
149 prefer: false,
150 visibility: ["//visibility:public"],
151 apex_available: ["com.android.art"],
Paul Duffin5c211452021-07-15 12:42:44 +0100152 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffina57835e2021-04-19 13:23:06 +0100153}
154`),
155 checkVersionedAndroidBpContents(`
156// This is auto-generated. DO NOT EDIT.
157
158prebuilt_bootclasspath_fragment {
159 name: "mysdk_mybootclasspathfragment@current",
160 sdk_member_name: "mybootclasspathfragment",
161 visibility: ["//visibility:public"],
162 apex_available: ["com.android.art"],
163 image_name: "art",
Paul Duffin2dc665b2021-04-23 16:58:51 +0100164 contents: ["mysdk_mybootlib@current"],
Paul Duffinda286f42021-06-29 11:59:23 +0100165 hidden_api: {
Paul Duffinda286f42021-06-29 11:59:23 +0100166 annotation_flags: "hiddenapi/annotation-flags.csv",
167 metadata: "hiddenapi/metadata.csv",
168 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100169 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100170 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
171 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffinda286f42021-06-29 11:59:23 +0100172 },
Paul Duffina57835e2021-04-19 13:23:06 +0100173}
174
175java_import {
176 name: "mysdk_mybootlib@current",
177 sdk_member_name: "mybootlib",
178 visibility: ["//visibility:public"],
179 apex_available: ["com.android.art"],
Paul Duffin5c211452021-07-15 12:42:44 +0100180 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffina57835e2021-04-19 13:23:06 +0100181}
182
183sdk_snapshot {
184 name: "mysdk@current",
185 visibility: ["//visibility:public"],
186 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
187 java_boot_libs: ["mysdk_mybootlib@current"],
188}
189`),
190 checkAllCopyRules(`
Paul Duffinda286f42021-06-29 11:59:23 +0100191.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
192.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
193.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100194.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin280bae62021-07-20 18:03:53 +0100195.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
196.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100197.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffinda286f42021-06-29 11:59:23 +0100198 `),
Paul Duffin7c475152021-06-09 16:17:58 +0100199 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
Paul Duffinc8ead412021-06-07 19:28:15 +0100200
201 // Check the behavior of the snapshot without the source.
202 snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
203 // Make sure that the boot jars package check rule includes the dex jar retrieved from the prebuilt apex.
204 checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/mybootlib.jar")
205 }),
206
Paul Duffin7c475152021-06-09 16:17:58 +0100207 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
208 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
Paul Duffina57835e2021-04-19 13:23:06 +0100209 )
Paul Duffinc8ead412021-06-07 19:28:15 +0100210
211 // Make sure that the boot jars package check rule includes the dex jar created from the source.
212 checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/mybootlib/android_common_apex10000/aligned/mybootlib.jar")
213}
214
215// checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars
216// package check rule.
217func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModule string) {
218 platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common")
219 bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check")
220 command := bootJarsCheckRule.RuleParams.Command
221 expectedCommandArgs := " out/soong/host/linux-x86/bin/dexdump build/soong/scripts/check_boot_jars/package_allowed_list.txt " + expectedModule + " &&"
222 android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs)
Paul Duffina57835e2021-04-19 13:23:06 +0100223}
224
225func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
Paul Duffin4a1d4512021-03-18 10:12:26 +0000226 result := android.GroupFixturePreparers(
227 prepareForSdkTestWithJava,
Paul Duffin895c7142021-04-25 13:40:15 +0100228 java.PrepareForTestWithJavaDefaultModules,
229 java.PrepareForTestWithJavaSdkLibraryFiles,
Paul Duffina10bd3c2021-05-12 13:46:54 +0100230 java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"),
satayevd604b212021-07-21 14:23:52 +0100231 java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"),
Paul Duffin7c475152021-06-09 16:17:58 +0100232 prepareForSdkTestWithApex,
233
234 // Add a platform_bootclasspath that depends on the fragment.
235 fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
236
Paul Duffin4a1d4512021-03-18 10:12:26 +0000237 android.FixtureWithRootAndroidBp(`
238 sdk {
239 name: "mysdk",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100240 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100241 java_sdk_libs: [
242 // This is not strictly needed as it should be automatically added to the sdk_snapshot as
243 // a java_sdk_libs module because it is used in the mybootclasspathfragment's
244 // api.stub_libs property. However, it is specified here to ensure that duplicates are
245 // correctly deduped.
246 "mysdklibrary",
247 ],
Paul Duffin4a1d4512021-03-18 10:12:26 +0000248 }
Paul Duffinf7f65da2021-03-10 15:00:46 +0000249
Paul Duffin7c475152021-06-09 16:17:58 +0100250 apex {
251 name: "myapex",
252 key: "myapex.key",
253 min_sdk_version: "2",
254 bootclasspath_fragments: ["mybootclasspathfragment"],
255 }
256
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100257 bootclasspath_fragment {
258 name: "mybootclasspathfragment",
Paul Duffin7c475152021-06-09 16:17:58 +0100259 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100260 contents: [
261 // This should be automatically added to the sdk_snapshot as a java_boot_libs module.
262 "mybootlib",
263 // This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
264 "myothersdklibrary",
265 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100266 api: {
267 stub_libs: ["mysdklibrary"],
268 },
269 core_platform_api: {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100270 // This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
Paul Duffin895c7142021-04-25 13:40:15 +0100271 stub_libs: ["mycoreplatform"],
272 },
Paul Duffina57835e2021-04-19 13:23:06 +0100273 }
274
275 java_library {
276 name: "mybootlib",
Paul Duffin7c475152021-06-09 16:17:58 +0100277 apex_available: ["myapex"],
Paul Duffina57835e2021-04-19 13:23:06 +0100278 srcs: ["Test.java"],
279 system_modules: "none",
280 sdk_version: "none",
Paul Duffin7c475152021-06-09 16:17:58 +0100281 min_sdk_version: "2",
Paul Duffina57835e2021-04-19 13:23:06 +0100282 compile_dex: true,
Paul Duffin7c475152021-06-09 16:17:58 +0100283 permitted_packages: ["mybootlib"],
Paul Duffin4a1d4512021-03-18 10:12:26 +0000284 }
Paul Duffin895c7142021-04-25 13:40:15 +0100285
286 java_sdk_library {
287 name: "mysdklibrary",
Paul Duffin7c475152021-06-09 16:17:58 +0100288 apex_available: ["myapex"],
Paul Duffin895c7142021-04-25 13:40:15 +0100289 srcs: ["Test.java"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100290 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100291 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100292 min_sdk_version: "2",
Paul Duffin895c7142021-04-25 13:40:15 +0100293 }
294
295 java_sdk_library {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100296 name: "myothersdklibrary",
Paul Duffin7c475152021-06-09 16:17:58 +0100297 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100298 srcs: ["Test.java"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100299 compile_dex: true,
Paul Duffina10bd3c2021-05-12 13:46:54 +0100300 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100301 min_sdk_version: "2",
302 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100303 }
304
305 java_sdk_library {
Paul Duffin895c7142021-04-25 13:40:15 +0100306 name: "mycoreplatform",
Paul Duffin7c475152021-06-09 16:17:58 +0100307 apex_available: ["myapex"],
Paul Duffin895c7142021-04-25 13:40:15 +0100308 srcs: ["Test.java"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100309 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100310 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100311 min_sdk_version: "2",
Paul Duffin895c7142021-04-25 13:40:15 +0100312 }
Paul Duffin4a1d4512021-03-18 10:12:26 +0000313 `),
314 ).RunTest(t)
Paul Duffinf7f65da2021-03-10 15:00:46 +0000315
Paul Duffin7c475152021-06-09 16:17:58 +0100316 // A preparer to update the test fixture used when processing an unpackage snapshot.
317 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
318
Paul Duffin36474d32021-03-12 12:19:43 +0000319 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000320 checkUnversionedAndroidBpContents(`
321// This is auto-generated. DO NOT EDIT.
322
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100323prebuilt_bootclasspath_fragment {
324 name: "mybootclasspathfragment",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000325 prefer: false,
326 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100327 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100328 contents: [
329 "mybootlib",
330 "myothersdklibrary",
331 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100332 api: {
333 stub_libs: ["mysdklibrary"],
334 },
335 core_platform_api: {
336 stub_libs: ["mycoreplatform"],
337 },
Paul Duffin2fef1362021-04-15 13:32:00 +0100338 hidden_api: {
Paul Duffin2fef1362021-04-15 13:32:00 +0100339 annotation_flags: "hiddenapi/annotation-flags.csv",
340 metadata: "hiddenapi/metadata.csv",
341 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100342 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100343 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
344 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffin2fef1362021-04-15 13:32:00 +0100345 },
Paul Duffina57835e2021-04-19 13:23:06 +0100346}
347
348java_import {
349 name: "mybootlib",
350 prefer: false,
351 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100352 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100353 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100354 permitted_packages: ["mybootlib"],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000355}
Paul Duffin895c7142021-04-25 13:40:15 +0100356
357java_sdk_library_import {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100358 name: "myothersdklibrary",
359 prefer: false,
360 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100361 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100362 shared_library: true,
363 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100364 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100365 public: {
366 jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
367 stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
368 current_api: "sdk_library/public/myothersdklibrary.txt",
369 removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
370 sdk_version: "current",
371 },
372}
373
374java_sdk_library_import {
Paul Duffin895c7142021-04-25 13:40:15 +0100375 name: "mysdklibrary",
376 prefer: false,
377 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100378 apex_available: ["myapex"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100379 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100380 public: {
381 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
382 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
383 current_api: "sdk_library/public/mysdklibrary.txt",
384 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
385 sdk_version: "current",
386 },
387}
388
389java_sdk_library_import {
390 name: "mycoreplatform",
391 prefer: false,
392 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100393 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100394 shared_library: true,
395 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100396 public: {
397 jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
398 stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
399 current_api: "sdk_library/public/mycoreplatform.txt",
400 removed_api: "sdk_library/public/mycoreplatform-removed.txt",
401 sdk_version: "current",
402 },
403}
Paul Duffina10bd3c2021-05-12 13:46:54 +0100404 `),
Paul Duffinf7f65da2021-03-10 15:00:46 +0000405 checkVersionedAndroidBpContents(`
406// This is auto-generated. DO NOT EDIT.
407
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100408prebuilt_bootclasspath_fragment {
409 name: "mysdk_mybootclasspathfragment@current",
410 sdk_member_name: "mybootclasspathfragment",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000411 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100412 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100413 contents: [
414 "mysdk_mybootlib@current",
415 "mysdk_myothersdklibrary@current",
416 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100417 api: {
418 stub_libs: ["mysdk_mysdklibrary@current"],
419 },
420 core_platform_api: {
421 stub_libs: ["mysdk_mycoreplatform@current"],
422 },
Paul Duffin2fef1362021-04-15 13:32:00 +0100423 hidden_api: {
Paul Duffin2fef1362021-04-15 13:32:00 +0100424 annotation_flags: "hiddenapi/annotation-flags.csv",
425 metadata: "hiddenapi/metadata.csv",
426 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100427 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100428 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
429 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffin2fef1362021-04-15 13:32:00 +0100430 },
Paul Duffina57835e2021-04-19 13:23:06 +0100431}
432
433java_import {
434 name: "mysdk_mybootlib@current",
435 sdk_member_name: "mybootlib",
436 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100437 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100438 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100439 permitted_packages: ["mybootlib"],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000440}
441
Paul Duffin895c7142021-04-25 13:40:15 +0100442java_sdk_library_import {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100443 name: "mysdk_myothersdklibrary@current",
444 sdk_member_name: "myothersdklibrary",
445 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100446 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100447 shared_library: true,
448 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100449 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100450 public: {
451 jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
452 stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
453 current_api: "sdk_library/public/myothersdklibrary.txt",
454 removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
455 sdk_version: "current",
456 },
457}
458
459java_sdk_library_import {
Paul Duffin895c7142021-04-25 13:40:15 +0100460 name: "mysdk_mysdklibrary@current",
461 sdk_member_name: "mysdklibrary",
462 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100463 apex_available: ["myapex"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100464 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100465 public: {
466 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
467 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
468 current_api: "sdk_library/public/mysdklibrary.txt",
469 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
470 sdk_version: "current",
471 },
472}
473
474java_sdk_library_import {
475 name: "mysdk_mycoreplatform@current",
476 sdk_member_name: "mycoreplatform",
477 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100478 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100479 shared_library: true,
480 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100481 public: {
482 jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
483 stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
484 current_api: "sdk_library/public/mycoreplatform.txt",
485 removed_api: "sdk_library/public/mycoreplatform-removed.txt",
486 sdk_version: "current",
487 },
488}
489
Paul Duffinf7f65da2021-03-10 15:00:46 +0000490sdk_snapshot {
491 name: "mysdk@current",
492 visibility: ["//visibility:public"],
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100493 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
Paul Duffina57835e2021-04-19 13:23:06 +0100494 java_boot_libs: ["mysdk_mybootlib@current"],
Paul Duffin895c7142021-04-25 13:40:15 +0100495 java_sdk_libs: [
Paul Duffina10bd3c2021-05-12 13:46:54 +0100496 "mysdk_myothersdklibrary@current",
Paul Duffin895c7142021-04-25 13:40:15 +0100497 "mysdk_mysdklibrary@current",
498 "mysdk_mycoreplatform@current",
499 ],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000500}
Paul Duffina10bd3c2021-05-12 13:46:54 +0100501 `),
Paul Duffina57835e2021-04-19 13:23:06 +0100502 checkAllCopyRules(`
Paul Duffin2fef1362021-04-15 13:32:00 +0100503.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
504.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
505.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100506.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin280bae62021-07-20 18:03:53 +0100507.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
508.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100509.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffina10bd3c2021-05-12 13:46:54 +0100510.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
511.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
512.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
Paul Duffin895c7142021-04-25 13:40:15 +0100513.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
514.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
515.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
516.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
517.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
518.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
Paul Duffin7c475152021-06-09 16:17:58 +0100519`),
520 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
Paul Duffind061d402021-06-07 21:36:01 +0100521 snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
522 module := result.ModuleForTests("platform-bootclasspath", "android_common")
523 var rule android.TestingBuildParams
524 rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv")
525 java.CheckHiddenAPIRuleInputs(t, "monolithic flags", `
526 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv
527 out/soong/hiddenapi/hiddenapi-stub-flags.txt
528 snapshot/hiddenapi/annotation-flags.csv
529 `, rule)
530
531 rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv")
532 java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", `
533 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv
534 snapshot/hiddenapi/metadata.csv
535 `, rule)
536
537 rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv")
538 java.CheckHiddenAPIRuleInputs(t, "monolithic index", `
539 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
540 snapshot/hiddenapi/index.csv
541 `, rule)
Paul Duffin630b11e2021-07-15 13:35:26 +0100542
Paul Duffin8d007e92021-07-22 12:00:49 +0100543 rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
Paul Duffin280bae62021-07-20 18:03:53 +0100544 android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/filtered-flags.csv:snapshot/hiddenapi/signature-patterns.csv ")
Paul Duffind061d402021-06-07 21:36:01 +0100545 }),
Paul Duffin7c475152021-06-09 16:17:58 +0100546 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
Paul Duffin8d007e92021-07-22 12:00:49 +0100547 snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
548 module := result.ModuleForTests("platform-bootclasspath", "android_common")
549 rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
Paul Duffin280bae62021-07-20 18:03:53 +0100550 android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv ")
Paul Duffin8d007e92021-07-22 12:00:49 +0100551 }),
Paul Duffin7c475152021-06-09 16:17:58 +0100552 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
553 )
Paul Duffinf7f65da2021-03-10 15:00:46 +0000554}
Paul Duffin04b4a192021-03-18 11:05:31 +0000555
Paul Duffin51227d82021-05-18 12:54:27 +0100556// TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a
557// bootclasspath_fragment is correctly output to the sdk snapshot.
558func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
559 result := android.GroupFixturePreparers(
560 prepareForSdkTestWithJava,
561 java.PrepareForTestWithJavaDefaultModules,
562 java.PrepareForTestWithJavaSdkLibraryFiles,
563 java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"),
satayevabcd5972021-08-06 17:49:46 +0100564 java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"),
Paul Duffin51227d82021-05-18 12:54:27 +0100565 prepareForSdkTestWithApex,
566
567 // Some additional files needed for the myotherapex.
568 android.FixtureMergeMockFs(android.MockFS{
569 "system/sepolicy/apex/myotherapex-file_contexts": nil,
570 "myotherapex/apex_manifest.json": nil,
571 "myotherapex/Test.java": nil,
572 }),
573
574 android.FixtureAddTextFile("myotherapex/Android.bp", `
575 apex {
576 name: "myotherapex",
577 key: "myapex.key",
578 min_sdk_version: "2",
579 bootclasspath_fragments: ["myotherbootclasspathfragment"],
580 }
581
582 bootclasspath_fragment {
583 name: "myotherbootclasspathfragment",
584 apex_available: ["myotherapex"],
585 contents: [
586 "myotherlib",
587 ],
588 }
589
590 java_library {
591 name: "myotherlib",
592 apex_available: ["myotherapex"],
593 srcs: ["Test.java"],
594 min_sdk_version: "2",
595 permitted_packages: ["myothersdklibrary"],
596 compile_dex: true,
597 }
598 `),
599
600 android.FixtureWithRootAndroidBp(`
601 sdk {
602 name: "mysdk",
603 bootclasspath_fragments: ["mybootclasspathfragment"],
604 }
605
606 bootclasspath_fragment {
607 name: "mybootclasspathfragment",
608 contents: [
609 "mysdklibrary",
610 ],
611 fragments: [
612 {
613 apex: "myotherapex",
614 module: "myotherbootclasspathfragment"
615 },
616 ],
617 }
618
619 java_sdk_library {
620 name: "mysdklibrary",
621 srcs: ["Test.java"],
622 shared_library: false,
623 public: {enabled: true},
624 min_sdk_version: "2",
625 }
626 `),
627 ).RunTest(t)
628
629 // A preparer to update the test fixture used when processing an unpackage snapshot.
630 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
631
632 CheckSnapshot(t, result, "mysdk", "",
633 checkUnversionedAndroidBpContents(`
634// This is auto-generated. DO NOT EDIT.
635
636prebuilt_bootclasspath_fragment {
637 name: "mybootclasspathfragment",
638 prefer: false,
639 visibility: ["//visibility:public"],
640 apex_available: ["//apex_available:platform"],
641 contents: ["mysdklibrary"],
642 fragments: [
643 {
644 apex: "myotherapex",
645 module: "myotherbootclasspathfragment",
646 },
647 ],
648 hidden_api: {
Paul Duffin51227d82021-05-18 12:54:27 +0100649 annotation_flags: "hiddenapi/annotation-flags.csv",
650 metadata: "hiddenapi/metadata.csv",
651 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100652 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100653 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
654 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffin51227d82021-05-18 12:54:27 +0100655 },
656}
657
658java_sdk_library_import {
659 name: "mysdklibrary",
660 prefer: false,
661 visibility: ["//visibility:public"],
662 apex_available: ["//apex_available:platform"],
663 shared_library: false,
664 public: {
665 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
666 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
667 current_api: "sdk_library/public/mysdklibrary.txt",
668 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
669 sdk_version: "current",
670 },
671}
672 `),
673 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
674 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
675 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
676 )
677}
678
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100679// Test that bootclasspath_fragment works with sdk.
680func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
Paul Duffin04b4a192021-03-18 11:05:31 +0000681 android.GroupFixturePreparers(
682 prepareForSdkTestWithApex,
683 prepareForSdkTestWithJava,
Paul Duffin8018e502021-05-21 19:28:09 +0100684 android.FixtureAddFile("java/mybootlib.jar", nil),
Paul Duffin04b4a192021-03-18 11:05:31 +0000685 android.FixtureWithRootAndroidBp(`
686 sdk {
687 name: "mysdk",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100688 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000689 }
690
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100691 bootclasspath_fragment {
692 name: "mybootclasspathfragment",
Paul Duffin04b4a192021-03-18 11:05:31 +0000693 image_name: "art",
Paul Duffin8018e502021-05-21 19:28:09 +0100694 contents: ["mybootlib"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000695 apex_available: ["myapex"],
696 }
697
Paul Duffin8018e502021-05-21 19:28:09 +0100698 java_library {
699 name: "mybootlib",
700 apex_available: ["myapex"],
701 srcs: ["Test.java"],
702 system_modules: "none",
703 sdk_version: "none",
704 min_sdk_version: "1",
705 compile_dex: true,
706 }
707
Paul Duffin04b4a192021-03-18 11:05:31 +0000708 sdk_snapshot {
709 name: "mysdk@1",
Paul Duffin8018e502021-05-21 19:28:09 +0100710 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000711 }
712
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100713 prebuilt_bootclasspath_fragment {
Paul Duffin8018e502021-05-21 19:28:09 +0100714 name: "mysdk_mybootclasspathfragment@1",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100715 sdk_member_name: "mybootclasspathfragment",
Paul Duffin04b4a192021-03-18 11:05:31 +0000716 prefer: false,
717 visibility: ["//visibility:public"],
718 apex_available: [
719 "myapex",
720 ],
721 image_name: "art",
Paul Duffin8018e502021-05-21 19:28:09 +0100722 contents: ["mysdk_mybootlib@1"],
723 }
724
725 java_import {
726 name: "mysdk_mybootlib@1",
727 sdk_member_name: "mybootlib",
728 visibility: ["//visibility:public"],
729 apex_available: ["com.android.art"],
730 jars: ["java/mybootlib.jar"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000731 }
732 `),
733 ).RunTest(t)
734}
Paul Duffin7c955552021-04-19 13:23:53 +0100735
736func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
737 result := android.GroupFixturePreparers(
738 prepareForSdkTestWithJava,
Paul Duffin475daaf2021-05-13 00:57:55 +0100739 java.PrepareForTestWithJavaDefaultModules,
740 java.PrepareForTestWithJavaSdkLibraryFiles,
741 java.FixtureWithLastReleaseApis("mysdklibrary"),
satayevd604b212021-07-21 14:23:52 +0100742 java.FixtureConfigureApexBootJars("myapex:mybootlib"),
Paul Duffin475daaf2021-05-13 00:57:55 +0100743 prepareForSdkTestWithApex,
Paul Duffin7c475152021-06-09 16:17:58 +0100744
745 // Add a platform_bootclasspath that depends on the fragment.
746 fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
747
Paul Duffin7c955552021-04-19 13:23:53 +0100748 android.MockFS{
749 "my-blocked.txt": nil,
750 "my-max-target-o-low-priority.txt": nil,
751 "my-max-target-p.txt": nil,
752 "my-max-target-q.txt": nil,
753 "my-max-target-r-low-priority.txt": nil,
754 "my-removed.txt": nil,
755 "my-unsupported-packages.txt": nil,
756 "my-unsupported.txt": nil,
757 }.AddToFixture(),
758 android.FixtureWithRootAndroidBp(`
759 sdk {
760 name: "mysdk",
761 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffin7c955552021-04-19 13:23:53 +0100762 }
763
Paul Duffin475daaf2021-05-13 00:57:55 +0100764 apex {
765 name: "myapex",
766 key: "myapex.key",
767 min_sdk_version: "1",
768 bootclasspath_fragments: ["mybootclasspathfragment"],
769 }
770
Paul Duffin7c955552021-04-19 13:23:53 +0100771 bootclasspath_fragment {
772 name: "mybootclasspathfragment",
Paul Duffin475daaf2021-05-13 00:57:55 +0100773 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100774 contents: ["mybootlib"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100775 api: {
776 stub_libs: ["mysdklibrary"],
777 },
Paul Duffin7c955552021-04-19 13:23:53 +0100778 hidden_api: {
779 unsupported: [
780 "my-unsupported.txt",
781 ],
782 removed: [
783 "my-removed.txt",
784 ],
785 max_target_r_low_priority: [
786 "my-max-target-r-low-priority.txt",
787 ],
788 max_target_q: [
789 "my-max-target-q.txt",
790 ],
791 max_target_p: [
792 "my-max-target-p.txt",
793 ],
794 max_target_o_low_priority: [
795 "my-max-target-o-low-priority.txt",
796 ],
797 blocked: [
798 "my-blocked.txt",
799 ],
800 unsupported_packages: [
801 "my-unsupported-packages.txt",
802 ],
803 },
804 }
805
806 java_library {
807 name: "mybootlib",
Paul Duffin475daaf2021-05-13 00:57:55 +0100808 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100809 srcs: ["Test.java"],
810 system_modules: "none",
811 sdk_version: "none",
Paul Duffin475daaf2021-05-13 00:57:55 +0100812 min_sdk_version: "1",
Paul Duffin7c955552021-04-19 13:23:53 +0100813 compile_dex: true,
Paul Duffin7c475152021-06-09 16:17:58 +0100814 permitted_packages: ["mybootlib"],
Paul Duffin7c955552021-04-19 13:23:53 +0100815 }
Paul Duffin475daaf2021-05-13 00:57:55 +0100816
817 java_sdk_library {
818 name: "mysdklibrary",
819 srcs: ["Test.java"],
820 compile_dex: true,
821 public: {enabled: true},
Paul Duffin869de142021-07-15 14:14:41 +0100822 permitted_packages: ["mysdklibrary"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100823 }
Paul Duffin7c955552021-04-19 13:23:53 +0100824 `),
825 ).RunTest(t)
826
Paul Duffin7c475152021-06-09 16:17:58 +0100827 // A preparer to update the test fixture used when processing an unpackage snapshot.
828 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
829
Paul Duffin7c955552021-04-19 13:23:53 +0100830 CheckSnapshot(t, result, "mysdk", "",
831 checkUnversionedAndroidBpContents(`
832// This is auto-generated. DO NOT EDIT.
833
834prebuilt_bootclasspath_fragment {
835 name: "mybootclasspathfragment",
836 prefer: false,
837 visibility: ["//visibility:public"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100838 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100839 contents: ["mybootlib"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100840 api: {
841 stub_libs: ["mysdklibrary"],
842 },
Paul Duffin7c955552021-04-19 13:23:53 +0100843 hidden_api: {
844 unsupported: ["hiddenapi/my-unsupported.txt"],
845 removed: ["hiddenapi/my-removed.txt"],
846 max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"],
847 max_target_q: ["hiddenapi/my-max-target-q.txt"],
848 max_target_p: ["hiddenapi/my-max-target-p.txt"],
849 max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"],
850 blocked: ["hiddenapi/my-blocked.txt"],
851 unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"],
Paul Duffin2fef1362021-04-15 13:32:00 +0100852 annotation_flags: "hiddenapi/annotation-flags.csv",
853 metadata: "hiddenapi/metadata.csv",
854 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100855 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin191be3a2021-08-10 16:14:16 +0100856 filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
857 filtered_flags: "hiddenapi/filtered-flags.csv",
Paul Duffin7c955552021-04-19 13:23:53 +0100858 },
859}
860
861java_import {
862 name: "mybootlib",
863 prefer: false,
864 visibility: ["//visibility:public"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100865 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100866 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100867 permitted_packages: ["mybootlib"],
Paul Duffin7c955552021-04-19 13:23:53 +0100868}
Paul Duffin475daaf2021-05-13 00:57:55 +0100869
870java_sdk_library_import {
871 name: "mysdklibrary",
872 prefer: false,
873 visibility: ["//visibility:public"],
874 apex_available: ["//apex_available:platform"],
875 shared_library: true,
876 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100877 permitted_packages: ["mysdklibrary"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100878 public: {
879 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
880 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
881 current_api: "sdk_library/public/mysdklibrary.txt",
882 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
883 sdk_version: "current",
884 },
885}
Paul Duffin7c955552021-04-19 13:23:53 +0100886`),
887 checkAllCopyRules(`
888my-unsupported.txt -> hiddenapi/my-unsupported.txt
889my-removed.txt -> hiddenapi/my-removed.txt
890my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt
891my-max-target-q.txt -> hiddenapi/my-max-target-q.txt
892my-max-target-p.txt -> hiddenapi/my-max-target-p.txt
893my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt
894my-blocked.txt -> hiddenapi/my-blocked.txt
895my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
Paul Duffin2fef1362021-04-15 13:32:00 +0100896.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
897.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
898.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100899.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin280bae62021-07-20 18:03:53 +0100900.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
901.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100902.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffin475daaf2021-05-13 00:57:55 +0100903.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
904.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
905.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
Paul Duffin7c955552021-04-19 13:23:53 +0100906`),
Paul Duffin7c475152021-06-09 16:17:58 +0100907 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
908 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
909 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
Paul Duffin7c955552021-04-19 13:23:53 +0100910 )
911}