| 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 ( | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 18 | "fmt" | 
|  | 19 | "path/filepath" | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 20 | "strings" | 
| Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 21 | "testing" | 
|  | 22 |  | 
|  | 23 | "android/soong/android" | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 24 | "android/soong/java" | 
| Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 25 | ) | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 26 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 27 | // fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that | 
|  | 28 | // references the bootclasspath fragment. | 
|  | 29 | func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer { | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 30 | return fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra(apex, fragment, "") | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | // fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra is the same as above, but also adds extra fragments. | 
|  | 34 | func fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra(apex, fragment, extraFragments string) android.FixturePreparer { | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 35 | return android.GroupFixturePreparers( | 
|  | 36 | // Add a platform_bootclasspath module. | 
|  | 37 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(` | 
|  | 38 | platform_bootclasspath { | 
|  | 39 | name: "platform-bootclasspath", | 
|  | 40 | fragments: [ | 
|  | 41 | { | 
|  | 42 | apex: "%s", | 
|  | 43 | module: "%s", | 
|  | 44 | }, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 45 | %s | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 46 | ], | 
|  | 47 | } | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 48 | `, apex, fragment, extraFragments)), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 49 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), | 
| Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 50 | android.FixtureAddFile("frameworks/base/config/boot-image-profile.txt", nil), | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 51 | android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 52 | ) | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | // fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment. | 
|  | 56 | func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer { | 
|  | 57 | apexFile := fmt.Sprintf("%s.apex", apex) | 
|  | 58 | dir := "prebuilts/apex" | 
|  | 59 | return android.GroupFixturePreparers( | 
|  | 60 | // A preparer to add a prebuilt apex to the test fixture. | 
|  | 61 | android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(` | 
|  | 62 | prebuilt_apex { | 
|  | 63 | name: "%s", | 
|  | 64 | src: "%s", | 
|  | 65 | exported_bootclasspath_fragments: [ | 
|  | 66 | "%s", | 
|  | 67 | ], | 
|  | 68 | } | 
|  | 69 | `, apex, apexFile, fragment)), | 
|  | 70 | android.FixtureAddFile(filepath.Join(dir, apexFile), nil), | 
|  | 71 | ) | 
|  | 72 | } | 
|  | 73 |  | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 74 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { | 
|  | 75 | result := android.GroupFixturePreparers( | 
|  | 76 | prepareForSdkTestWithJava, | 
| Jiakai Zhang | b95998b | 2023-05-11 16:39:27 +0100 | [diff] [blame] | 77 | java.PrepareForTestWithDexpreopt, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 78 | prepareForSdkTestWithApex, | 
|  | 79 |  | 
|  | 80 | // Some additional files needed for the art apex. | 
|  | 81 | android.FixtureMergeMockFs(android.MockFS{ | 
|  | 82 | "com.android.art.avbpubkey":                          nil, | 
|  | 83 | "com.android.art.pem":                                nil, | 
|  | 84 | "system/sepolicy/apex/com.android.art-file_contexts": nil, | 
|  | 85 | }), | 
| Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 86 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 87 | // Add a platform_bootclasspath that depends on the fragment. | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 88 | fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra( | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 89 | "com.android.art", "art-bootclasspath-fragment", java.ApexBootJarFragmentsForPlatformBootclasspath), | 
| Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 90 |  | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 91 | java.PrepareForBootImageConfigTest, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 92 | java.PrepareApexBootJarConfigsAndModules, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 93 | android.FixtureWithRootAndroidBp(` | 
|  | 94 | sdk { | 
|  | 95 | name: "mysdk", | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 96 | bootclasspath_fragments: ["art-bootclasspath-fragment"], | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 97 | } | 
|  | 98 |  | 
|  | 99 | apex { | 
|  | 100 | name: "com.android.art", | 
|  | 101 | key: "com.android.art.key", | 
|  | 102 | bootclasspath_fragments: [ | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 103 | "art-bootclasspath-fragment", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 104 | ], | 
|  | 105 | updatable: false, | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | bootclasspath_fragment { | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 109 | name: "art-bootclasspath-fragment", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 110 | image_name: "art", | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 111 | contents: ["core1", "core2"], | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 112 | apex_available: ["com.android.art"], | 
| Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 113 | hidden_api: { | 
|  | 114 | split_packages: ["*"], | 
|  | 115 | }, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 116 | } | 
|  | 117 |  | 
|  | 118 | apex_key { | 
|  | 119 | name: "com.android.art.key", | 
|  | 120 | public_key: "com.android.art.avbpubkey", | 
|  | 121 | private_key: "com.android.art.pem", | 
|  | 122 | } | 
|  | 123 |  | 
|  | 124 | java_library { | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 125 | name: "core1", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 126 | srcs: ["Test.java"], | 
|  | 127 | system_modules: "none", | 
|  | 128 | sdk_version: "none", | 
|  | 129 | compile_dex: true, | 
|  | 130 | apex_available: ["com.android.art"], | 
|  | 131 | } | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 132 |  | 
|  | 133 | java_library { | 
|  | 134 | name: "core2", | 
|  | 135 | srcs: ["Test.java"], | 
|  | 136 | system_modules: "none", | 
|  | 137 | sdk_version: "none", | 
|  | 138 | compile_dex: true, | 
|  | 139 | apex_available: ["com.android.art"], | 
|  | 140 | } | 
|  | 141 | `), | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 142 | ).RunTest(t) | 
|  | 143 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 144 | // A preparer to update the test fixture used when processing an unpackage snapshot. | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 145 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "art-bootclasspath-fragment") | 
| Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 146 |  | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 147 | // Check that source on its own configures the bootImageConfig correctly. | 
| Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 148 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
|  | 149 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 150 |  | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 151 | CheckSnapshot(t, result, "mysdk", "", | 
| Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 152 | checkAndroidBpContents(` | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 153 | // This is auto-generated. DO NOT EDIT. | 
|  | 154 |  | 
|  | 155 | prebuilt_bootclasspath_fragment { | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 156 | name: "art-bootclasspath-fragment", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 157 | prefer: false, | 
|  | 158 | visibility: ["//visibility:public"], | 
|  | 159 | apex_available: ["com.android.art"], | 
|  | 160 | image_name: "art", | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 161 | contents: [ | 
|  | 162 | "core1", | 
|  | 163 | "core2", | 
|  | 164 | ], | 
| Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 165 | hidden_api: { | 
| Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 166 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 167 | metadata: "hiddenapi/metadata.csv", | 
|  | 168 | index: "hiddenapi/index.csv", | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 169 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
| Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 170 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 171 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
| Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 172 | }, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 173 | } | 
|  | 174 |  | 
|  | 175 | java_import { | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 176 | name: "core1", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 177 | prefer: false, | 
|  | 178 | visibility: ["//visibility:public"], | 
|  | 179 | apex_available: ["com.android.art"], | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 180 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core1.jar"], | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 181 | } | 
|  | 182 |  | 
|  | 183 | java_import { | 
|  | 184 | name: "core2", | 
|  | 185 | prefer: false, | 
|  | 186 | visibility: ["//visibility:public"], | 
|  | 187 | apex_available: ["com.android.art"], | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 188 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"], | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 189 | } | 
|  | 190 | `), | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 191 | checkAllCopyRules(` | 
| Jiakai Zhang | b69e895 | 2023-07-11 14:31:22 +0100 | [diff] [blame] | 192 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 193 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv | 
|  | 194 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv | 
|  | 195 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv | 
|  | 196 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv | 
|  | 197 | .intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 198 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar | 
|  | 199 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar | 
| Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 200 | `), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 201 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 202 |  | 
|  | 203 | // Check the behavior of the snapshot without the source. | 
|  | 204 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 205 | // Make sure that the boot jars package check rule includes the dex jars retrieved from the prebuilt apex. | 
|  | 206 | checkBootJarsPackageCheckRule(t, result, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 207 | append( | 
|  | 208 | []string{ | 
|  | 209 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar", | 
|  | 210 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar", | 
|  | 211 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar", | 
|  | 212 | }, | 
|  | 213 | java.ApexBootJarDexJarPaths..., | 
|  | 214 | )..., | 
|  | 215 | ) | 
| Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 216 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
|  | 217 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 218 | }), | 
|  | 219 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 220 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 221 |  | 
|  | 222 | // Check the behavior of the snapshot when the source is preferred. | 
|  | 223 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { | 
| Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 224 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
|  | 225 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 226 | }), | 
|  | 227 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 228 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 229 |  | 
|  | 230 | // Check the behavior of the snapshot when it is preferred. | 
|  | 231 | snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) { | 
| Jiakai Zhang | cb13b5d | 2023-07-13 11:03:38 +0100 | [diff] [blame] | 232 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
|  | 233 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic") | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 234 | }), | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 235 | ) | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 236 |  | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 237 | // Make sure that the boot jars package check rule includes the dex jars created from the source. | 
|  | 238 | checkBootJarsPackageCheckRule(t, result, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 239 | append( | 
|  | 240 | []string{ | 
|  | 241 | "out/soong/.intermediates/core1/android_common_apex10000/aligned/core1.jar", | 
|  | 242 | "out/soong/.intermediates/core2/android_common_apex10000/aligned/core2.jar", | 
|  | 243 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar", | 
|  | 244 | }, | 
|  | 245 | java.ApexBootJarDexJarPaths..., | 
|  | 246 | )..., | 
|  | 247 | ) | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 248 | } | 
|  | 249 |  | 
|  | 250 | // checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars | 
|  | 251 | // package check rule. | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 252 | func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModules ...string) { | 
|  | 253 | t.Helper() | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 254 | platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common") | 
|  | 255 | bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check") | 
|  | 256 | command := bootJarsCheckRule.RuleParams.Command | 
| Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 257 | expectedCommandArgs := " build/soong/scripts/check_boot_jars/package_allowed_list.txt " + strings.Join(expectedModules, " ") + " &&" | 
| Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 258 | android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs) | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 259 | } | 
|  | 260 |  | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 261 | func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, copyRules string) { | 
| Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 262 | result := android.GroupFixturePreparers( | 
|  | 263 | prepareForSdkTestWithJava, | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 264 | java.PrepareForTestWithJavaDefaultModules, | 
|  | 265 | java.PrepareForTestWithJavaSdkLibraryFiles, | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 266 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 267 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 268 | prepareForSdkTestWithApex, | 
|  | 269 |  | 
|  | 270 | // Add a platform_bootclasspath that depends on the fragment. | 
|  | 271 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), | 
|  | 272 |  | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 273 | android.FixtureWithRootAndroidBp(sdk+` | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 274 | apex { | 
|  | 275 | name: "myapex", | 
|  | 276 | key: "myapex.key", | 
|  | 277 | min_sdk_version: "2", | 
|  | 278 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 279 | } | 
|  | 280 |  | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 281 | bootclasspath_fragment { | 
|  | 282 | name: "mybootclasspathfragment", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 283 | apex_available: ["myapex"], | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 284 | contents: [ | 
|  | 285 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. | 
|  | 286 | "mybootlib", | 
|  | 287 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. | 
|  | 288 | "myothersdklibrary", | 
|  | 289 | ], | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 290 | api: { | 
|  | 291 | stub_libs: ["mysdklibrary"], | 
|  | 292 | }, | 
|  | 293 | core_platform_api: { | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 294 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 295 | stub_libs: ["mycoreplatform"], | 
|  | 296 | }, | 
| Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 297 | hidden_api: { | 
|  | 298 | split_packages: ["*"], | 
|  | 299 | }, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 300 | } | 
|  | 301 |  | 
|  | 302 | java_library { | 
|  | 303 | name: "mybootlib", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 304 | apex_available: ["myapex"], | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 305 | srcs: ["Test.java"], | 
|  | 306 | system_modules: "none", | 
|  | 307 | sdk_version: "none", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 308 | min_sdk_version: "2", | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 309 | compile_dex: true, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 310 | permitted_packages: ["mybootlib"], | 
| Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 311 | } | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 312 |  | 
|  | 313 | java_sdk_library { | 
|  | 314 | name: "mysdklibrary", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 315 | apex_available: ["myapex"], | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 316 | srcs: ["Test.java"], | 
| Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 317 | shared_library: false, | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 318 | public: {enabled: true}, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 319 | min_sdk_version: "2", | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 320 | } | 
|  | 321 |  | 
|  | 322 | java_sdk_library { | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 323 | name: "myothersdklibrary", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 324 | apex_available: ["myapex"], | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 325 | srcs: ["Test.java"], | 
| Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 326 | compile_dex: true, | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 327 | public: {enabled: true}, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 328 | min_sdk_version: "2", | 
|  | 329 | permitted_packages: ["myothersdklibrary"], | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 330 | } | 
|  | 331 |  | 
|  | 332 | java_sdk_library { | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 333 | name: "mycoreplatform", | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 334 | apex_available: ["myapex"], | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 335 | srcs: ["Test.java"], | 
| Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 336 | compile_dex: true, | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 337 | public: {enabled: true}, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 338 | min_sdk_version: "2", | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 339 | } | 
| Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 340 | `), | 
|  | 341 | ).RunTest(t) | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 342 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 343 | // A preparer to update the test fixture used when processing an unpackage snapshot. | 
|  | 344 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") | 
|  | 345 |  | 
| Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 346 | CheckSnapshot(t, result, "mysdk", "", | 
| Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 347 | checkAndroidBpContents(` | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 348 | // This is auto-generated. DO NOT EDIT. | 
|  | 349 |  | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 350 | prebuilt_bootclasspath_fragment { | 
|  | 351 | name: "mybootclasspathfragment", | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 352 | prefer: false, | 
|  | 353 | visibility: ["//visibility:public"], | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 354 | apex_available: ["myapex"], | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 355 | contents: [ | 
|  | 356 | "mybootlib", | 
|  | 357 | "myothersdklibrary", | 
|  | 358 | ], | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 359 | api: { | 
|  | 360 | stub_libs: ["mysdklibrary"], | 
|  | 361 | }, | 
|  | 362 | core_platform_api: { | 
|  | 363 | stub_libs: ["mycoreplatform"], | 
|  | 364 | }, | 
| Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 365 | hidden_api: { | 
| Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 366 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 367 | metadata: "hiddenapi/metadata.csv", | 
|  | 368 | index: "hiddenapi/index.csv", | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 369 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
| Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 370 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 371 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
| Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 372 | }, | 
| Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 373 | } | 
|  | 374 |  | 
|  | 375 | java_import { | 
|  | 376 | name: "mybootlib", | 
|  | 377 | prefer: false, | 
|  | 378 | visibility: ["//visibility:public"], | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 379 | apex_available: ["myapex"], | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 380 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], | 
| Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 381 | min_sdk_version: "2", | 
| Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 382 | permitted_packages: ["mybootlib"], | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 383 | } | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 384 |  | 
|  | 385 | java_sdk_library_import { | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 386 | name: "myothersdklibrary", | 
|  | 387 | prefer: false, | 
|  | 388 | visibility: ["//visibility:public"], | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 389 | apex_available: ["myapex"], | 
| Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 390 | shared_library: true, | 
|  | 391 | compile_dex: true, | 
| Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 392 | permitted_packages: ["myothersdklibrary"], | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 393 | public: { | 
|  | 394 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], | 
|  | 395 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], | 
|  | 396 | current_api: "sdk_library/public/myothersdklibrary.txt", | 
|  | 397 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", | 
|  | 398 | sdk_version: "current", | 
|  | 399 | }, | 
|  | 400 | } | 
|  | 401 |  | 
|  | 402 | java_sdk_library_import { | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 403 | name: "mysdklibrary", | 
|  | 404 | prefer: false, | 
|  | 405 | visibility: ["//visibility:public"], | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 406 | apex_available: ["myapex"], | 
| Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 407 | shared_library: false, | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 408 | public: { | 
|  | 409 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], | 
|  | 410 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], | 
|  | 411 | current_api: "sdk_library/public/mysdklibrary.txt", | 
|  | 412 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", | 
|  | 413 | sdk_version: "current", | 
|  | 414 | }, | 
|  | 415 | } | 
|  | 416 |  | 
|  | 417 | java_sdk_library_import { | 
|  | 418 | name: "mycoreplatform", | 
|  | 419 | prefer: false, | 
|  | 420 | visibility: ["//visibility:public"], | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 421 | apex_available: ["myapex"], | 
| Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 422 | shared_library: true, | 
|  | 423 | compile_dex: true, | 
| Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 424 | public: { | 
|  | 425 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], | 
|  | 426 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], | 
|  | 427 | current_api: "sdk_library/public/mycoreplatform.txt", | 
|  | 428 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", | 
|  | 429 | sdk_version: "current", | 
|  | 430 | }, | 
|  | 431 | } | 
| Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 432 | `), | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 433 | checkAllCopyRules(copyRules), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 434 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), | 
| Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 435 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { | 
|  | 436 | module := result.ModuleForTests("platform-bootclasspath", "android_common") | 
|  | 437 | var rule android.TestingBuildParams | 
|  | 438 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") | 
|  | 439 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` | 
|  | 440 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv | 
|  | 441 | out/soong/hiddenapi/hiddenapi-stub-flags.txt | 
|  | 442 | snapshot/hiddenapi/annotation-flags.csv | 
|  | 443 | `, rule) | 
|  | 444 |  | 
|  | 445 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") | 
|  | 446 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` | 
|  | 447 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv | 
|  | 448 | snapshot/hiddenapi/metadata.csv | 
|  | 449 | `, rule) | 
|  | 450 |  | 
|  | 451 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") | 
|  | 452 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` | 
|  | 453 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv | 
|  | 454 | snapshot/hiddenapi/index.csv | 
|  | 455 | `, rule) | 
| Paul Duffin | 630b11e | 2021-07-15 13:35:26 +0100 | [diff] [blame] | 456 |  | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 457 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") | 
| Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 458 | android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/filtered-flags.csv:snapshot/hiddenapi/signature-patterns.csv ") | 
| Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 459 | }), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 460 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 461 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { | 
|  | 462 | module := result.ModuleForTests("platform-bootclasspath", "android_common") | 
|  | 463 | rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") | 
| Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 464 | 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 Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 465 | }), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 466 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), | 
|  | 467 | ) | 
| Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 468 | } | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 469 |  | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 470 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { | 
|  | 471 | t.Run("added-directly", func(t *testing.T) { | 
|  | 472 | testSnapshotWithBootClasspathFragment_Contents(t, ` | 
|  | 473 | sdk { | 
|  | 474 | name: "mysdk", | 
|  | 475 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 476 | java_sdk_libs: [ | 
|  | 477 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as | 
|  | 478 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's | 
|  | 479 | // api.stub_libs property. However, it is specified here to ensure that duplicates are | 
|  | 480 | // correctly deduped. | 
|  | 481 | "mysdklibrary", | 
|  | 482 | ], | 
|  | 483 | } | 
|  | 484 | `, ` | 
|  | 485 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 486 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv | 
|  | 487 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv | 
|  | 488 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv | 
|  | 489 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv | 
|  | 490 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 491 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 492 | .intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 493 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt | 
|  | 494 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 495 | .intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 496 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt | 
|  | 497 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 498 | .intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 499 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt | 
|  | 500 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt | 
|  | 501 | `) | 
|  | 502 | }) | 
|  | 503 |  | 
|  | 504 | copyBootclasspathFragmentFromApexVariantRules := ` | 
|  | 505 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 506 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv | 
|  | 507 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv | 
|  | 508 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv | 
|  | 509 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv | 
|  | 510 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 511 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 512 | .intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 513 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt | 
|  | 514 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 515 | .intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 516 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt | 
|  | 517 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 518 | .intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar | 
| Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 519 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt | 
|  | 520 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt | 
|  | 521 | ` | 
|  | 522 | t.Run("added-via-apex", func(t *testing.T) { | 
|  | 523 | testSnapshotWithBootClasspathFragment_Contents(t, ` | 
|  | 524 | sdk { | 
|  | 525 | name: "mysdk", | 
|  | 526 | apexes: ["myapex"], | 
|  | 527 | } | 
|  | 528 | `, copyBootclasspathFragmentFromApexVariantRules) | 
|  | 529 | }) | 
|  | 530 |  | 
|  | 531 | t.Run("added-directly-and-indirectly", func(t *testing.T) { | 
|  | 532 | testSnapshotWithBootClasspathFragment_Contents(t, ` | 
|  | 533 | sdk { | 
|  | 534 | name: "mysdk", | 
|  | 535 | apexes: ["myapex"], | 
|  | 536 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as | 
|  | 537 | // a bootclasspath_fragments module because it is used in the myapex's | 
|  | 538 | // bootclasspath_fragments property. However, it is specified here to ensure that duplicates | 
|  | 539 | // are correctly deduped. | 
|  | 540 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 541 | java_sdk_libs: [ | 
|  | 542 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as | 
|  | 543 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's | 
|  | 544 | // api.stub_libs property. However, it is specified here to ensure that duplicates are | 
|  | 545 | // correctly deduped. | 
|  | 546 | "mysdklibrary", | 
|  | 547 | ], | 
|  | 548 | } | 
|  | 549 | `, copyBootclasspathFragmentFromApexVariantRules) | 
|  | 550 | }) | 
|  | 551 | } | 
|  | 552 |  | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 553 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a | 
|  | 554 | // bootclasspath_fragment is correctly output to the sdk snapshot. | 
|  | 555 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { | 
|  | 556 | result := android.GroupFixturePreparers( | 
|  | 557 | prepareForSdkTestWithJava, | 
|  | 558 | java.PrepareForTestWithJavaDefaultModules, | 
|  | 559 | java.PrepareForTestWithJavaSdkLibraryFiles, | 
|  | 560 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), | 
| satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 561 | java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"), | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 562 | prepareForSdkTestWithApex, | 
|  | 563 |  | 
|  | 564 | // Some additional files needed for the myotherapex. | 
|  | 565 | android.FixtureMergeMockFs(android.MockFS{ | 
|  | 566 | "system/sepolicy/apex/myotherapex-file_contexts": nil, | 
|  | 567 | "myotherapex/apex_manifest.json":                 nil, | 
|  | 568 | "myotherapex/Test.java":                          nil, | 
|  | 569 | }), | 
|  | 570 |  | 
|  | 571 | android.FixtureAddTextFile("myotherapex/Android.bp", ` | 
|  | 572 | apex { | 
|  | 573 | name: "myotherapex", | 
|  | 574 | key: "myapex.key", | 
|  | 575 | min_sdk_version: "2", | 
|  | 576 | bootclasspath_fragments: ["myotherbootclasspathfragment"], | 
|  | 577 | } | 
|  | 578 |  | 
|  | 579 | bootclasspath_fragment { | 
|  | 580 | name: "myotherbootclasspathfragment", | 
|  | 581 | apex_available: ["myotherapex"], | 
|  | 582 | contents: [ | 
|  | 583 | "myotherlib", | 
|  | 584 | ], | 
| Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 585 | hidden_api: { | 
|  | 586 | split_packages: ["*"], | 
|  | 587 | }, | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 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 | ], | 
| Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 617 | hidden_api: { | 
|  | 618 | split_packages: ["*"], | 
|  | 619 | }, | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 620 | } | 
|  | 621 |  | 
|  | 622 | java_sdk_library { | 
|  | 623 | name: "mysdklibrary", | 
|  | 624 | srcs: ["Test.java"], | 
|  | 625 | shared_library: false, | 
|  | 626 | public: {enabled: true}, | 
|  | 627 | min_sdk_version: "2", | 
|  | 628 | } | 
|  | 629 | `), | 
|  | 630 | ).RunTest(t) | 
|  | 631 |  | 
|  | 632 | // A preparer to update the test fixture used when processing an unpackage snapshot. | 
|  | 633 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") | 
|  | 634 |  | 
|  | 635 | CheckSnapshot(t, result, "mysdk", "", | 
| Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 636 | checkAndroidBpContents(` | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 637 | // This is auto-generated. DO NOT EDIT. | 
|  | 638 |  | 
|  | 639 | prebuilt_bootclasspath_fragment { | 
|  | 640 | name: "mybootclasspathfragment", | 
|  | 641 | prefer: false, | 
|  | 642 | visibility: ["//visibility:public"], | 
|  | 643 | apex_available: ["//apex_available:platform"], | 
|  | 644 | contents: ["mysdklibrary"], | 
|  | 645 | fragments: [ | 
|  | 646 | { | 
|  | 647 | apex: "myotherapex", | 
|  | 648 | module: "myotherbootclasspathfragment", | 
|  | 649 | }, | 
|  | 650 | ], | 
|  | 651 | hidden_api: { | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 652 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 653 | metadata: "hiddenapi/metadata.csv", | 
|  | 654 | index: "hiddenapi/index.csv", | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 655 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
| Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 656 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 657 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
| Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 658 | }, | 
|  | 659 | } | 
|  | 660 |  | 
|  | 661 | java_sdk_library_import { | 
|  | 662 | name: "mysdklibrary", | 
|  | 663 | prefer: false, | 
|  | 664 | visibility: ["//visibility:public"], | 
|  | 665 | apex_available: ["//apex_available:platform"], | 
|  | 666 | shared_library: false, | 
|  | 667 | public: { | 
|  | 668 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], | 
|  | 669 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], | 
|  | 670 | current_api: "sdk_library/public/mysdklibrary.txt", | 
|  | 671 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", | 
|  | 672 | sdk_version: "current", | 
|  | 673 | }, | 
|  | 674 | } | 
|  | 675 | `), | 
|  | 676 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), | 
|  | 677 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), | 
|  | 678 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), | 
|  | 679 | ) | 
|  | 680 | } | 
|  | 681 |  | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 682 | // Test that bootclasspath_fragment works with sdk. | 
|  | 683 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 684 | android.GroupFixturePreparers( | 
|  | 685 | prepareForSdkTestWithApex, | 
|  | 686 | prepareForSdkTestWithJava, | 
| Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 687 | android.FixtureMergeMockFs(android.MockFS{ | 
|  | 688 | "java/mybootlib.jar":                nil, | 
|  | 689 | "hiddenapi/annotation-flags.csv":    nil, | 
|  | 690 | "hiddenapi/index.csv":               nil, | 
|  | 691 | "hiddenapi/metadata.csv":            nil, | 
|  | 692 | "hiddenapi/signature-patterns.csv":  nil, | 
|  | 693 | "hiddenapi/filtered-stub-flags.csv": nil, | 
|  | 694 | "hiddenapi/filtered-flags.csv":      nil, | 
|  | 695 | }), | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 696 | android.FixtureWithRootAndroidBp(` | 
|  | 697 | sdk { | 
|  | 698 | name: "mysdk", | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 699 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 700 | } | 
|  | 701 |  | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 702 | bootclasspath_fragment { | 
|  | 703 | name: "mybootclasspathfragment", | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 704 | image_name: "art", | 
| Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 705 | contents: ["mybootlib"], | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 706 | apex_available: ["myapex"], | 
| Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 707 | hidden_api: { | 
|  | 708 | split_packages: ["*"], | 
|  | 709 | }, | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 710 | } | 
|  | 711 |  | 
| Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 712 | java_library { | 
|  | 713 | name: "mybootlib", | 
|  | 714 | apex_available: ["myapex"], | 
|  | 715 | srcs: ["Test.java"], | 
|  | 716 | system_modules: "none", | 
|  | 717 | sdk_version: "none", | 
|  | 718 | min_sdk_version: "1", | 
|  | 719 | compile_dex: true, | 
|  | 720 | } | 
|  | 721 |  | 
| Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 722 | prebuilt_bootclasspath_fragment { | 
| Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 723 | name: "mybootclasspathfragment", | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 724 | prefer: false, | 
|  | 725 | visibility: ["//visibility:public"], | 
|  | 726 | apex_available: [ | 
|  | 727 | "myapex", | 
|  | 728 | ], | 
|  | 729 | image_name: "art", | 
| Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 730 | contents: ["mybootlib"], | 
|  | 731 | hidden_api: { | 
|  | 732 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 733 | metadata: "hiddenapi/metadata.csv", | 
|  | 734 | index: "hiddenapi/index.csv", | 
|  | 735 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
|  | 736 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 737 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
|  | 738 | }, | 
| Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 739 | } | 
|  | 740 |  | 
|  | 741 | java_import { | 
| Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 742 | name: "mybootlib", | 
| Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 743 | visibility: ["//visibility:public"], | 
|  | 744 | apex_available: ["com.android.art"], | 
|  | 745 | jars: ["java/mybootlib.jar"], | 
| Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 746 | } | 
|  | 747 | `), | 
|  | 748 | ).RunTest(t) | 
|  | 749 | } | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 750 |  | 
|  | 751 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { | 
|  | 752 | result := android.GroupFixturePreparers( | 
|  | 753 | prepareForSdkTestWithJava, | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 754 | java.PrepareForTestWithJavaDefaultModules, | 
|  | 755 | java.PrepareForTestWithJavaSdkLibraryFiles, | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 756 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"), | 
|  | 757 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"), | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 758 | prepareForSdkTestWithApex, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 759 |  | 
|  | 760 | // Add a platform_bootclasspath that depends on the fragment. | 
|  | 761 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), | 
|  | 762 |  | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 763 | android.MockFS{ | 
|  | 764 | "my-blocked.txt":                   nil, | 
|  | 765 | "my-max-target-o-low-priority.txt": nil, | 
|  | 766 | "my-max-target-p.txt":              nil, | 
|  | 767 | "my-max-target-q.txt":              nil, | 
|  | 768 | "my-max-target-r-low-priority.txt": nil, | 
|  | 769 | "my-removed.txt":                   nil, | 
|  | 770 | "my-unsupported-packages.txt":      nil, | 
|  | 771 | "my-unsupported.txt":               nil, | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 772 | "my-new-max-target-q.txt":          nil, | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 773 | }.AddToFixture(), | 
|  | 774 | android.FixtureWithRootAndroidBp(` | 
|  | 775 | sdk { | 
|  | 776 | name: "mysdk", | 
|  | 777 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 778 | } | 
|  | 779 |  | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 780 | apex { | 
|  | 781 | name: "myapex", | 
|  | 782 | key: "myapex.key", | 
|  | 783 | min_sdk_version: "1", | 
|  | 784 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 785 | } | 
|  | 786 |  | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 787 | bootclasspath_fragment { | 
|  | 788 | name: "mybootclasspathfragment", | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 789 | apex_available: ["myapex"], | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 790 | contents: ["mybootlib", "mynewlibrary"], | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 791 | api: { | 
|  | 792 | stub_libs: ["mysdklibrary"], | 
|  | 793 | }, | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 794 | hidden_api: { | 
|  | 795 | unsupported: [ | 
|  | 796 | "my-unsupported.txt", | 
|  | 797 | ], | 
|  | 798 | removed: [ | 
|  | 799 | "my-removed.txt", | 
|  | 800 | ], | 
|  | 801 | max_target_r_low_priority: [ | 
|  | 802 | "my-max-target-r-low-priority.txt", | 
|  | 803 | ], | 
|  | 804 | max_target_q: [ | 
|  | 805 | "my-max-target-q.txt", | 
|  | 806 | ], | 
|  | 807 | max_target_p: [ | 
|  | 808 | "my-max-target-p.txt", | 
|  | 809 | ], | 
|  | 810 | max_target_o_low_priority: [ | 
|  | 811 | "my-max-target-o-low-priority.txt", | 
|  | 812 | ], | 
|  | 813 | blocked: [ | 
|  | 814 | "my-blocked.txt", | 
|  | 815 | ], | 
|  | 816 | unsupported_packages: [ | 
|  | 817 | "my-unsupported-packages.txt", | 
|  | 818 | ], | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 819 | split_packages: ["sdklibrary"], | 
|  | 820 | package_prefixes: ["sdklibrary.all.mine"], | 
|  | 821 | single_packages: ["sdklibrary.mine"], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 822 | }, | 
|  | 823 | } | 
|  | 824 |  | 
|  | 825 | java_library { | 
|  | 826 | name: "mybootlib", | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 827 | apex_available: ["myapex"], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 828 | srcs: ["Test.java"], | 
|  | 829 | system_modules: "none", | 
|  | 830 | sdk_version: "none", | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 831 | min_sdk_version: "1", | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 832 | compile_dex: true, | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 833 | permitted_packages: ["mybootlib"], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 834 | } | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 835 |  | 
|  | 836 | java_sdk_library { | 
|  | 837 | name: "mysdklibrary", | 
|  | 838 | srcs: ["Test.java"], | 
|  | 839 | compile_dex: true, | 
|  | 840 | public: {enabled: true}, | 
| Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 841 | permitted_packages: ["mysdklibrary"], | 
| Spandan Das | 9145508 | 2023-03-02 04:41:35 +0000 | [diff] [blame] | 842 | min_sdk_version: "current", | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 843 | } | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 844 |  | 
|  | 845 | java_sdk_library { | 
|  | 846 | name: "mynewlibrary", | 
|  | 847 | apex_available: ["myapex"], | 
|  | 848 | srcs: ["Test.java"], | 
|  | 849 | min_sdk_version: "10", | 
|  | 850 | compile_dex: true, | 
|  | 851 | public: {enabled: true}, | 
|  | 852 | permitted_packages: ["mysdklibrary"], | 
|  | 853 | hidden_api: { | 
|  | 854 | max_target_q: [ | 
|  | 855 | "my-new-max-target-q.txt", | 
|  | 856 | ], | 
|  | 857 | split_packages: ["sdklibrary", "newlibrary"], | 
|  | 858 | package_prefixes: ["newlibrary.all.mine"], | 
|  | 859 | single_packages: ["newlibrary.mine"], | 
|  | 860 | }, | 
|  | 861 | } | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 862 | `), | 
|  | 863 | ).RunTest(t) | 
|  | 864 |  | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 865 | // A preparer to update the test fixture used when processing an unpackage snapshot. | 
|  | 866 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") | 
|  | 867 |  | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 868 | CheckSnapshot(t, result, "mysdk", "", | 
| Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 869 | checkAndroidBpContents(` | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 870 | // This is auto-generated. DO NOT EDIT. | 
|  | 871 |  | 
|  | 872 | prebuilt_bootclasspath_fragment { | 
|  | 873 | name: "mybootclasspathfragment", | 
|  | 874 | prefer: false, | 
|  | 875 | visibility: ["//visibility:public"], | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 876 | apex_available: ["myapex"], | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 877 | contents: [ | 
|  | 878 | "mybootlib", | 
|  | 879 | "mynewlibrary", | 
|  | 880 | ], | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 881 | api: { | 
|  | 882 | stub_libs: ["mysdklibrary"], | 
|  | 883 | }, | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 884 | hidden_api: { | 
|  | 885 | unsupported: ["hiddenapi/my-unsupported.txt"], | 
|  | 886 | removed: ["hiddenapi/my-removed.txt"], | 
|  | 887 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 888 | max_target_q: [ | 
|  | 889 | "hiddenapi/my-max-target-q.txt", | 
|  | 890 | "hiddenapi/my-new-max-target-q.txt", | 
|  | 891 | ], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 892 | max_target_p: ["hiddenapi/my-max-target-p.txt"], | 
|  | 893 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], | 
|  | 894 | blocked: ["hiddenapi/my-blocked.txt"], | 
|  | 895 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], | 
| Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 896 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 897 | metadata: "hiddenapi/metadata.csv", | 
|  | 898 | index: "hiddenapi/index.csv", | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 899 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
| Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 900 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 901 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 902 | }, | 
|  | 903 | } | 
|  | 904 |  | 
|  | 905 | java_import { | 
|  | 906 | name: "mybootlib", | 
|  | 907 | prefer: false, | 
|  | 908 | visibility: ["//visibility:public"], | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 909 | apex_available: ["myapex"], | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 910 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], | 
| Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 911 | min_sdk_version: "1", | 
| Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 912 | permitted_packages: ["mybootlib"], | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 913 | } | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 914 |  | 
|  | 915 | java_sdk_library_import { | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 916 | name: "mynewlibrary", | 
|  | 917 | prefer: false, | 
|  | 918 | visibility: ["//visibility:public"], | 
|  | 919 | apex_available: ["myapex"], | 
|  | 920 | shared_library: true, | 
|  | 921 | compile_dex: true, | 
|  | 922 | permitted_packages: ["mysdklibrary"], | 
|  | 923 | public: { | 
|  | 924 | jars: ["sdk_library/public/mynewlibrary-stubs.jar"], | 
|  | 925 | stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"], | 
|  | 926 | current_api: "sdk_library/public/mynewlibrary.txt", | 
|  | 927 | removed_api: "sdk_library/public/mynewlibrary-removed.txt", | 
|  | 928 | sdk_version: "current", | 
|  | 929 | }, | 
|  | 930 | } | 
|  | 931 |  | 
|  | 932 | java_sdk_library_import { | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 933 | name: "mysdklibrary", | 
|  | 934 | prefer: false, | 
|  | 935 | visibility: ["//visibility:public"], | 
|  | 936 | apex_available: ["//apex_available:platform"], | 
|  | 937 | shared_library: true, | 
|  | 938 | compile_dex: true, | 
| Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 939 | permitted_packages: ["mysdklibrary"], | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 940 | public: { | 
|  | 941 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], | 
|  | 942 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], | 
|  | 943 | current_api: "sdk_library/public/mysdklibrary.txt", | 
|  | 944 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", | 
|  | 945 | sdk_version: "current", | 
|  | 946 | }, | 
|  | 947 | } | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 948 | `), | 
|  | 949 | checkAllCopyRules(` | 
|  | 950 | my-unsupported.txt -> hiddenapi/my-unsupported.txt | 
|  | 951 | my-removed.txt -> hiddenapi/my-removed.txt | 
|  | 952 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt | 
|  | 953 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 954 | my-new-max-target-q.txt -> hiddenapi/my-new-max-target-q.txt | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 955 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt | 
|  | 956 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt | 
|  | 957 | my-blocked.txt -> hiddenapi/my-blocked.txt | 
|  | 958 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt | 
| Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 959 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 960 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv | 
|  | 961 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv | 
| Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 962 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv | 
| Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 963 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv | 
|  | 964 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv | 
| Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 965 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 966 | .intermediates/mynewlibrary.stubs/android_common/combined/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar | 
| Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 967 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt | 
|  | 968 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 969 | .intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar | 
| Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 970 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt | 
|  | 971 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 972 | `), | 
| Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 973 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), | 
|  | 974 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), | 
|  | 975 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), | 
| Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 976 | ) | 
|  | 977 | } | 
| Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 978 |  | 
|  | 979 | func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string, | 
|  | 980 | expectedSdkSnapshot string, | 
|  | 981 | expectedCopyRules string, | 
|  | 982 | expectedStubFlagsInputs []string, | 
|  | 983 | suffix string) { | 
|  | 984 |  | 
|  | 985 | result := android.GroupFixturePreparers( | 
|  | 986 | prepareForSdkTestWithJava, | 
|  | 987 | java.PrepareForTestWithJavaDefaultModules, | 
|  | 988 | java.PrepareForTestWithJavaSdkLibraryFiles, | 
|  | 989 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"), | 
|  | 990 | java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"), | 
|  | 991 | prepareForSdkTestWithApex, | 
|  | 992 |  | 
|  | 993 | // Add a platform_bootclasspath that depends on the fragment. | 
|  | 994 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), | 
|  | 995 |  | 
|  | 996 | android.FixtureMergeEnv(map[string]string{ | 
|  | 997 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, | 
|  | 998 | }), | 
|  | 999 |  | 
|  | 1000 | android.FixtureWithRootAndroidBp(` | 
|  | 1001 | sdk { | 
|  | 1002 | name: "mysdk", | 
|  | 1003 | apexes: ["myapex"], | 
|  | 1004 | } | 
|  | 1005 |  | 
|  | 1006 | apex { | 
|  | 1007 | name: "myapex", | 
|  | 1008 | key: "myapex.key", | 
|  | 1009 | min_sdk_version: "S", | 
|  | 1010 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 1011 | } | 
|  | 1012 |  | 
|  | 1013 | bootclasspath_fragment { | 
|  | 1014 | name: "mybootclasspathfragment", | 
|  | 1015 | apex_available: ["myapex"], | 
|  | 1016 | contents: [ | 
|  | 1017 | "mysdklibrary", | 
|  | 1018 | "mynewsdklibrary", | 
|  | 1019 | ], | 
|  | 1020 |  | 
|  | 1021 | hidden_api: { | 
|  | 1022 | split_packages: [], | 
|  | 1023 | }, | 
|  | 1024 | } | 
|  | 1025 |  | 
|  | 1026 | java_sdk_library { | 
|  | 1027 | name: "mysdklibrary", | 
|  | 1028 | apex_available: ["myapex"], | 
|  | 1029 | srcs: ["Test.java"], | 
|  | 1030 | shared_library: false, | 
|  | 1031 | public: {enabled: true}, | 
|  | 1032 | min_sdk_version: "S", | 
|  | 1033 | } | 
|  | 1034 |  | 
|  | 1035 | java_sdk_library { | 
|  | 1036 | name: "mynewsdklibrary", | 
|  | 1037 | apex_available: ["myapex"], | 
|  | 1038 | srcs: ["Test.java"], | 
|  | 1039 | compile_dex: true, | 
|  | 1040 | public: {enabled: true}, | 
|  | 1041 | min_sdk_version: "Tiramisu", | 
|  | 1042 | permitted_packages: ["mynewsdklibrary"], | 
|  | 1043 | } | 
|  | 1044 | `), | 
|  | 1045 | ).RunTest(t) | 
|  | 1046 |  | 
|  | 1047 | bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common") | 
|  | 1048 | rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv") | 
|  | 1049 | android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits) | 
|  | 1050 |  | 
|  | 1051 | CheckSnapshot(t, result, "mysdk", "", | 
|  | 1052 | checkAndroidBpContents(expectedSdkSnapshot), | 
|  | 1053 | checkAllCopyRules(expectedCopyRules), | 
|  | 1054 | ) | 
|  | 1055 | } | 
|  | 1056 |  | 
|  | 1057 | func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) { | 
|  | 1058 | t.Run("target S build", func(t *testing.T) { | 
|  | 1059 | expectedSnapshot := ` | 
|  | 1060 | // This is auto-generated. DO NOT EDIT. | 
|  | 1061 |  | 
|  | 1062 | prebuilt_bootclasspath_fragment { | 
|  | 1063 | name: "mybootclasspathfragment", | 
|  | 1064 | prefer: false, | 
|  | 1065 | visibility: ["//visibility:public"], | 
|  | 1066 | apex_available: ["myapex"], | 
|  | 1067 | contents: ["mysdklibrary"], | 
|  | 1068 | hidden_api: { | 
|  | 1069 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 1070 | metadata: "hiddenapi/metadata.csv", | 
|  | 1071 | index: "hiddenapi/index.csv", | 
|  | 1072 | stub_flags: "hiddenapi/stub-flags.csv", | 
|  | 1073 | all_flags: "hiddenapi/all-flags.csv", | 
|  | 1074 | }, | 
|  | 1075 | } | 
|  | 1076 |  | 
|  | 1077 | java_sdk_library_import { | 
|  | 1078 | name: "mysdklibrary", | 
|  | 1079 | prefer: false, | 
|  | 1080 | visibility: ["//visibility:public"], | 
|  | 1081 | apex_available: ["myapex"], | 
|  | 1082 | shared_library: false, | 
|  | 1083 | public: { | 
|  | 1084 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], | 
|  | 1085 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], | 
|  | 1086 | current_api: "sdk_library/public/mysdklibrary.txt", | 
|  | 1087 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", | 
|  | 1088 | sdk_version: "current", | 
|  | 1089 | }, | 
|  | 1090 | } | 
|  | 1091 | ` | 
|  | 1092 | expectedCopyRules := ` | 
|  | 1093 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 1094 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv | 
|  | 1095 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv | 
|  | 1096 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv | 
|  | 1097 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 1098 | .intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar | 
| Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 1099 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt | 
|  | 1100 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt | 
|  | 1101 | ` | 
|  | 1102 |  | 
|  | 1103 | // On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part | 
|  | 1104 | // of the snapshot. | 
|  | 1105 | expectedStubFlagsInputs := []string{ | 
|  | 1106 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", | 
|  | 1107 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", | 
|  | 1108 | } | 
|  | 1109 |  | 
|  | 1110 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S", | 
|  | 1111 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot") | 
|  | 1112 | }) | 
|  | 1113 |  | 
|  | 1114 | t.Run("target-Tiramisu-build", func(t *testing.T) { | 
|  | 1115 | expectedSnapshot := ` | 
|  | 1116 | // This is auto-generated. DO NOT EDIT. | 
|  | 1117 |  | 
|  | 1118 | prebuilt_bootclasspath_fragment { | 
|  | 1119 | name: "mybootclasspathfragment", | 
|  | 1120 | prefer: false, | 
|  | 1121 | visibility: ["//visibility:public"], | 
|  | 1122 | apex_available: ["myapex"], | 
|  | 1123 | contents: [ | 
|  | 1124 | "mysdklibrary", | 
|  | 1125 | "mynewsdklibrary", | 
|  | 1126 | ], | 
|  | 1127 | hidden_api: { | 
|  | 1128 | annotation_flags: "hiddenapi/annotation-flags.csv", | 
|  | 1129 | metadata: "hiddenapi/metadata.csv", | 
|  | 1130 | index: "hiddenapi/index.csv", | 
|  | 1131 | signature_patterns: "hiddenapi/signature-patterns.csv", | 
|  | 1132 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", | 
|  | 1133 | filtered_flags: "hiddenapi/filtered-flags.csv", | 
|  | 1134 | }, | 
|  | 1135 | } | 
|  | 1136 |  | 
|  | 1137 | java_sdk_library_import { | 
|  | 1138 | name: "mysdklibrary", | 
|  | 1139 | prefer: false, | 
|  | 1140 | visibility: ["//visibility:public"], | 
|  | 1141 | apex_available: ["myapex"], | 
|  | 1142 | shared_library: false, | 
|  | 1143 | public: { | 
|  | 1144 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], | 
|  | 1145 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], | 
|  | 1146 | current_api: "sdk_library/public/mysdklibrary.txt", | 
|  | 1147 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", | 
|  | 1148 | sdk_version: "current", | 
|  | 1149 | }, | 
|  | 1150 | } | 
|  | 1151 |  | 
|  | 1152 | java_sdk_library_import { | 
|  | 1153 | name: "mynewsdklibrary", | 
|  | 1154 | prefer: false, | 
|  | 1155 | visibility: ["//visibility:public"], | 
|  | 1156 | apex_available: ["myapex"], | 
|  | 1157 | shared_library: true, | 
|  | 1158 | compile_dex: true, | 
|  | 1159 | permitted_packages: ["mynewsdklibrary"], | 
|  | 1160 | public: { | 
|  | 1161 | jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"], | 
|  | 1162 | stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"], | 
|  | 1163 | current_api: "sdk_library/public/mynewsdklibrary.txt", | 
|  | 1164 | removed_api: "sdk_library/public/mynewsdklibrary-removed.txt", | 
|  | 1165 | sdk_version: "current", | 
|  | 1166 | }, | 
|  | 1167 | } | 
|  | 1168 | ` | 
|  | 1169 | expectedCopyRules := ` | 
|  | 1170 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv | 
|  | 1171 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv | 
|  | 1172 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv | 
|  | 1173 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv | 
|  | 1174 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv | 
|  | 1175 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 1176 | .intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar | 
| Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 1177 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt | 
|  | 1178 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt | 
| Jihoon Kang | 1147b31 | 2023-06-08 23:25:57 +0000 | [diff] [blame] | 1179 | .intermediates/mynewsdklibrary.stubs/android_common/combined/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar | 
| Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 1180 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt | 
|  | 1181 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt | 
|  | 1182 | ` | 
|  | 1183 |  | 
|  | 1184 | // On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as | 
|  | 1185 | // they are both part of the snapshot. | 
|  | 1186 | expectedStubFlagsInputs := []string{ | 
|  | 1187 | "out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar", | 
|  | 1188 | "out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar", | 
|  | 1189 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", | 
|  | 1190 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", | 
|  | 1191 | } | 
|  | 1192 |  | 
|  | 1193 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu", | 
|  | 1194 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "") | 
|  | 1195 | }) | 
|  | 1196 | } | 
| Sam Delmerico | 3588136 | 2023-06-30 14:40:10 -0400 | [diff] [blame] | 1197 |  | 
|  | 1198 | func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) { | 
|  | 1199 | result := android.GroupFixturePreparers( | 
|  | 1200 | prepareForSdkTestWithJava, | 
|  | 1201 | java.PrepareForTestWithJavaDefaultModules, | 
|  | 1202 | java.PrepareForTestWithJavaSdkLibraryFiles, | 
|  | 1203 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"), | 
|  | 1204 | java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"), | 
|  | 1205 | prepareForSdkTestWithApex, | 
|  | 1206 | // Add a platform_bootclasspath that depends on the fragment. | 
|  | 1207 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), | 
|  | 1208 | android.FixtureMergeEnv(map[string]string{ | 
|  | 1209 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", | 
|  | 1210 | }), | 
|  | 1211 | android.FixtureWithRootAndroidBp(` | 
|  | 1212 | sdk { | 
|  | 1213 | name: "mysdk", | 
|  | 1214 | apexes: ["myapex"], | 
|  | 1215 | } | 
|  | 1216 | apex { | 
|  | 1217 | name: "myapex", | 
|  | 1218 | key: "myapex.key", | 
|  | 1219 | min_sdk_version: "S", | 
|  | 1220 | bootclasspath_fragments: ["mybootclasspathfragment"], | 
|  | 1221 | } | 
|  | 1222 | bootclasspath_fragment { | 
|  | 1223 | name: "mybootclasspathfragment", | 
|  | 1224 | apex_available: ["myapex"], | 
|  | 1225 | contents: ["mysdklibrary", "mynewsdklibrary"], | 
|  | 1226 | hidden_api: { | 
|  | 1227 | split_packages: [], | 
|  | 1228 | }, | 
|  | 1229 | } | 
|  | 1230 | java_sdk_library { | 
|  | 1231 | name: "mysdklibrary", | 
|  | 1232 | apex_available: ["myapex"], | 
|  | 1233 | srcs: ["Test.java"], | 
|  | 1234 | shared_library: false, | 
|  | 1235 | public: {enabled: true}, | 
|  | 1236 | min_sdk_version: "Tiramisu", | 
|  | 1237 | } | 
|  | 1238 | java_sdk_library { | 
|  | 1239 | name: "mynewsdklibrary", | 
|  | 1240 | apex_available: ["myapex"], | 
|  | 1241 | srcs: ["Test.java"], | 
|  | 1242 | compile_dex: true, | 
|  | 1243 | public: {enabled: true}, | 
|  | 1244 | min_sdk_version: "Tiramisu", | 
|  | 1245 | permitted_packages: ["mynewsdklibrary"], | 
|  | 1246 | } | 
|  | 1247 | `), | 
|  | 1248 | ).RunTest(t) | 
|  | 1249 |  | 
|  | 1250 | CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`)) | 
|  | 1251 | } |