blob: 916610957180b5140e3ef149997f486c32cccaef [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),
Paul Duffinc8ead412021-06-07 19:28:15 +010043 android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil),
Paul Duffin7c475152021-06-09 16:17:58 +010044 )
45}
46
47// fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment.
48func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer {
49 apexFile := fmt.Sprintf("%s.apex", apex)
50 dir := "prebuilts/apex"
51 return android.GroupFixturePreparers(
52 // A preparer to add a prebuilt apex to the test fixture.
53 android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(`
54 prebuilt_apex {
55 name: "%s",
56 src: "%s",
57 exported_bootclasspath_fragments: [
58 "%s",
59 ],
60 }
61 `, apex, apexFile, fragment)),
62 android.FixtureAddFile(filepath.Join(dir, apexFile), nil),
63 )
64}
65
Paul Duffina57835e2021-04-19 13:23:06 +010066func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
67 result := android.GroupFixturePreparers(
68 prepareForSdkTestWithJava,
Paul Duffin023dba02021-04-22 01:45:29 +010069 java.PrepareForTestWithJavaDefaultModules,
Paul Duffina57835e2021-04-19 13:23:06 +010070 prepareForSdkTestWithApex,
71
72 // Some additional files needed for the art apex.
73 android.FixtureMergeMockFs(android.MockFS{
74 "com.android.art.avbpubkey": nil,
75 "com.android.art.pem": nil,
76 "system/sepolicy/apex/com.android.art-file_contexts": nil,
77 }),
Paul Duffin023dba02021-04-22 01:45:29 +010078
Paul Duffin7c475152021-06-09 16:17:58 +010079 // Add a platform_bootclasspath that depends on the fragment.
80 fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"),
Paul Duffin023dba02021-04-22 01:45:29 +010081
Paul Duffina57835e2021-04-19 13:23:06 +010082 java.FixtureConfigureBootJars("com.android.art:mybootlib"),
83 android.FixtureWithRootAndroidBp(`
84 sdk {
85 name: "mysdk",
86 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffina57835e2021-04-19 13:23:06 +010087 }
88
89 apex {
90 name: "com.android.art",
91 key: "com.android.art.key",
92 bootclasspath_fragments: [
93 "mybootclasspathfragment",
94 ],
95 updatable: false,
96 }
97
98 bootclasspath_fragment {
99 name: "mybootclasspathfragment",
100 image_name: "art",
Paul Duffinf23bc472021-04-27 12:42:20 +0100101 contents: ["mybootlib"],
Paul Duffina57835e2021-04-19 13:23:06 +0100102 apex_available: ["com.android.art"],
103 }
104
105 apex_key {
106 name: "com.android.art.key",
107 public_key: "com.android.art.avbpubkey",
108 private_key: "com.android.art.pem",
109 }
110
111 java_library {
112 name: "mybootlib",
113 srcs: ["Test.java"],
114 system_modules: "none",
115 sdk_version: "none",
116 compile_dex: true,
117 apex_available: ["com.android.art"],
118 }
119 `),
120 ).RunTest(t)
121
Paul Duffin7c475152021-06-09 16:17:58 +0100122 // A preparer to update the test fixture used when processing an unpackage snapshot.
123 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
Paul Duffin023dba02021-04-22 01:45:29 +0100124
Paul Duffina57835e2021-04-19 13:23:06 +0100125 CheckSnapshot(t, result, "mysdk", "",
126 checkUnversionedAndroidBpContents(`
127// This is auto-generated. DO NOT EDIT.
128
129prebuilt_bootclasspath_fragment {
130 name: "mybootclasspathfragment",
131 prefer: false,
132 visibility: ["//visibility:public"],
133 apex_available: ["com.android.art"],
134 image_name: "art",
Paul Duffin2dc665b2021-04-23 16:58:51 +0100135 contents: ["mybootlib"],
Paul Duffinda286f42021-06-29 11:59:23 +0100136 hidden_api: {
Paul Duffinda286f42021-06-29 11:59:23 +0100137 annotation_flags: "hiddenapi/annotation-flags.csv",
138 metadata: "hiddenapi/metadata.csv",
139 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100140 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100141 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffinda286f42021-06-29 11:59:23 +0100142 all_flags: "hiddenapi/all-flags.csv",
143 },
Paul Duffina57835e2021-04-19 13:23:06 +0100144}
145
146java_import {
147 name: "mybootlib",
148 prefer: false,
149 visibility: ["//visibility:public"],
150 apex_available: ["com.android.art"],
Paul Duffin5c211452021-07-15 12:42:44 +0100151 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffina57835e2021-04-19 13:23:06 +0100152}
153`),
154 checkVersionedAndroidBpContents(`
155// This is auto-generated. DO NOT EDIT.
156
157prebuilt_bootclasspath_fragment {
158 name: "mysdk_mybootclasspathfragment@current",
159 sdk_member_name: "mybootclasspathfragment",
160 visibility: ["//visibility:public"],
161 apex_available: ["com.android.art"],
162 image_name: "art",
Paul Duffin2dc665b2021-04-23 16:58:51 +0100163 contents: ["mysdk_mybootlib@current"],
Paul Duffinda286f42021-06-29 11:59:23 +0100164 hidden_api: {
Paul Duffinda286f42021-06-29 11:59:23 +0100165 annotation_flags: "hiddenapi/annotation-flags.csv",
166 metadata: "hiddenapi/metadata.csv",
167 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100168 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100169 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffinda286f42021-06-29 11:59:23 +0100170 all_flags: "hiddenapi/all-flags.csv",
171 },
Paul Duffina57835e2021-04-19 13:23:06 +0100172}
173
174java_import {
175 name: "mysdk_mybootlib@current",
176 sdk_member_name: "mybootlib",
177 visibility: ["//visibility:public"],
178 apex_available: ["com.android.art"],
Paul Duffin5c211452021-07-15 12:42:44 +0100179 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffina57835e2021-04-19 13:23:06 +0100180}
181
182sdk_snapshot {
183 name: "mysdk@current",
184 visibility: ["//visibility:public"],
185 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
186 java_boot_libs: ["mysdk_mybootlib@current"],
187}
188`),
189 checkAllCopyRules(`
Paul Duffinda286f42021-06-29 11:59:23 +0100190.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
191.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
192.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100193.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin67b9d612021-07-21 17:38:47 +0100194.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
Paul Duffinda286f42021-06-29 11:59:23 +0100195.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100196.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffinda286f42021-06-29 11:59:23 +0100197 `),
Paul Duffin7c475152021-06-09 16:17:58 +0100198 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
Paul Duffinc8ead412021-06-07 19:28:15 +0100199
200 // Check the behavior of the snapshot without the source.
201 snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
202 // Make sure that the boot jars package check rule includes the dex jar retrieved from the prebuilt apex.
203 checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/mybootlib.jar")
204 }),
205
Paul Duffin7c475152021-06-09 16:17:58 +0100206 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
207 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
Paul Duffina57835e2021-04-19 13:23:06 +0100208 )
Paul Duffinc8ead412021-06-07 19:28:15 +0100209
210 // Make sure that the boot jars package check rule includes the dex jar created from the source.
211 checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/mybootlib/android_common_apex10000/aligned/mybootlib.jar")
212}
213
214// checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars
215// package check rule.
216func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModule string) {
217 platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common")
218 bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check")
219 command := bootJarsCheckRule.RuleParams.Command
220 expectedCommandArgs := " out/soong/host/linux-x86/bin/dexdump build/soong/scripts/check_boot_jars/package_allowed_list.txt " + expectedModule + " &&"
221 android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs)
Paul Duffina57835e2021-04-19 13:23:06 +0100222}
223
224func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
Paul Duffin4a1d4512021-03-18 10:12:26 +0000225 result := android.GroupFixturePreparers(
226 prepareForSdkTestWithJava,
Paul Duffin895c7142021-04-25 13:40:15 +0100227 java.PrepareForTestWithJavaDefaultModules,
228 java.PrepareForTestWithJavaSdkLibraryFiles,
Paul Duffina10bd3c2021-05-12 13:46:54 +0100229 java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"),
satayevd604b212021-07-21 14:23:52 +0100230 java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"),
Paul Duffin7c475152021-06-09 16:17:58 +0100231 prepareForSdkTestWithApex,
232
233 // Add a platform_bootclasspath that depends on the fragment.
234 fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
235
Paul Duffin4a1d4512021-03-18 10:12:26 +0000236 android.FixtureWithRootAndroidBp(`
237 sdk {
238 name: "mysdk",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100239 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100240 java_sdk_libs: [
241 // This is not strictly needed as it should be automatically added to the sdk_snapshot as
242 // a java_sdk_libs module because it is used in the mybootclasspathfragment's
243 // api.stub_libs property. However, it is specified here to ensure that duplicates are
244 // correctly deduped.
245 "mysdklibrary",
246 ],
Paul Duffin4a1d4512021-03-18 10:12:26 +0000247 }
Paul Duffinf7f65da2021-03-10 15:00:46 +0000248
Paul Duffin7c475152021-06-09 16:17:58 +0100249 apex {
250 name: "myapex",
251 key: "myapex.key",
252 min_sdk_version: "2",
253 bootclasspath_fragments: ["mybootclasspathfragment"],
254 }
255
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100256 bootclasspath_fragment {
257 name: "mybootclasspathfragment",
Paul Duffin7c475152021-06-09 16:17:58 +0100258 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100259 contents: [
260 // This should be automatically added to the sdk_snapshot as a java_boot_libs module.
261 "mybootlib",
262 // This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
263 "myothersdklibrary",
264 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100265 api: {
266 stub_libs: ["mysdklibrary"],
267 },
268 core_platform_api: {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100269 // This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
Paul Duffin895c7142021-04-25 13:40:15 +0100270 stub_libs: ["mycoreplatform"],
271 },
Paul Duffina57835e2021-04-19 13:23:06 +0100272 }
273
274 java_library {
275 name: "mybootlib",
Paul Duffin7c475152021-06-09 16:17:58 +0100276 apex_available: ["myapex"],
Paul Duffina57835e2021-04-19 13:23:06 +0100277 srcs: ["Test.java"],
278 system_modules: "none",
279 sdk_version: "none",
Paul Duffin7c475152021-06-09 16:17:58 +0100280 min_sdk_version: "2",
Paul Duffina57835e2021-04-19 13:23:06 +0100281 compile_dex: true,
Paul Duffin7c475152021-06-09 16:17:58 +0100282 permitted_packages: ["mybootlib"],
Paul Duffin4a1d4512021-03-18 10:12:26 +0000283 }
Paul Duffin895c7142021-04-25 13:40:15 +0100284
285 java_sdk_library {
286 name: "mysdklibrary",
Paul Duffin7c475152021-06-09 16:17:58 +0100287 apex_available: ["myapex"],
Paul Duffin895c7142021-04-25 13:40:15 +0100288 srcs: ["Test.java"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100289 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100290 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100291 min_sdk_version: "2",
Paul Duffin895c7142021-04-25 13:40:15 +0100292 }
293
294 java_sdk_library {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100295 name: "myothersdklibrary",
Paul Duffin7c475152021-06-09 16:17:58 +0100296 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100297 srcs: ["Test.java"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100298 compile_dex: true,
Paul Duffina10bd3c2021-05-12 13:46:54 +0100299 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100300 min_sdk_version: "2",
301 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100302 }
303
304 java_sdk_library {
Paul Duffin895c7142021-04-25 13:40:15 +0100305 name: "mycoreplatform",
Paul Duffin7c475152021-06-09 16:17:58 +0100306 apex_available: ["myapex"],
Paul Duffin895c7142021-04-25 13:40:15 +0100307 srcs: ["Test.java"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100308 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100309 public: {enabled: true},
Paul Duffin7c475152021-06-09 16:17:58 +0100310 min_sdk_version: "2",
Paul Duffin895c7142021-04-25 13:40:15 +0100311 }
Paul Duffin4a1d4512021-03-18 10:12:26 +0000312 `),
313 ).RunTest(t)
Paul Duffinf7f65da2021-03-10 15:00:46 +0000314
Paul Duffin7c475152021-06-09 16:17:58 +0100315 // A preparer to update the test fixture used when processing an unpackage snapshot.
316 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
317
Paul Duffin36474d32021-03-12 12:19:43 +0000318 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000319 checkUnversionedAndroidBpContents(`
320// This is auto-generated. DO NOT EDIT.
321
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100322prebuilt_bootclasspath_fragment {
323 name: "mybootclasspathfragment",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000324 prefer: false,
325 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100326 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100327 contents: [
328 "mybootlib",
329 "myothersdklibrary",
330 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100331 api: {
332 stub_libs: ["mysdklibrary"],
333 },
334 core_platform_api: {
335 stub_libs: ["mycoreplatform"],
336 },
Paul Duffin2fef1362021-04-15 13:32:00 +0100337 hidden_api: {
Paul Duffin2fef1362021-04-15 13:32:00 +0100338 annotation_flags: "hiddenapi/annotation-flags.csv",
339 metadata: "hiddenapi/metadata.csv",
340 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100341 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100342 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffin2fef1362021-04-15 13:32:00 +0100343 all_flags: "hiddenapi/all-flags.csv",
344 },
Paul Duffina57835e2021-04-19 13:23:06 +0100345}
346
347java_import {
348 name: "mybootlib",
349 prefer: false,
350 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100351 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100352 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100353 permitted_packages: ["mybootlib"],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000354}
Paul Duffin895c7142021-04-25 13:40:15 +0100355
356java_sdk_library_import {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100357 name: "myothersdklibrary",
358 prefer: false,
359 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100360 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100361 shared_library: true,
362 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100363 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100364 public: {
365 jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
366 stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
367 current_api: "sdk_library/public/myothersdklibrary.txt",
368 removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
369 sdk_version: "current",
370 },
371}
372
373java_sdk_library_import {
Paul Duffin895c7142021-04-25 13:40:15 +0100374 name: "mysdklibrary",
375 prefer: false,
376 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100377 apex_available: ["myapex"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100378 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100379 public: {
380 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
381 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
382 current_api: "sdk_library/public/mysdklibrary.txt",
383 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
384 sdk_version: "current",
385 },
386}
387
388java_sdk_library_import {
389 name: "mycoreplatform",
390 prefer: false,
391 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100392 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100393 shared_library: true,
394 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100395 public: {
396 jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
397 stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
398 current_api: "sdk_library/public/mycoreplatform.txt",
399 removed_api: "sdk_library/public/mycoreplatform-removed.txt",
400 sdk_version: "current",
401 },
402}
Paul Duffina10bd3c2021-05-12 13:46:54 +0100403 `),
Paul Duffinf7f65da2021-03-10 15:00:46 +0000404 checkVersionedAndroidBpContents(`
405// This is auto-generated. DO NOT EDIT.
406
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100407prebuilt_bootclasspath_fragment {
408 name: "mysdk_mybootclasspathfragment@current",
409 sdk_member_name: "mybootclasspathfragment",
Paul Duffinf7f65da2021-03-10 15:00:46 +0000410 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100411 apex_available: ["myapex"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100412 contents: [
413 "mysdk_mybootlib@current",
414 "mysdk_myothersdklibrary@current",
415 ],
Paul Duffin895c7142021-04-25 13:40:15 +0100416 api: {
417 stub_libs: ["mysdk_mysdklibrary@current"],
418 },
419 core_platform_api: {
420 stub_libs: ["mysdk_mycoreplatform@current"],
421 },
Paul Duffin2fef1362021-04-15 13:32:00 +0100422 hidden_api: {
Paul Duffin2fef1362021-04-15 13:32:00 +0100423 annotation_flags: "hiddenapi/annotation-flags.csv",
424 metadata: "hiddenapi/metadata.csv",
425 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100426 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100427 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffin2fef1362021-04-15 13:32:00 +0100428 all_flags: "hiddenapi/all-flags.csv",
429 },
Paul Duffina57835e2021-04-19 13:23:06 +0100430}
431
432java_import {
433 name: "mysdk_mybootlib@current",
434 sdk_member_name: "mybootlib",
435 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100436 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100437 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100438 permitted_packages: ["mybootlib"],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000439}
440
Paul Duffin895c7142021-04-25 13:40:15 +0100441java_sdk_library_import {
Paul Duffina10bd3c2021-05-12 13:46:54 +0100442 name: "mysdk_myothersdklibrary@current",
443 sdk_member_name: "myothersdklibrary",
444 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100445 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100446 shared_library: true,
447 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100448 permitted_packages: ["myothersdklibrary"],
Paul Duffina10bd3c2021-05-12 13:46:54 +0100449 public: {
450 jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
451 stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
452 current_api: "sdk_library/public/myothersdklibrary.txt",
453 removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
454 sdk_version: "current",
455 },
456}
457
458java_sdk_library_import {
Paul Duffin895c7142021-04-25 13:40:15 +0100459 name: "mysdk_mysdklibrary@current",
460 sdk_member_name: "mysdklibrary",
461 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100462 apex_available: ["myapex"],
Paul Duffinf4600f62021-05-13 22:34:45 +0100463 shared_library: false,
Paul Duffin895c7142021-04-25 13:40:15 +0100464 public: {
465 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
466 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
467 current_api: "sdk_library/public/mysdklibrary.txt",
468 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
469 sdk_version: "current",
470 },
471}
472
473java_sdk_library_import {
474 name: "mysdk_mycoreplatform@current",
475 sdk_member_name: "mycoreplatform",
476 visibility: ["//visibility:public"],
Paul Duffin7c475152021-06-09 16:17:58 +0100477 apex_available: ["myapex"],
Paul Duffinea8f8082021-06-24 13:25:57 +0100478 shared_library: true,
479 compile_dex: true,
Paul Duffin895c7142021-04-25 13:40:15 +0100480 public: {
481 jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
482 stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
483 current_api: "sdk_library/public/mycoreplatform.txt",
484 removed_api: "sdk_library/public/mycoreplatform-removed.txt",
485 sdk_version: "current",
486 },
487}
488
Paul Duffinf7f65da2021-03-10 15:00:46 +0000489sdk_snapshot {
490 name: "mysdk@current",
491 visibility: ["//visibility:public"],
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100492 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
Paul Duffina57835e2021-04-19 13:23:06 +0100493 java_boot_libs: ["mysdk_mybootlib@current"],
Paul Duffin895c7142021-04-25 13:40:15 +0100494 java_sdk_libs: [
Paul Duffina10bd3c2021-05-12 13:46:54 +0100495 "mysdk_myothersdklibrary@current",
Paul Duffin895c7142021-04-25 13:40:15 +0100496 "mysdk_mysdklibrary@current",
497 "mysdk_mycoreplatform@current",
498 ],
Paul Duffinf7f65da2021-03-10 15:00:46 +0000499}
Paul Duffina10bd3c2021-05-12 13:46:54 +0100500 `),
Paul Duffina57835e2021-04-19 13:23:06 +0100501 checkAllCopyRules(`
Paul Duffin2fef1362021-04-15 13:32:00 +0100502.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
503.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
504.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100505.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin67b9d612021-07-21 17:38:47 +0100506.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
Paul Duffin2fef1362021-04-15 13:32:00 +0100507.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100508.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffina10bd3c2021-05-12 13:46:54 +0100509.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
510.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
511.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 +0100512.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
513.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
514.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
515.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
516.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
517.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 +0100518`),
519 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
Paul Duffind061d402021-06-07 21:36:01 +0100520 snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
521 module := result.ModuleForTests("platform-bootclasspath", "android_common")
522 var rule android.TestingBuildParams
523 rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv")
524 java.CheckHiddenAPIRuleInputs(t, "monolithic flags", `
525 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv
526 out/soong/hiddenapi/hiddenapi-stub-flags.txt
527 snapshot/hiddenapi/annotation-flags.csv
528 `, rule)
529
530 rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv")
531 java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", `
532 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv
533 snapshot/hiddenapi/metadata.csv
534 `, rule)
535
536 rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv")
537 java.CheckHiddenAPIRuleInputs(t, "monolithic index", `
538 out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
539 snapshot/hiddenapi/index.csv
540 `, rule)
Paul Duffin630b11e2021-07-15 13:35:26 +0100541
542 // Make sure that the permitted packages from the prebuilts end up in the
543 // updatable-bcp-packages.txt file.
544 rule = module.Output("updatable-bcp-packages.txt")
545 expectedContents := `'mybootlib\nmyothersdklibrary\n'`
546 android.AssertStringEquals(t, "updatable-bcp-packages.txt", expectedContents, rule.Args["content"])
Paul Duffin8d007e92021-07-22 12:00:49 +0100547
548 rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
549 android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/all-flags.csv:snapshot/hiddenapi/signature-patterns.csv ")
Paul Duffind061d402021-06-07 21:36:01 +0100550 }),
Paul Duffin7c475152021-06-09 16:17:58 +0100551 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
Paul Duffin8d007e92021-07-22 12:00:49 +0100552 snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
553 module := result.ModuleForTests("platform-bootclasspath", "android_common")
554 rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
555 android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/all-flags.csv:out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv ")
556 }),
Paul Duffin7c475152021-06-09 16:17:58 +0100557 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
558 )
Paul Duffinf7f65da2021-03-10 15:00:46 +0000559}
Paul Duffin04b4a192021-03-18 11:05:31 +0000560
Paul Duffin51227d82021-05-18 12:54:27 +0100561// TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a
562// bootclasspath_fragment is correctly output to the sdk snapshot.
563func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
564 result := android.GroupFixturePreparers(
565 prepareForSdkTestWithJava,
566 java.PrepareForTestWithJavaDefaultModules,
567 java.PrepareForTestWithJavaSdkLibraryFiles,
568 java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"),
569 prepareForSdkTestWithApex,
570
571 // Some additional files needed for the myotherapex.
572 android.FixtureMergeMockFs(android.MockFS{
573 "system/sepolicy/apex/myotherapex-file_contexts": nil,
574 "myotherapex/apex_manifest.json": nil,
575 "myotherapex/Test.java": nil,
576 }),
577
578 android.FixtureAddTextFile("myotherapex/Android.bp", `
579 apex {
580 name: "myotherapex",
581 key: "myapex.key",
582 min_sdk_version: "2",
583 bootclasspath_fragments: ["myotherbootclasspathfragment"],
584 }
585
586 bootclasspath_fragment {
587 name: "myotherbootclasspathfragment",
588 apex_available: ["myotherapex"],
589 contents: [
590 "myotherlib",
591 ],
592 }
593
594 java_library {
595 name: "myotherlib",
596 apex_available: ["myotherapex"],
597 srcs: ["Test.java"],
598 min_sdk_version: "2",
599 permitted_packages: ["myothersdklibrary"],
600 compile_dex: true,
601 }
602 `),
603
604 android.FixtureWithRootAndroidBp(`
605 sdk {
606 name: "mysdk",
607 bootclasspath_fragments: ["mybootclasspathfragment"],
608 }
609
610 bootclasspath_fragment {
611 name: "mybootclasspathfragment",
612 contents: [
613 "mysdklibrary",
614 ],
615 fragments: [
616 {
617 apex: "myotherapex",
618 module: "myotherbootclasspathfragment"
619 },
620 ],
621 }
622
623 java_sdk_library {
624 name: "mysdklibrary",
625 srcs: ["Test.java"],
626 shared_library: false,
627 public: {enabled: true},
628 min_sdk_version: "2",
629 }
630 `),
631 ).RunTest(t)
632
633 // A preparer to update the test fixture used when processing an unpackage snapshot.
634 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
635
636 CheckSnapshot(t, result, "mysdk", "",
637 checkUnversionedAndroidBpContents(`
638// This is auto-generated. DO NOT EDIT.
639
640prebuilt_bootclasspath_fragment {
641 name: "mybootclasspathfragment",
642 prefer: false,
643 visibility: ["//visibility:public"],
644 apex_available: ["//apex_available:platform"],
645 contents: ["mysdklibrary"],
646 fragments: [
647 {
648 apex: "myotherapex",
649 module: "myotherbootclasspathfragment",
650 },
651 ],
652 hidden_api: {
Paul Duffin51227d82021-05-18 12:54:27 +0100653 annotation_flags: "hiddenapi/annotation-flags.csv",
654 metadata: "hiddenapi/metadata.csv",
655 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100656 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100657 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffin51227d82021-05-18 12:54:27 +0100658 all_flags: "hiddenapi/all-flags.csv",
659 },
660}
661
662java_sdk_library_import {
663 name: "mysdklibrary",
664 prefer: false,
665 visibility: ["//visibility:public"],
666 apex_available: ["//apex_available:platform"],
667 shared_library: false,
668 public: {
669 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
670 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
671 current_api: "sdk_library/public/mysdklibrary.txt",
672 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
673 sdk_version: "current",
674 },
675}
676 `),
677 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
678 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
679 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
680 )
681}
682
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100683// Test that bootclasspath_fragment works with sdk.
684func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
Paul Duffin04b4a192021-03-18 11:05:31 +0000685 android.GroupFixturePreparers(
686 prepareForSdkTestWithApex,
687 prepareForSdkTestWithJava,
Paul Duffin8018e502021-05-21 19:28:09 +0100688 android.FixtureAddFile("java/mybootlib.jar", nil),
Paul Duffin04b4a192021-03-18 11:05:31 +0000689 android.FixtureWithRootAndroidBp(`
690 sdk {
691 name: "mysdk",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100692 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000693 }
694
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100695 bootclasspath_fragment {
696 name: "mybootclasspathfragment",
Paul Duffin04b4a192021-03-18 11:05:31 +0000697 image_name: "art",
Paul Duffin8018e502021-05-21 19:28:09 +0100698 contents: ["mybootlib"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000699 apex_available: ["myapex"],
700 }
701
Paul Duffin8018e502021-05-21 19:28:09 +0100702 java_library {
703 name: "mybootlib",
704 apex_available: ["myapex"],
705 srcs: ["Test.java"],
706 system_modules: "none",
707 sdk_version: "none",
708 min_sdk_version: "1",
709 compile_dex: true,
710 }
711
Paul Duffin04b4a192021-03-18 11:05:31 +0000712 sdk_snapshot {
713 name: "mysdk@1",
Paul Duffin8018e502021-05-21 19:28:09 +0100714 bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000715 }
716
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100717 prebuilt_bootclasspath_fragment {
Paul Duffin8018e502021-05-21 19:28:09 +0100718 name: "mysdk_mybootclasspathfragment@1",
Paul Duffin0b28a8d2021-04-21 23:38:34 +0100719 sdk_member_name: "mybootclasspathfragment",
Paul Duffin04b4a192021-03-18 11:05:31 +0000720 prefer: false,
721 visibility: ["//visibility:public"],
722 apex_available: [
723 "myapex",
724 ],
725 image_name: "art",
Paul Duffin8018e502021-05-21 19:28:09 +0100726 contents: ["mysdk_mybootlib@1"],
727 }
728
729 java_import {
730 name: "mysdk_mybootlib@1",
731 sdk_member_name: "mybootlib",
732 visibility: ["//visibility:public"],
733 apex_available: ["com.android.art"],
734 jars: ["java/mybootlib.jar"],
Paul Duffin04b4a192021-03-18 11:05:31 +0000735 }
736 `),
737 ).RunTest(t)
738}
Paul Duffin7c955552021-04-19 13:23:53 +0100739
740func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
741 result := android.GroupFixturePreparers(
742 prepareForSdkTestWithJava,
Paul Duffin475daaf2021-05-13 00:57:55 +0100743 java.PrepareForTestWithJavaDefaultModules,
744 java.PrepareForTestWithJavaSdkLibraryFiles,
745 java.FixtureWithLastReleaseApis("mysdklibrary"),
satayevd604b212021-07-21 14:23:52 +0100746 java.FixtureConfigureApexBootJars("myapex:mybootlib"),
Paul Duffin475daaf2021-05-13 00:57:55 +0100747 prepareForSdkTestWithApex,
Paul Duffin7c475152021-06-09 16:17:58 +0100748
749 // Add a platform_bootclasspath that depends on the fragment.
750 fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
751
Paul Duffin7c955552021-04-19 13:23:53 +0100752 android.MockFS{
753 "my-blocked.txt": nil,
754 "my-max-target-o-low-priority.txt": nil,
755 "my-max-target-p.txt": nil,
756 "my-max-target-q.txt": nil,
757 "my-max-target-r-low-priority.txt": nil,
758 "my-removed.txt": nil,
759 "my-unsupported-packages.txt": nil,
760 "my-unsupported.txt": nil,
761 }.AddToFixture(),
762 android.FixtureWithRootAndroidBp(`
763 sdk {
764 name: "mysdk",
765 bootclasspath_fragments: ["mybootclasspathfragment"],
Paul Duffin7c955552021-04-19 13:23:53 +0100766 }
767
Paul Duffin475daaf2021-05-13 00:57:55 +0100768 apex {
769 name: "myapex",
770 key: "myapex.key",
771 min_sdk_version: "1",
772 bootclasspath_fragments: ["mybootclasspathfragment"],
773 }
774
Paul Duffin7c955552021-04-19 13:23:53 +0100775 bootclasspath_fragment {
776 name: "mybootclasspathfragment",
Paul Duffin475daaf2021-05-13 00:57:55 +0100777 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100778 contents: ["mybootlib"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100779 api: {
780 stub_libs: ["mysdklibrary"],
781 },
Paul Duffin7c955552021-04-19 13:23:53 +0100782 hidden_api: {
783 unsupported: [
784 "my-unsupported.txt",
785 ],
786 removed: [
787 "my-removed.txt",
788 ],
789 max_target_r_low_priority: [
790 "my-max-target-r-low-priority.txt",
791 ],
792 max_target_q: [
793 "my-max-target-q.txt",
794 ],
795 max_target_p: [
796 "my-max-target-p.txt",
797 ],
798 max_target_o_low_priority: [
799 "my-max-target-o-low-priority.txt",
800 ],
801 blocked: [
802 "my-blocked.txt",
803 ],
804 unsupported_packages: [
805 "my-unsupported-packages.txt",
806 ],
807 },
808 }
809
810 java_library {
811 name: "mybootlib",
Paul Duffin475daaf2021-05-13 00:57:55 +0100812 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100813 srcs: ["Test.java"],
814 system_modules: "none",
815 sdk_version: "none",
Paul Duffin475daaf2021-05-13 00:57:55 +0100816 min_sdk_version: "1",
Paul Duffin7c955552021-04-19 13:23:53 +0100817 compile_dex: true,
Paul Duffin7c475152021-06-09 16:17:58 +0100818 permitted_packages: ["mybootlib"],
Paul Duffin7c955552021-04-19 13:23:53 +0100819 }
Paul Duffin475daaf2021-05-13 00:57:55 +0100820
821 java_sdk_library {
822 name: "mysdklibrary",
823 srcs: ["Test.java"],
824 compile_dex: true,
825 public: {enabled: true},
Paul Duffin869de142021-07-15 14:14:41 +0100826 permitted_packages: ["mysdklibrary"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100827 }
Paul Duffin7c955552021-04-19 13:23:53 +0100828 `),
829 ).RunTest(t)
830
Paul Duffin7c475152021-06-09 16:17:58 +0100831 // A preparer to update the test fixture used when processing an unpackage snapshot.
832 preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
833
Paul Duffin7c955552021-04-19 13:23:53 +0100834 CheckSnapshot(t, result, "mysdk", "",
835 checkUnversionedAndroidBpContents(`
836// This is auto-generated. DO NOT EDIT.
837
838prebuilt_bootclasspath_fragment {
839 name: "mybootclasspathfragment",
840 prefer: false,
841 visibility: ["//visibility:public"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100842 apex_available: ["myapex"],
Paul Duffin7c955552021-04-19 13:23:53 +0100843 contents: ["mybootlib"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100844 api: {
845 stub_libs: ["mysdklibrary"],
846 },
Paul Duffin7c955552021-04-19 13:23:53 +0100847 hidden_api: {
848 unsupported: ["hiddenapi/my-unsupported.txt"],
849 removed: ["hiddenapi/my-removed.txt"],
850 max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"],
851 max_target_q: ["hiddenapi/my-max-target-q.txt"],
852 max_target_p: ["hiddenapi/my-max-target-p.txt"],
853 max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"],
854 blocked: ["hiddenapi/my-blocked.txt"],
855 unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"],
Paul Duffin2fef1362021-04-15 13:32:00 +0100856 annotation_flags: "hiddenapi/annotation-flags.csv",
857 metadata: "hiddenapi/metadata.csv",
858 index: "hiddenapi/index.csv",
Paul Duffin8d007e92021-07-22 12:00:49 +0100859 signature_patterns: "hiddenapi/signature-patterns.csv",
Paul Duffin67b9d612021-07-21 17:38:47 +0100860 stub_flags: "hiddenapi/stub-flags.csv",
Paul Duffin2fef1362021-04-15 13:32:00 +0100861 all_flags: "hiddenapi/all-flags.csv",
Paul Duffin7c955552021-04-19 13:23:53 +0100862 },
863}
864
865java_import {
866 name: "mybootlib",
867 prefer: false,
868 visibility: ["//visibility:public"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100869 apex_available: ["myapex"],
Paul Duffin5c211452021-07-15 12:42:44 +0100870 jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
Paul Duffin869de142021-07-15 14:14:41 +0100871 permitted_packages: ["mybootlib"],
Paul Duffin7c955552021-04-19 13:23:53 +0100872}
Paul Duffin475daaf2021-05-13 00:57:55 +0100873
874java_sdk_library_import {
875 name: "mysdklibrary",
876 prefer: false,
877 visibility: ["//visibility:public"],
878 apex_available: ["//apex_available:platform"],
879 shared_library: true,
880 compile_dex: true,
Paul Duffin869de142021-07-15 14:14:41 +0100881 permitted_packages: ["mysdklibrary"],
Paul Duffin475daaf2021-05-13 00:57:55 +0100882 public: {
883 jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
884 stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
885 current_api: "sdk_library/public/mysdklibrary.txt",
886 removed_api: "sdk_library/public/mysdklibrary-removed.txt",
887 sdk_version: "current",
888 },
889}
Paul Duffin7c955552021-04-19 13:23:53 +0100890`),
891 checkAllCopyRules(`
892my-unsupported.txt -> hiddenapi/my-unsupported.txt
893my-removed.txt -> hiddenapi/my-removed.txt
894my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt
895my-max-target-q.txt -> hiddenapi/my-max-target-q.txt
896my-max-target-p.txt -> hiddenapi/my-max-target-p.txt
897my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt
898my-blocked.txt -> hiddenapi/my-blocked.txt
899my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
Paul Duffin2fef1362021-04-15 13:32:00 +0100900.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
901.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
902.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
Paul Duffin8d007e92021-07-22 12:00:49 +0100903.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
Paul Duffin67b9d612021-07-21 17:38:47 +0100904.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
Paul Duffin2fef1362021-04-15 13:32:00 +0100905.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
Paul Duffin5c211452021-07-15 12:42:44 +0100906.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
Paul Duffin475daaf2021-05-13 00:57:55 +0100907.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
908.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
909.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 +0100910`),
Paul Duffin7c475152021-06-09 16:17:58 +0100911 snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
912 snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
913 snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
Paul Duffin7c955552021-04-19 13:23:53 +0100914 )
915}